Click here to Skip to main content
15,924,367 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
MultiByteToWideChar doesnt able to convert english to hebrew language if i give code

page as 1255 can u please tell me why its happening .

What I have tried:

nSize = MultiByteToWideChar(nlanguageCodePage, 0, sUnicodeBuff, -1, NULL, NULL);
MultiByteToWideChar(nlanguageCodePage, 0, sUnicodeBuff, -1, chUniocodeBuff, nSize);
Posted

MultiByteToWideChar does not "translate". It converts between different character encodings.

Calling it like with your example code will convert strings using the specified codepage (1255 = ANSI Hebrew) to UTF-16LE (the Unicode encoding used internally by Windows). Character encoding means that binary codes are assigned to specific characters. The conversion just looks up the UTF-16LE codes for the codes of the input string according to the passed code page.

With 8-bit code pages like 125x ANSI, the lower 128 characters are mapped as they are (the high byte of the UTF-16LE output is zero) and the upper 128 characters are looked up. Example:

CharacterANSI-1255UTF-16LE
A0x410x0041
א0xE00x05D0


You are probably looking for a translation or transliteration. Windows does not provide such functions. So you have to write it yourself or search the web for existing code.
 
Share this answer
 
Adding to Jochen Amtdt solution already given, if you wish to make up your on conversion I suggest you create a look-up table, the value of the English part of the characters is used as the index into an array, the value is the Hebrew.

This allows you to use the value of the character to translate itself by simply using the value it references. You'll need to handle Upper and lower cases, and handle the characters you don't wish to modify (set them to zero and use as flag or map to themselves - the latter more efficient at run time as you don't need to test the value, whilst the former easier to set up).

And, of course, you'll need to reverse the text - either in absolute terms or changing the presentation of the block to R->L.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900