Menu

#1752 binay scan can't work correctly

obsolete: 8.3.4
closed-invalid
5
2002-01-20
2002-01-19
Anonymous
No

I want to change a Chinese character, which unicode
value is \u4e2d, to hex.the following is my commands.

set a \u4e2d
binary scan $a H* b

after I run the two commands, the value of variable b
is 2d, not 4e2d. who can tell me why? thanks

my email : dimblue@163.net

Discussion

  • Jeffrey Hobbs

    Jeffrey Hobbs - 2002-01-20

    Logged In: YES
    user_id=72656

    You want "format %x [scan \u4e2d %c]", as is:

    (hobbs) 60 % format %x [scan \u4e2d %c]
    4e2d

    \u4e2d is not binary, it's just a utf-8 string, so use the
    regular scan.

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2002-01-20
    • status: open --> closed-invalid
     
  • Donal K. Fellows

    Logged In: YES
    user_id=79902

    A better solution is:
    binary scan [encoding convertto unicode $a] H* b
    (because that is better at dealing with characters with the
    highest bit set.)