I'm using Mathematica10.0.2 on my Win7. Recently I crawled some websites by mathematica and within the information returned by URLFetch there are plenty of UTF-16M codes. These UTF-16M codes are actually the names of web user and I intended to translate them into normal words or characters.

a sample of UTF-16M codes looks like


(If you manipulate the string above the Mathematica might warning with a heap of "Unknown string escape \u." But this is not the key point)

There are online tools to convert UTF-16 codes to the TEXT, here is a example: http://macchiato.com/unicode/convert.html

If you type the codes such as 5929 or 4e0a or 4eba or 95f4 into the website above, the Output would give you the corresponding word/characters.

My problem is how could I do this by Mathematica automatically?

I tried

 ImportString["5929", "Character16"] 

It gave wrong result.


 "\\u5927", {"Character16"}]], #] & /@

still all same wrong results

 "\\u5927"], #] & /@ $CharacterEncodings

didn't work...

What should I do?

(*Err something like URLFetch["http://macchiato.com/unicode/convert.html","Method"->"POST",...] might be too awkward *)


2 Answers 2


I'm going to assume you want this specific char:

Unicode Han Character

The issue is not with Mathematica's character code conversion, but instead the encoding source.

The value you have obtained is in Hex, where you need the decimal to use FromCharacterCode.

Hex-> Dec-> Front end





  • $\begingroup$ Great find, I tried, but the only relevant search result I found from "UTF-16M" was the converter linked to in the OP $\endgroup$
    – Jason B.
    Commented Apr 26, 2016 at 18:36
  • $\begingroup$ you don't need to search "UTF-16M", just search UTF-16. @JasonB $\endgroup$
    – Harry
    Commented Apr 27, 2016 at 5:10

You can also use FromDigits:

FromCharacterCode[FromDigits[#, 16] &
  /@ StringSplit["\u5929\u4e0a\u4eba\u95f4", "\u"]]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.