MSDOTnet.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Data record from Database, displaying as special characters

 
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> C Sharp
Author Message
chike_oji



Joined: 13 Dec 2007
Posts: 10

PostPosted: Wed Jan 23, 2008 1:45 pm    Post subject: Data record from Database, displaying as special characters Reply with quote

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);

Archived from group: microsoft>public>dotnet>languages>csharp
Back to top
View user's profile Send private message
Jon Skeet [C# MVP]



Joined: 08 Aug 2007
Posts: 27

PostPosted: Wed Jan 23, 2008 1:51 pm    Post subject: Re: Data record from Database, displaying as special charact Reply with quote

On Jan 23, 4:45 pm, chike_...@yahoo.com wrote:
> 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
Back to top
View user's profile Send private message
chike_oji



Joined: 13 Dec 2007
Posts: 10

PostPosted: Wed Jan 23, 2008 3:46 pm    Post subject: Re: Data record from Database, displaying as special charact Reply with quote

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

On Jan 23, 5:51 pm, "Jon Skeet [C# MVP]" wrote:
> On Jan 23, 4:45 pm, chike_...@yahoo.com wrote:
>
> > 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.
>
> Seehttp://pobox.com/~skeet/csharp/debuggingunicode.htmlfor details
> of how to track down this kind of thing.
>
> Jon
Back to top
View user's profile Send private message
Jon Skeet [C# MVP]



Joined: 08 Aug 2007
Posts: 266

PostPosted: Thu Jan 24, 2008 12:10 am    Post subject: Re: Data record from Database, displaying as special charact Reply with quote

wrote:
> 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?

--
Jon Skeet -
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Back to top
View user's profile Send private message
chike_oji



Joined: 13 Dec 2007
Posts: 10

PostPosted: Thu Jan 24, 2008 9:41 am    Post subject: Re: Data record from Database, displaying as special charact Reply with quote

Hi Jon,

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

Thanks a lot.

Regards,
Chike.

On Jan 23, 8:10 pm, Jon Skeet [C# MVP] wrote:
>   wrote:
> > 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?
>
> --
> Jon Skeet - http://www.pobox.com/~skeet  Blog:http://www.msmvps.com/jon.skeet
> World class .NET training in the UK:http://iterativetraining.co.uk

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Cannot enter special characters in DataGridView via Alt+0XXX Hi! I have a problem with the .NET DataGridView control. It's demonstrated by building a trivial test project in Visual Studio 2005, using these steps: 1. Ctrl+Shift+N to create a new project. 2. Select a WinForms project, accepting all of the defaults. 3

Displaying data from parent What is the best method to display columns in a parent table and not using comboboxes? Example: You have an Order entry form and want to display additional columns from the customer table, let say customer name and adress. If you use a combobox and bind t

displaying XML data in datagrid column i want to display actual XML data (with tags & data) from a table's colum (XML data) in a datagrid's column... by default it shows only yhe content of the XML but not the tags...anyone have an answer for this... i don't want to bind the data to a text bo

displaying XML data in datagrid column i want to display actual XML data (with tags & data) from a table's colum (XML data) in a datagrid's column... by default it shows only yhe content of the XML but not the tags...anyone have an answer for this... i don't want to bind the data to a text bo

Let us think i have datagrid which displays record from data Hai, Q:- Let us think i have datagrid which displays record from database, now if any new record is inserted in database how can the user knows the a new record is inserted in database so he can refresh the page? what is apporach we need to follow to do
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> C Sharp All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group