如何将印度泰米尔语转换为unicode字符串

时间:2015-11-18 10:56:28

标签: .net unicode tamil

我要求发送一个泰米尔语短信,让我们说"தமிழ்"使用服务提供商。 服务提供者只需要Unicode字符串。 我不想要字节数组,

1 个答案:

答案 0 :(得分:-1)

在.NET中,应用程序中的所有字符串都已在Unicode字符集中进行编码。

如果要查看构成给定字符串的单个字符和字符代码,可以使用此控制台应用程序示例将它们打印到屏幕上进行分析。我无法看到您与SMS服务提供商的接口,因此需要修改此示例以满足您的需求:

class Program
{
    static void Main(string[] args)
    {
        const string str = "தமிழ்"; // this is already a unicode string.

        byte[] stringBytes = Encoding.Unicode.GetBytes(str);
        char[] stringChars = Encoding.Unicode.GetChars(stringBytes);

        foreach (var chr in stringChars)
        {
            // unicode character code
            var unicoded = ((int)chr).ToString();

            // hex character code
            var hexcoded = @"\u" + ((int)chr).ToString("X4").ToLower();

            // print to VS output window
            Trace.WriteLine(chr + "     " + unicoded + "     " + hexcoded);
        }
    }
}
相关问题