Unicode String versus ANSI String (PB10)Tag(s): Powerscript
Since PB is now Unicode-based, you may have a problem calling an external API which is expecting an ANSI string. The good news is that PB provides a way to convert the String to the required format.
Blob lbl_data lbl_data = Blob("Hello World!", EncodingANSI!) ls_data = String(lbl_data, EncodingANSI!) ...
STRINGS
In PB10, the PowerScript functions Len(), Left(), Mid(), and Right() are all Unicode
character based and are equivalent to the existing LenW(), LeftW(), MidW(), and RightW() functions.
To manipulate strings as bytes or ASCII characters instead of Unicode characters, a new set of LenA(), LeftA(), MidA(), and RightA() functions have been added. When the 'A' functions are applied, PowerBuilder will convert the Unicode string to a DBCS string based on the machine's locale, and then apply the operation.
FILES
The FileOpen() function now has an Encoding argument for identifying the encoding of the target file. The function
FileEncoding(filename) determines and returns the encoding (EncodingANSI!, Encoding UTF8! ,
EncodingUTF16LE!, And EncodingUTF16BE!) used in the file. The FileEncoding() function
should precede the opening of existing files so the correct encoding parameter can be pass in the
FileOpen() call.
// PB10 li_FileNum = FileOpen("Emplyee.txt", TextMode!, Read!,EncodingANSI!) // PB9 //li_FileNum = FileOpen("Employee.txt", TextMode!)
More details at http://www.sybase.com/content/1036154/L02684_PB_InternationalizedApps_WP.pdf
Send comment, question or suggestion to howto@rgagnon.com