Re: Cannot display Chinese data from database

Tech-Archive recommends: Fix windows errors by optimizing your registry



Jason Chan wrote:

> Some chinese characters data (in Big5 encoding) is stored in database.
> I tried to display the data in an aspx but the characters cannot
> display correctly.
> I tried anything I think is related:
> - Setting the charset, codepage of the page

The Codepage directive in ASP.NET 2.0 is the same as reponseEncoding in
web.config.

> - changed the responseEncoding in web.config to Big5
> - hardcoded Response.ContentEncoding to 950 (codepage of Big5)

And these are identical as well (the latter, like Codepage, works at
the page level though).

> - Change the file encoding to Big5 (in save option)

That's only relevant at buildtime.

> None of them work.
>
> For the same data, it can displayed correctly in my classic asp.
>
> Code (.NET)
> private void Page_Load(object sender, System.EventArgs e)
> {
> SqlConnection connection = new
> SqlConnection(ConfigurationSettings.AppSettings["NewsDB"]);
> SqlCommand command = new SqlCommand();
> command.Connection = connection;
> command.CommandText = "SELECT Newsid, StoryDate, StoryTime,
> Headline FROM tblLatestHeader";
> command.CommandType = CommandType.Text;
>
> SqlDataReader dataReader;
> connection.Open();
> dataReader = command.ExecuteReader();
> string html = "";
> while (dataReader.Read())
> {
> html += dataReader[3].ToString();
> }
> connection.Close();
> Label1.Text = html;
> Label2.Text = "你好嗎"; // this is chinese character which
> can display correctly
> }

If your hardcoded sample text is displayed correctly, there's quite
likely a problem with your ADO.NET provider. Are the correct characters
displayed when you debug your code right after retrieving strings from
the database?

Cheers,
--
http://www.joergjooss.de
mailto:news-reply@xxxxxxxxxxxxx
.



Relevant Pages

  • Re: Is there a character limit on bound controls?
    ... doesn't mean they all went into the database. ... just fine - I've put more than 1,000 characters in without incident. ... However, on the page that needs to display the text, the text is ... The truncation happens regardless of whether there ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: get external data odbc limitation?
    ... Actually, it's limiting the number of characters that can be displayed, not ... Up to 64K of characters will appear in the list. ... You only get 64K characters to display the table names. ... My advice is to connect to the database server as a user who has limited ...
    (microsoft.public.access.externaldata)
  • IMPROVING PASSORD SECURITY ON COMPUTER SYSTEMS
    ... Instead using 'fixed characters' ... Alice will type '1332' as password on this transaction, ... a different path to build the password on checkerboard. ... it is better to display N different characters on checkerboard. ...
    (comp.security.misc)
  • IMPROVING PASSORD SECURITY ON COMPUTER SYSTEMS
    ... Instead using 'fixed characters' ... Alice will type '1332' as password on this transaction, ... a different path to build the password on checkerboard. ... it is better to display N different characters on checkerboard. ...
    (comp.security.unix)
  • Re: [OT] [XP] ISO 8859/1 Code Page for DOS window?
    ... *** I can't say because I don't use Windows anymore. ... If you were to implement certain codes, your keyboard ... would display different characters for certain key presses. ...
    (comp.os.msdos.misc)