473,725 Members | 2,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(strin g asciiString)
System.Text.Enc oding ascii = System.Text.Enc oding.ASCII;
System.Text.Enc oding utf8 = System.Text.Enc oding.UTF8;

byte[] asciiBytes = ascii.GetBytes( asciiString);
byte[] utf8Bytes = System.Text.Enc oding.Convert(a scii, utf8,

char[] utf8Chars = new char[utf8.GetCharCou nt(utf8Bytes, 0,
utf8Bytes.Lengt h)];
utf8.GetChars(u tf8Bytes, 0, utf8Bytes.Lengt h, utf8Chars, 0);
string utf8String = new string(utf8Char s);

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 5448

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Peter Wilkinson | last post by:
Hello tlistmembers, I am using the encoding function to convert unicode to ascii. At one point this code was working just fine, however, now it has broken. I am reading a text file that has is in unicode (I am unsure of which flavour or bit depth). as I read in the file one line at a time (readlines()) it converts to ascii. Simple enough. At the same time I am copressing to bz2 with the bz2 module but that works just fine. The code...
by: Keith MacDonald | last post by:
Hello, Is there a portable (at least for VC.Net and g++) method to convert text between wchar_t and char, using the standard library? I may have missed something obvious, but the section on codecvt, in Josuttis' "The Standard C++ Library", did not help, and I'm still awaiting delivery of Langer's "Standard C++ IOStreams and Locales". Thanks,
by: gnv | last post by:
Hi all, I am writing a cross-browser(i.e. 6 and netscape 7.1) javascript program to save an XML file to local file system. I have an xml string like below: var xmlStr = "<?xml version="1.0" encoding="UTF-8"?><a>some info</a>"; I want to save this xml file to local file system with JavaScript,
by: webdev | last post by:
lo all, some of the questions i'll ask below have most certainly been discussed already, i just hope someone's kind enough to answer them again to help me out.. so i started a python 2.3 script that grabs some web pages from the web, regex parse the data and stores it localy to xml file for further use.. at first i had no problem using python minidom and everything concerning
by: mail2atulmehta | last post by:
I have a question. how to generate two files, one in UTF-8, the other in ASCII with the same column length SO that when i do the conversion from utf-8 to ascii, the column length does not change . any help is appreciated thanks
by: clintp | last post by:
I have a byte array that contains 8-bit ascii characters. I'm not particular about the codepage used to display them, but I have to preserve the position in the string with something and be able to back to the original byte implementation. For example, this doesn't work: // Bytes for .02{cent} in my standard codepage byte ba = new Byte { 0x2e, 0x30, 0x32, 0x9b };
by: Mike Currie | last post by:
Can anyone explain why I'm getting an ascii encoding error when I'm trying to write out using a UTF-8 encoder? Thanks Python 2.4.3 (#69, Mar 29 2006, 17:35:34) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> filterMap = {} >>> for i in range(0,255):
by: Jean-Franēois Michaud | last post by:
Hello all, I'm having a little problem, The UTF-8 parser we are using converts the newline entity ( ) within an attribute that we are using to paliate CSS limitations. After the parser has gone through the document, the entity is converted to \n, which then effectively tosses out the window the behavior we are getting by keepinig the entity AS IS within the document.
by: Michael Goerz | last post by:
Hi, I am writing unicode stings into a special text file that requires to have non-ascii characters as as octal-escaped UTF-8 codes. For example, the letter "ƨ" (latin capital I with acute, code point 205) would come out as "\303\215". I will also have to read back from the file later on and convert the escaped characters back into a unicode string.
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.