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

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

asp.net - Configuring WCF Services in Code WCF 4.5 -