我们无法将Unicode字符串转换为UTF-8字符串以通过网络发送:
// Start with our unicode string.
string unicode = "Convert: \u10A0";
// Get an array of bytes representing the unicode string, two for each character.
byte[] source = Encoding.Unicode.GetBytes(unicode);
// Convert the Unicode bytes to UTF-8 representation.
byte[] converted = Encoding.Convert(Encoding.Unicode, Encoding.UTF8, source);
// Now that we have converted the bytes, save them to a new string.
string utf8 = Encoding.UTF8.GetString(converted);
// Send the converted string using a Microsoft function.
MicrosoftFunc(utf8);
Run Code Online (Sandbox Code Playgroud)
虽然我们已经将字符串转换为UTF-8,但它并没有以UTF-8的形式到达.
我正在使用Access 2000数据库"现代化"经典的asp应用程序.
我在SQL Server 2008r2上重写了数据库并更改了所有字段以使用更新的unicode启用nchar,nvarchar,ntext并导入旧数据.我还从IIS 6切换到IIS 7
经典的asp使用UTF-8收集和写入数据.
现在,应用程序在网页中正确显示OLD数据,但是当我触摸它时,即:更新或插入数据正在被破坏.我假设在将数据写入SQL服务器之前,我需要以某种方式将UTF-8数据从经典的asp转换为UCS-2.
但是怎么样?
注意:似乎sql server在从access访问导入数据时自动将utf-8数据转换为可用格式.