Hi Moshe,
When following Chris' steps, if you're seeing that it's UTF-8 encoding then I suspect the file is UTF-8 WITHOUT BOM and that may be causing your issue. PowerBuilder can only correctly read a UTF-8 encoded file as long as it has the BOM (or Byte Order Mark) in place, although there is a way around this...see below.
@Andreas...you're mostly correct with the exception that PB will not properly detect UTF-8 without BOM and will default to ANSI which is likely what is causing Moshe's issue versus having the correct font.
Moshe, what I would suggest is that you follow Chris' steps to File, Save As but continue on to save it but when doing so change the encoding to UTF-8 with BOM. Then try to process the file. If it works then you have a few options for a more permanent solution:
- Convert each file you wish to process using the above steps, but this may not be convenient/ efficient to have to do this each time,
- See if the source/ provider of the file can have it created using UTF-8 with BOM,
- Process it the way you have been but with these lines of code first (I have not included variable declarations but hopefully they are obvious):
li_file_handle = FileOpen(ls_path_filename, StreamMode!, Read!, LockReadWrite!, Append!, EncodingANSI!)
ll_chars_read = FileReadEx(li_file_handle,lblb_file_contents)
ls_contents_as_utf8 = String(lblb_file_contents, EncodingUTF8!)
The above opens the file with ANSI encoding, reads the file into a BLOB variable and then converts it into a String variable using the String function and specifying EncodingUTF8! You can then process the contents of the String variable or write it back out to a text file with UTF-8 with BOM encoding and process it from there.
HTH...regards,
Mark
the charecthers are all unreadble
why ?
Andreas.