Recently someone asked me about how to cast a multi byte character to a single byte character to get a Cyrillic string encoded in a char data type. In general terms the answer is using the WideCharToMultiByte method but be aware of setting the right length parameter (usually it’s necessary adding the null terminated character size) and the right code page. To answer the question I wrote this function:

        char* Wchar_tToAnsi(wchar_t* SS1)
            int ISO_8859_5 = 28595;
            char* SS2;
            int strsize = WideCharToMultiByte(ISO_8859_5, 0, SS1, wcslen(SS1) + 1, NULL, 0, NULL, NULL);
            SS2 = new char[strsize];
            WideCharToMultiByte(ISO_8859_5, 0, SS1, wcslen(SS1) + 1, SS2, strsize, NULL, NULL);
            return SS2;

To use the above function simply get the data representation as wchar_t, no matter what’s your development plaform, if it’s windows that’s the datatype you should use as follows:

            wchar_t str[]=L"восемь зданий";
            char *newStr=Wchar_tToAnsi(str);


Javier Andrés Cáceres Alvis

Microsoft Most Valuable Professional – MVP
Intel Black Belt Software Developer