简体   繁体   中英

Displaying Swedish charaters in aspx page

In an aspx page, Combo box is displaying swedish characters in wrong way. It is displaying like "Réunion" instead of"'Re'union" ? This value is retrieved from oracle database? Please suggest workarounds to fix this issue? Note: Culture and UICulture attributes are tried with. But not working"

You either use encoding for your html page different from the default UTF-8 or are reading wrong values from the database. You can check the encoding headers with Firebug or IE Dev Tools and also the document encoding. You can check if your column in the database is unicode or ASCII in which case you will need encoding. There are two simple test you can do

  1. Add some swedish text directly into a C# string and assign it to a label. See how it renders. If it is OK then your page encoding is OK.
  2. Put a breakpoint after you retrieve the value from the database and check with the debugger if it is displayed correctly in the debugger window.

If 1 does not display correctly but 2 does then you have encoding problem with the page. If you 1 is displayed correctly but 2 is not you have a problem when reading or writing values to the database.

First of all, determine if you receive the string correctly from the Oracle database (in debugger, view the received string). If the string is already received wrong, it means you have not properly set the database charset on your connection. You should fix that; a nasty workaround would be to “ungarble” the garbled string by something like Encoding.UTF8.GetString(Encoding.GetEncoding(1252).GetBytes(garbledString)) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM