XOJO 2019R3 Encodings Issues

Forget my code. I did not see somehow that you already convert f+lName to UTF8 before you merge it into fContent …
I have to leave this conversation for now, but hope someone else can help you. :slight_smile:

Well Apparently I did let only the [quote]fContent = TIStream.readAll.ConvertEncoding(Encodings.UTF8)[/quote] to get all the text as UTF 8 and then I did a method

[code]
Method Name ToUTF8Text Extends s As String Return Type String

Var result As String

If s.Encoding = Nil Then
result = DefineEncoding(s, Encodings.UTF8)

Else
result = ConvertEncoding(s, Encodings.UTF8)

End If

Return result[/code]

So apparently the XOJO IDE was creating confusion for me as now after all this I get [quote]St?hanie[/quote] as name but in the printing file it shows correct so no idea what to think now , I guess I have to ignore the IDE debug side as it can be deceiving

and I did disabled as well the Encoding on Reading the file and Writing the file.

That would work only if the original file was UTF8 encoded to begin with, but not in any other case. As I said: define the encoding when you read text and convert to another encoding (if required) when you save it. You may convert everything to UTF8 after you have defined the encoding (if the encoding isn’t UTF8 to begin with) to streamline internal string handling but that isn’t critical; characters come out right internally regardless of the encoding, provided the encoding is known and properly defined.

Well that was the point , I dismissed the text input stream encoding as I have no idea what is it and what it was as they tend to create in Windows and on Mac those templates and when I read the raw rtf data I converted all that in UTF8 and I start working from there, and apparently it works, not perfect fix but for the moment it works, hopefully I’ll dismiss soon the rtf part and work with docx directly and done.

Hi there
encoding with the German special characters has UFT8
a length problem in the storage because the special characters are saved as 2 bytes. The display in the text is correct.
I now use memory block with leftb () so as not to overwrite my fixed memory size.
Example Test (8 bytes in the display) has a length of 11 bytes
a string.left (8) does not work, 11 bytes remain when saving

Rudolf: That is why String.LeftBytes exists. Try with that.

String.LeftBytes …

Explanation:
String.Left returns the umber of characters (what you see on screen)
String.LeftBytes returns the number of Bytes the characters occupy in memory.