这里是我用来将Georgian unicode 转换为其拉丁等效文本的代码 sn-p。
string[] charset = new string[33] { "a", "b", "g", "d", "e", "v", "z", "T", "i", "k", "l", "m", "n", "o", "p", "J", "r", "s","t", "u", "f", "q", "R", "y", "S", "C", "c", "Z", "w", "W", "x", "j", "h" };
string unicodeString = "აბ, - გდ";
string latin_string = "";
byte[] unicodeBytes = Encoding.Unicode.GetBytes(unicodeString);
for (int p = 0; p < unicodeBytes.Length / 2; p++)
{
if (unicodeBytes[p * 2] > 207 && unicodeBytes[p * 2] < 241)
latin_string += charset[unicodeBytes[p * 2] - 208];
else
latin_string += Convert.ToChar(unicodeBytes[p * 2]).ToString();
}
只解释必要的部分:
Encoding.Unicode.GetBytes(unicodeString); 返回字节数组,这个数组的长度是2 * unicodeString.Length。这样来自 unicodestring 的每个字母都有一对字节。
为了更好的解释,附上图片
unicodeBytes 甚至索引都有代表您要解码的字母的值。格鲁吉亚字母的第一个字母从 208 开始,到 240 结束(总共 33 个)。因此,如果 unicodeBytes 值在 [208;240] 范围内,我必须使用 charset 字符串数组来获得拉丁等价物,否则 unicodeBytes 值只是字符代码。
我不知道是否有它的库,但这种方法将让您基本了解如何编写自己的转换器。