0
$\begingroup$

I have a bunch of Chinese characters that I would like to change into decimal numbers, then into binary numbers. I would then like to take back the binary numbers and change them into decimal numbers and finally into their original form of a character. But the problem is that when I use the FromDigits[], it gives me back a different decimal number than the original, thus resulting in a different Chinese character.

In[201]:= ToCharacterCode["癿"]
Out[201]= {30335}
In[202]:= IntegerDigits[%, 2, 8]
Out[202]= {{0, 1, 1, 1, 1, 1, 1, 1}}
In[203]:= FromDigits[%]
Out[203]= {0, 1, 1, 1, 1, 1, 1, 1}
In[204]:= FromDigits[%, 2]
Out[204]= 127 
In[205]:= FromCharacterCode[%]
Out[205]= ""

How to fix this problem? I tried reading the documentation and I believe it might be something with the encoding. However, I am not sure how to fix it.

$\endgroup$
  • $\begingroup$ 8 bits isn't enough to encode 30335 decimal. $\endgroup$ – John Doty Jan 3 '18 at 19:21
  • $\begingroup$ Yes, you are right. Thank you for pointing out my mistake. $\endgroup$ – user3318424 Jan 4 '18 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.