public String text2uni2(String arg_Source)
{
int enCode;
char[] charArray = arg_Source.ToCharArray();
StringBuilder uniText = new StringBuilder(arg_Source.Length * 2);
for (int i = 0; i < charArray.Length; i++)
{
char a = charArray[i];
uniText.Append("\\u");
enCode = (a >> 8);
string hexCode = enCode.ToString("X");
if (hexCode.ToString().Length == 1)
{
uniText.Append("0");
}
uniText.Append(hexCode);
enCode = (a & 0xFF);
hexCode = enCode.ToString("X");
if (hexCode.ToString().Length == 1)
{
uniText.Append("0");
}
uniText.Append(hexCode);
}
return (uniText.ToString());
}
例如ドラマも大人気「のだめカンタービレ」の世界
轉換後
\u30c9\u30e9\u30de\u3082\u5927\u4eba\u6c17\u300c\u306e\u3060\u3081
\u30ab\u30f3\u30bf\u30fc\u30d3\u30ec\u300d\u306e\u4e16\u754c
La new打進冠軍決賽
轉換後
\u004c\u0061\u0020\u006e\u0065\u0077\u6253\u9032\u51a0\u8ecd\u6c7a\u8cfd
沒有留言:
張貼留言