Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Convert Hex to Unicode (Chinese)

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 87
Accepted Solution

Convert Hex to Unicode (Chinese)

Hi All,

I need to import excel spreadsheets containing Hex and convert it to the Chinese language so it can then be translated. An example is I need to convert:

73B0572865B94FBF62537ED94F605417 to

现在方便打给你吗

Is there a way this can be done? I've googled it to death but have yet to find an answer.

Many thanks in advance

Steve


Accepted Solutions
Solution
‎06-08-2015 01:11 AM
Trusted Advisor
Posts: 1,300

Re: Convert Hex to Unicode (Chinese)

This is because the SAS session you started is most likely run with 'English' encoding and not 'Unicode.'  So, while you are properly performing the encoding you are unable to store/view the unicode characters with the given session settings.

View solution in original post


All Replies
Trusted Advisor
Posts: 1,300

Re: Convert Hex to Unicode (Chinese)

data _null_;

input foo $hex32.;

bar=unicode(foo,'utf16b');

put bar;

cards;

73B0572865B94FBF62537ED94F605417

;

run;

Frequent Contributor
Posts: 87

Re: Convert Hex to Unicode (Chinese)

Hiya,

I tried your code but it doesn't appear to work:

Is it a matter of finding the correct encoding?

cheers

Steve

37   data _null_ ;

38   input foo $hex32.;

39   bar=unicode(foo,'utf16b');

40   put bar;

41   cards;

NOTE: Argument 1 to function UNICODE('s°W(e¹O¿bS~Ù'[12 of 16 characters shown],'utf16b') at line 39

      column 5 is invalid.

RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9---

42         73B0572865B94FBF62537ED94F605417

foo=s°W(e¹O¿bS~ÙO`T  bar=  _ERROR_=1 _N_=1

NOTE: DATA statement used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

44   run;

Solution
‎06-08-2015 01:11 AM
Trusted Advisor
Posts: 1,300

Re: Convert Hex to Unicode (Chinese)

This is because the SAS session you started is most likely run with 'English' encoding and not 'Unicode.'  So, while you are properly performing the encoding you are unable to store/view the unicode characters with the given session settings.

Valued Guide
Posts: 3,208

Re: Convert Hex to Unicode (Chinese)

Most sas installations are done wit a single byte Latin approach. Eguide is supporting utf8 that includes Chinese chars. When running sas in utf8 mode you should change your mind that 1 char is 1 byte. There are 1 to 4 bytes representing 1 char. Your reading and conversion of chars should go automatic. The challenge is that some coding habits need to change.

---->-- ja karman --<-----
Frequent Contributor
Posts: 87

Re: Convert Hex to Unicode (Chinese)

Thanks for your help, I should be able to get things working from here.

Super User
Posts: 9,681

Re: Convert Hex to Unicode (Chinese)

I tested Matt's code . It is right . I never realize SAS has such function ,must >=9.3  .

Trusted Advisor
Posts: 1,300

Re: Convert Hex to Unicode (Chinese)

,


I believe this function was added to SAS as a pre-production feature in 9.1.3 and then officially in 9.2

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 1198 views
  • 3 likes
  • 4 in conversation