1

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

4

1 回答 1

-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);
        }
    }
}
于 2015-11-27T12:22:58.110 回答