Data record from Database, displaying as special characters in webpage

C

chike_oji

Hello,

I am displaying data retrieved from a database as a httpresponse in a
webform.
I noticed that some characters such as the comma (,), display as
special characters in the
web browser (Internet Explorer). It displays something like $^^%
instead of a comma.
Please how can I have the browser display the comma as it is from the
database.

Please find below a sample code of the code that packages the data
responseString into a
httpresponse object for display in the browser.

Thank you.

Regards,

Chike

//Make sure the response string length is not greater than 160.
if (responseString.Length > 160)
{
responseString = responseString.Substring(0,
160);
}

// Obtain a response object
HttpResponse httpresponse = Page.Response;
byte[] buffer = Encoding.UTF8.GetBytes(responseString);

// Get a response stream and write the response to it
// httpresponse.ContentLength64 = buffer.Length;
httpresponse.ContentType = "text/plain";
httpresponse.OutputStream.Write(buffer, 0,
buffer.Length);
httpresponse.Flush(); httpresponse.Close();
}
catch (Exception exception)
{
//Console.WriteLine(exception.Message);
//Console.WriteLine(exception.StackTrace);
 
J

Jon Skeet [C# MVP]

I am displaying data retrieved from a database as a httpresponse in a
webform. I noticed that some characters such as the comma (,), display as
special characters in the
web browser (Internet Explorer). It displays something like $^^%
instead of a comma.

Something like? It would help if you could be exact.

See http://pobox.com/~skeet/csharp/debuggingunicode.html for details
of how to track down this kind of thing.

Jon
 
C

chike_oji

Hi Jon,

The character that get misrepresented is the apostrophe (').For
example the word Obasanjo's is represented as ObasanjoâEURO(tm)s.

In some places, it gets represented well.

I don't understand why it is not uniform. Is it likely as a result of
data entry from different types of keyboards or as a result of
character encoding formats?

Any help will be appreciated.

Thank you very much.

Regards

Chike
 
J

Jon Skeet [C# MVP]

The character that get misrepresented is the apostrophe (').For
example the word Obasanjo's is represented as ObasanjoâEURO(tm)s.

In some places, it gets represented well.

I don't understand why it is not uniform. Is it likely as a result of
data entry from different types of keyboards or as a result of
character encoding formats?

(As replied to by email - please keep the discussion on the group.)

It's likely to be because in some cases it's a "curly quote" or "smart
quote" and sometimes it's a normal apostrophe. It really depends on the
data source. Might it have come from something like a Word document?
 
C

chike_oji

Hi Jon,

Thanks.
The data entry team use data from
various sources inlcuding internet webpages.

Thanks a lot.

Regards,
Chike.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top