英语到希伯来语的字符 [英] English to hebrew chracters

查看:83
本文介绍了英语到希伯来语的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我给代码,MultiByteToWideChar无法将英语转换为希伯来语语言



页面为1255你能告诉我它为什么会发生这种情况。



我尝试过:



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

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

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);

推荐答案

MultiByteToWideChar 不翻译。它在不同的字符编码之间进行转换。



使用您的示例代码调用它将使用指定的代码页(1255 = ANSI希伯来语)将字符串转换为UTF-16LE(Windows内部使用的Unicode编码)。字符编码意味着将二进制代码分配给特定字符。转换只是根据传递的代码页查找输入字符串代码的UTF-16LE代码。



使用像125x ANSI这样的8位代码页,低128个字符按原样映射(UTF-16LE输出的高字节为零),并查找高128个字符。示例:



字符 ANSI-1255 UTF- 16LE
A 的0x41 0x0041
א 0xE0 0x05D0




您可能正在寻找翻译或音译。 Windows不提供此类功能。因此,您必须自己编写或在网上搜索现有代码。
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.


添加到已经给出的Jochen Amtdt解决方案,如果您想要进行转换,我建议您创建查找表,字符的英文部分的值用作数组的索引,值是希伯来语。



这允许您通过简单地使用它引用的值来使用字符的值来自我转换。你需要处理大小写,并处理你不想修改的字符(将它们设置为零并用作标记或映射到自己 - 后者在运行时更有效,因为你不需要测试价值,而前者更容易设置)。



当然,你需要反转文本 - 无论是绝对值还是更改将块呈现给R-> L。
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.


这篇关于英语到希伯来语的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆