encoding (optional for PowerBuilder)
|
Character encoding of the file to which the data is saved. This parameter applies only to the following formats: TEXT, CSV, SQL, HTML, and DIF. If you do not specify an encoding parameter, the file is saved in ANSI format. Values are:
-
EncodingANSI! (default)
-
EncodingUTF8!
-
EncodingUTF16LE!
-
EncodingUTF16BE!
|
Anyway, I don't know if anyone knows an easier way, but I guess you'd have to convert the resulting file to UTF8 somehow after doing the SaveAs().
So use FileOpen(), Blob and String Conversion FileReadEx, FileWriteEx, etc. Here's an example which does not do the exact conversion that you want, but will give you an idea of how to do the conversion.
From the Powerbuilder Help on FileEncoding(), You'll also have to do a FileOpen() in streammode for the data that you are going to write as UTF8. See the help on FileOpen() and FileEncoding().
From the help on FileEncoding():
long ll_filenum
integer li_bytes
string ls_unicode
blob lb_ansi
encoding eRet
ll_filenum = FileOpen("employee.dat", StreamMode!, Read!, LockWrite!, Replace!)
// test the file's encoding
eRet = FileEncoding("employee.dat")
if eRet = EncodingANSI! then
li_ bytes = FileReadEx(ll_filenum, lb_ansi)
ls_unicode = string(lb_ansi, EncodingANSI!)
else
li_ bytes = FileReadEx(ll_filenum, ls_unicode)
end if
FileClose(ll_filenum)
// You would add the code here for writing the "ls_unicode" to a file which you have opened with encoding UTF8
......
HTH, regards
Yes, I just tried this myself now and it does not work in PB2017/2019. :-(
I'll post my workaround solution next as a reply to your initial post so that you can see more of my workaround. In the mean-time, I would open a Support Ticket for this issue.
Regards .. Chris