Jon, thanks for you replies. I looked at your links... there is a lot of
info there, I will continue to study this, but it hasn't really revealed any
solutions said:
Okay, so if the problem is getting the data in the first place, read
this:
The problem isn't getting the data... I'm getting data from sql server in
some encoded format, but I don't know what it is... it starts with an
ampersand '&', then there is a '#' pound sign, then a 5 digit integer, then a
semi colon. I notice it gets translated when I post it exactly, so I'm
trying to descibe it here. If I put some spaces between it, a single
character looks like this (remove spaces):
& # 35843 ;
First of all, is this unicode?
Secondly, this is what I know about the problem:
1. I get the data in the above format from SQL server.
2. On an ASP.NET 2.0 webpage, if I move this data into a the innerHtml
property of a div tag for example, I see Chinese characters as expected, for
example:
articleArea.InnerHtml = article.NativeHeadline; //this works great!!!
3. If I move the same data into an asp:textbox, or an html input textbox, I
get the data exactly as it looks in SQL server with the ampersand, pound,
number, semicolon format. But I need this to show the Chinese characters.
4. Interstingly, if I cut and paste from the DIV in step 2, to the textbox,
the textbox shows the Chinese characters just fine... but this does not solve
the problem of course, just an interesting note.
5. I did try changing the font to MS Arial Unicode also didn't work
6. Another interesting note, a gridview column will display the data just
fine too!
7. Is there some conversion I can do in c# server side to get it to work?
I know for example, that if the data is in this format:
char[] chinese = {'\u6B22','\u8FCE','\u4F7F','\u7528','\u0020'};
and I move this to the textbox, the data also shows as expected. But how to
get the ampersand, pound, number, semicolon translated to the above?
Any other ideas for me are appreciated, I just need to know how to get the
textbox control to show Chinese and not weird codes.
Thanks
Jon Skeet said:
tparks69 said:
I have the font specified as: style="font-family:Arial Unicode MS" but that
doesn't help. Also I found some code that works but the source data is in a
slightly different format than how I am getting it from SQL server:
So this works:
char[] chinese = {'\u6B22','\u8FCE','\u4F7F','\u7528','\u0020'};
txtHeadline.Text = new string(chinese);
text shows up as chinese characters in the textbox... but my data from SQL
server is in a different format... like this...
? ? etc... what is this format, how can I convert it to '\u6B22'
etc...???
Okay, so if the problem is getting the data in the first place, read
this:
http://pobox.com/~skeet/csharp/debuggingunicode.html
--
Jon Skeet - <
[email protected]>
Web site:
http://www.pobox.com/~skeet
Blog:
http://www.msmvps.com/jon.skeet
C# in Depth:
http://csharpindepth.com