469,909 Members | 1,765 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,909 developers. It's quick & easy.

Converting ASCII to UTF-8

I am getting some Korean characters data from MS SQL server. These
data were submitted as UTF-8 into the database, but stored as normal
varchars. So, when I getting them out of database by using Gridview
+SqlDataSource, they are actually ASCII format, but I couldn't just
convert the encoding of the page to get the proper UTF-8 format Korean

So, i modified a function from MS site, try to convert ASCII to UTF-8,
as below
protected string Convertor(string asciiString)
System.Text.Encoding ascii = System.Text.Encoding.ASCII;
System.Text.Encoding utf8 = System.Text.Encoding.UTF8;

byte[] asciiBytes = ascii.GetBytes(asciiString);
byte[] utf8Bytes = System.Text.Encoding.Convert(ascii, utf8,

char[] utf8Chars = new char[utf8.GetCharCount(utf8Bytes, 0,
utf8.GetChars(utf8Bytes, 0, utf8Bytes.Length, utf8Chars, 0);
string utf8String = new string(utf8Chars);

return utf8String;

But this doesn't work, all i get are question marks ???.

Anyone knows how do i solve this problem? From the SQL server side or
in the ASP.NET code?
Nov 28 '07 #1
0 5233

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Peter Wilkinson | last post: by
22 posts views Thread by Keith MacDonald | last post: by
4 posts views Thread by webdev | last post: by
5 posts views Thread by mail2atulmehta | last post: by
5 posts views Thread by Mike Currie | last post: by
11 posts views Thread by Jean-François Michaud | last post: by
9 posts views Thread by Michael Goerz | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.