Hello,
We have to convert blob data into string. The blob content could be encoded in UTF8, ANSI or UTF16LE.
How to identify which encoder to use for string conversion?
Thank you,
Yuri
Hello,
We have to convert blob data into string. The blob content could be encoded in UTF8, ANSI or UTF16LE.
How to identify which encoder to use for string conversion?
Thank you,
Yuri
Hopefully the fix for FileEncoding will by default fix FileOpen but if not hopefully FileOpen will also be addressed.
Here is the code I used that ultimately worked:
li_file_handle = FileOpen(ls_path + This.Text(li_counter), StreamMode!, Read!, LockReadWrite!, Append!, EncodingANSI!) //EncodingANSI! required for accents
li_chars_read = FileReadEx(li_file_handle,lb_blob)
ls_total_file = String(lb_blob, EncodingUTF8!) //EncodingUTF8! required for accents
At the time this really struck me as odd having to open the file with ANSI encoding in order to properly read a UTF-8 encoded file, but doing so along with some conversion ended up working. I thought it might be related to byte order marking and very strict adherence to the absence or presence of BOM, but thanks to your bug submission I now know it is a bug.
Regards,
I've the same problem and i've found the same workaround.
https://community.appeon.com/index.php/qna/q-a/fileencoding-utf8-file-returns-ansi
My problem is that the input files can be sometimes in ANSI, sometimes in UFT8.
The program doesn't know it.
So the conversion String(lb_blob, EncodingUTF8!) cannot always be done (if the file is ANSI, i get asian character).
So did you find a workaround to check the right file encoding ?
If not, then the only thing I can think of is to utilize Roland's suggestion re: IsTextUnicode but I thought in the other Q&A thread someone stated it didn't work or it didn't work enough maybe?!
Regards,