C++ Arabic UTF8 string to CString -


in visual studio 2008 mfc project i've manage strings in utf8 containing arabic cities , searching onlines write little piece of code:

    cstring myclass::convertstring(string input) {     int l = multibytetowidechar(cp_utf8, 0, input.c_str(), -1, null, 0);     wchar_t *str = new wchar_t[l];     int r = multibytetowidechar(cp_utf8, 0, input.c_str(), -1, str, l);     cstring output = str;     delete str ;     return output; } 

when try convert string remains same , if try print these 2 string result same. doing wrong?

thanks in advance.

you don't want convert strings utf-8 display purposes. there no utf-8 charset allow display them correctly. if have them in unicode, keep them in unicode. build application in unicode , avoid mbcs if can. makes life easier. otherwise, displaying arabic strings, have convert them arabic codepage , use arabic font/charset display them.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -