Quantcast
Channel: Windows 7 Miscellaneous forum
Viewing all articles
Browse latest Browse all 11372

Unable to copy a char* type string to _bstr_t data type in vc++ ,application running on Windows 7 32 bit/64 bit with system as a Japanese locale,some problematic japanese characters are changing as incorrect .

$
0
0

Can anybody provide a solution for below problem.

Code sample: vc++ under VS 2010 

/////////////////////////////////////////////////

patternValue=  タイプ

patternLen = 3

int nChars = WideCharToMultiByte( CP_UTF8, 0, patternValue, patternLen, 
NULL, 0 ,  NULL, NULL); //changed from CP_UTF8 to the retrieved code page

char *pChars = new char[nChars];
ZeroMemory(pChars, nChars );


WideCharToMultiByte( codPageTobeUsed, 0, patternValue, patternLen, 
pChars, nChars ,  NULL, NULL); 

pChars[nChars] = '\0';

_bstr_t bstrPattern(pChars);

///////////////////////////////////////////////

After conversion :

The bstrpattern contains as タイチE

the problematic character  is  プ after conversion it has ' チE'

The above is happened for all the japanese  Katakana character set(i.e.  0x30D0  to 0x30DF)

This problem is happened when the system has japanese locale only.() 

how to change system locale is :Control Panel\All Control Panel Items ->region and language then select Administrative tab then click changesystemlocale

Can anybody resolve the problem and send me the solution to ramu.50k@gmail.com

Best Regards,

Ramakrishna N




Viewing all articles
Browse latest Browse all 11372

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>