Hello Massimo,
I've used WriteString passing in constructor both UTF-8 and UTF-16 integer buth results are very strange, and doesn't give me the requested file.
I think (but this is my opinion) that the file "i_want_this.txt" is in Unicode (UTF-16), while "i_have_this.txt" is UTF-8.
I'll try again with Writestring.
I'll build a simple app that loop with all the code page available for the constructor to see if there is a way to accomplish this.
Do you want to encode it in UTF16?
If yes then you should use BinaryFile.New2 with code page 1200.
Then you should convert the string to bytes with BinaryFile.StringToBytes. The last step is to write the bytes with WriteBytes.
You should not use BinaryFile.WriteString as it adds the string length as a prefix.
Edit: Once again, I've wrote this post before reading your previous two...
I see two differences:
- utf16.txt is missing the UTF16 BOM. You should write the following two bytes at the beginning of the file: 255, 254.
- utf16.txt is missing the last chr(10) character. I think that it is LF but it doesn't really matter.
I see two differences:
- utf16.txt is missing the UTF16 BOM. You should write the following two bytes at the beginning of the file: 255, 254.
- utf16.txt is missing the last chr(10) character. I think that it is LF but it doesn't really matter.
Write the bytes at the beginning with: BinaryFile.WriteByte(255) and BinaryFile.WriteByte(254).
You can add the chr(10) into the string: str = "some string" & chr(10).
You can also write it with WriteByte(10) followed by WriteByte(0).