开发者

Encoding Problem after convert PB7 to PB10.5

开发者 https://www.devze.com 2023-03-30 20:06 出处:网络
After i convert from PB7 to 10.5 i have problem in old storage SQL server database Arabic character,it shows the characters

After i convert from PB7 to 10.5 i have problem in old storage SQL server database Arabic character,it shows the characters in data开发者_如何学Cwindow as strange symbols that has no meaning like ÓíÇÑÉ ÕÛíÑÉ ?


Two things you need to look at when migrating to PB10 or higher. Strings in external function calls and any data read in files, such as ini files or file read functions. The reason why is that PB10 was the version where strings were based on Unicode instead of ANSI.

You'll start running into problems where your string data has garbage characters when it used to work fine. The good news is that PB provides a way to convert the string to the required format and there are functions for both.

The default PB10 encoding is UTF-16, little endian (EncodingUTF16LE!)

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. is any reading/writing of files because around PB10 it went to unicode. PB converted all the existing functions to Unicode and created new versions of the functions. So in PB10 Powerscript functions Len(), Left(), Mid() were changed to unicode and new functions Len.

 Blob lbl_data
 lbl_data = Blob("Hello World!", EncodingANSI!)
 ls_data = String(lbl_data, EncodingANSI!)


 // PB10 and higher
 li_FileNum = FileOpen("MyFile.txt", TextMode!, Read!, EncodingANSI!)

 // PB9 and lower you didn't need EncodingANSI!
 //li_FileNum = FileOpen("MyFile.txt", TextMode!)

What happens if you don't add EncodingANSI! ? All the data you get from external files will be unreadable garbage characters. This is about the most significant issue when upgrading to PB10 and above, but it's very simple to resolve once you figure it out.

I don't think your database issues are related to the encoding but it is possible. If you are seeing garbage characters you probably have mismatches with encoding.

0

精彩评论

暂无评论...
验证码 换一张
取 消