How to convert a string containting the hex value of a UTF-8 to a wchar in C? -


i using gcc. have string containing hex value of utf-8 char this:

char[] str = "4e86" 

(such kind of strings read out xml-file). convert wchar containing character \u4e86.

i know can directly define

wchar_t wc = l'\u4e86'; 

but function this

wchar_t wc = convert(str) 

how?

try this:

char[] str = "4e86"; wchar_t wc = strtol(str, null, 16); 

(ref: https://stackoverflow.com/a/10156436/999400)


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -