再问UTF8,知道U8的编码,怎么得到它对应的字符?
有这样一张表,想通过前面的U8代码得到字符,与第二列对比防止错误,有啥好办法没?
30E0ム
30E1メ
30E2モ
30E3ャ
30E5ュ
30E6ユ
30E7ョ
30E8ヨ
30E9ラ
30EAリ
30EBル
30ECレ
30EDロ
30EFワ
30F3ン
[解决办法]
幫顶
朋友 有空就看看这个问题。沒空就算了,謝過了.http://community.csdn.net/Expert/topic/5686/5686047.xml?temp=.8212702
[解决办法]
UTF8Encoding e = new UTF8Encoding();
e.GetString(你要转化的byte[]); //这个用来解码,返回一个string
e.GetByte(string s); // 这个用来编码,返回byte[]
[解决办法]
直接定义!~
char c= '\u30E0 ' //ム
这是unicode 码! 相信你是从windows 文字code表里找的!~
呵呵!~~
[解决办法]
转成Char型
char ch = '\u30E0 ';
MessageBox.Show(ch.ToString());
[解决办法]
//将UTF-8编码转换成字符串
public string FromUtf8(string str)
{
char[] hexDigits = { '0 ', '1 ', '2 ', '3 ', '4 ',
'5 ', '6 ', '7 ', '8 ', '9 ',
'A ', 'B ', 'C ', 'D ', 'E ', 'F '};
List <byte> byteList = new List <byte> (str.Length / 3);
if (str != null)
{
List <string> strList = new List <string> ();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < str.Length; ++i)
{
if (str[i] == '% ')
{
strList.Add(str.Substring(i, 3));
}
}
foreach (string tempStr in strList)
{
int num = 0;
int temp = 0;
for (int j = 0; j < hexDigits.Length; ++j)
{
if (hexDigits[j].Equals(tempStr[1]))
{
temp = j ;
num = temp < < 4;
}
}
for (int j = 0; j < hexDigits.Length; ++j)
{
if (hexDigits[j].Equals(tempStr[2]))
{
num += j;
}
}
byteList.Add((byte)num);
}
}
return Encoding.UTF8.GetString(byteList.ToArray());
}
[解决办法]
// 数据库存的是字符串 ?
char ch = (char)byte.Parse(dr[1].ToString(), NumberStyles.AllowHexSpecifier);
[解决办法]
// OR
char ch = (char)byte.Parse( "0x " + dr[1].ToString());
[解决办法]
不懂,帮顶
[解决办法]
试试这样
int n = int.Parse( "30E0 ", System.Globalization.NumberStyles.AllowHexSpecifier); // 转为整型,这样不会溢出了
byte[] bytes = System.BitConverter.GetBytes(n); // 转为字节数组
string str = System.Text.Encoding.UTF8.GetString(bytes); // 转为字符