Hi,
I realised (finally !) that I am connecting to a mssql backend with
collation 1252.
So I have updated my configuration file to the following:
<globalization requestEncoding="windows-1252"
responseEncoding="windows-1252"
fileEncoding="windows-1252"
culture="zh-CN"/>
Also on page load I set programatically the following:
Response.Charset = "gb2312";
This will allow datagrid, textboxes to correctly display chinese
symbol characters on the browser. On the html source file, the text
written to the file is as codepage 1252 characters, which I then
assume if rendered correctly by the browser as I have set the charset
above.
These values are retrieved from the database correctly, and on
page-load, post-backs and saving to the database all is fine.
However, when displaying converted date strings to the browser i am
getting some strange results. When I convert a date (using the
cultures DateTimeFormat patterns) to be displayed with month
abbreviation to the browser for
example with english culture these may be the result 'Jan 2004'.
When the page is displayed with the zh-CH (simplied chinese) culture
it displays '?? 2004', that is the chinese symbols for the abbreviated
month
are not rendered on the browser correctly. In the html source file,
the text written on the file is also showing '??'.
However, when I remove the previous command
Response.Charset = "gb2312";
and replace it with
Session.CodePage = 936;
the displaying of the formatted date string is correct with the month
abbreviation showing the corresponding chinese character symbols.
The html source file, the text written to the file is as codepage 1252
characters, which I then assume if rendered correctly by the browser
as I
have set the codepage above. However, this now makes the previous
datagrids and textboxes not show the corresponding chinese character
symbols.
I when I set both the
Response.Charset = "gb2312";
Session.CodePage = 936;
this does not give the desired results. Why can't I set both of these
values together at the same time to make it work?
I had a look at the data being returned from the mssql backend and its
fine.
I performed the steps detailed in
http://www.pobox.com/~skeet/csharp/d...ngunicode.html and I used
the returned hex values below. As the data is stored as windows-1252,
I then used the double-byte code page conversions
(
http://www.microsoft.com/globaldev/reference/WinCP.mspx) to see if
the displayed chinese symbols on the browser correspond to the
database values and they match.
I am a little confused as to what is happening, perhaps someone has
some ideas.
Thanks.
pa***********@gmail.com (pabv) wrote in message news:<da*************************@posting.google.c om>...
I think I have made some progress in finding the error to this
problem.
I realised that the error seemed to be happening with the asp.net
textbox control. I than investigated further and realised the error
where the chinese character symbols are not being displayed correctly
on the browser occurs with multiline textbox.
Multiline textbox (texbox with TextMode = TextBoxMode.MultiLine) are
rendered on the browser by asp.net as a textarea. This results in
unicode characters (ie. characters not translated by the codepage
encoding process) being displayed on both page-load and any subsequent
page-postbacks before final page submission to have data saved to the
mssql backend.
So I populated a singleline textbox, and on the browser and it
displayed the chinese character symbols correctly. This results in
both page-load and page-postbacks displaying the chinese character
symbols correctly.
Hence, it seems to occur when I populate a multiline textbox that it
is rendered as a textarea in html.
I went a step further and this time I created a html server textarea
control (HtmlTextArea). I populated the control, and on page-load the
chinese character symbols are displayed correctly on the browser.
However, when I change the text inside the htmltextarea control, on
page-postback the chinese characters symbols are no longer displayed
correctly.
So one question I have is what encodings/processes are occurring on
page-postbacks that is causing the htmltextarea control to have this
issue? And most importantly why is the multiline textbox not
displaying chinese character symbols correctly when the htmltextarea
control partially is?
I will investigate further. Perhaps you or others may have some ideas
as to whether this has any importance to the issue.
I will also take your suggestion and follow the steps in your
debugging unicode page.
Thanks again.