如何在vb.net 2.0 Windows窗体组合框中显示来自sql 2005的unicode数据 [英] how to display unicode data from sql 2005 in vb.net 2.0 windows forms combobox
本文介绍了如何在vb.net 2.0 Windows窗体组合框中显示来自sql 2005的unicode数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请告诉我如何在vb.net 2.0 Windows窗体组合框中显示来自sql 2005的unicode数据.
我可以将值存储在数据库中,但是当它不可用时,它会以盒子形式出现.
Please tell me how to display unicode data from sql 2005 in vb.net 2.0 windows forms combobox.
I am able to store values in database, but when it is disalying it is coming as boxes.
推荐答案
您可以尝试下面的代码.
You can try following code.
//Code starts here
static void convertunicode()
{
string unicodeString = "This string contains the unicode character Pi(\u03a0)";
// Create two different encodings.
Encoding ascii = Encoding.ASCII;
Encoding unicode = Encoding.Unicode;
// Convert the string into a byte[].
byte[] unicodeBytes = unicode.GetBytes(unicodeString);
// Perform the conversion from one encoding to the other.
byte[] asciiBytes = Encoding.Convert(unicode, ascii, unicodeBytes);
// Convert the new byte[] into a char[] and then into a string.
// This is a slightly different approach to converting to illustrate
// the use of GetCharCount/GetChars.
char[] asciiChars = new char[ascii.GetCharCount(asciiBytes, 0, asciiBytes.Length)];
ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0);
string asciiString = new string(asciiChars);
// Display the strings created before and after the conversion.
Console.WriteLine("Original string: {0}", unicodeString);
Console.WriteLine("Ascii converted string: {0}", asciiString);
}
//Code Ends Here
HTH
HTH
这篇关于如何在vb.net 2.0 Windows窗体组合框中显示来自sql 2005的unicode数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文