1. ma jack
  2. PowerBuilder
  3. Thursday, 9 March 2023 10:01 AM UTC

Hello everyone


I now have a a.txt file, the content is \u5171\u7528, after using the fileread() function to read, I want to convert \uxxxx into corresponding characters, the following is my attempt

li_fhandl=fileopen("C:\work\a.txt")
li_fread=fileread(li_fhandl, ls_line)
lbl_data = Blob(ls_line, EncodingUTF8!)
ls_str = String(ls_line, EncodingUTF8!)
messagebox("", ls_str)

 

\u5171\u7528 is displayed in the pop-up, because \u5171\u7528 is always treated as a string instead of a unicode, I tried to search for decode in https://docs.appeon.com/pb2019r3/powerscript_reference/ and did not find a suitable function


Is there any function to solve this problem?

Accepted Answer
Benjamin Gaesslein Accepted Answer Pending Moderation
  1. Thursday, 9 March 2023 11:19 AM UTC
  2. PowerBuilder
  3. # Permalink

You can use the HexDecode function of coderobject for this. Sample:

coderobject code
blob lblb_uni
string ls_uni
ls_uni = 'u\5171\u7528'

code = create coderobject
lblb_uni = code.hexdecode( ls_uni )
messagebox( 'Uni', string(lblb_uni, EncodingUTF16BE!) )
Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Thursday, 9 March 2023 11:18 AM UTC
  2. PowerBuilder
  3. # 1

Do a search in the PB help on "Coderobject", maybe it will have a function that you can use for your purpose?

regards.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.