Damián Herrera
Damián Herrera

Reputation: 89

IE: Unicode characters in HTML select and option tags

I need show options in a select with unicode characters. Try this:

<select id="ddlNota_CateId">
<option value="1091">&#26641;&#31435;&#20351;&#29992;ICT&#30340;</option>
</select>

And show unrecognized charcaters (树立使用ICT的). :s

Example in http://200.115.217.50/test.html

Upvotes: 4

Views: 7994

Answers (5)

chryss
chryss

Reputation: 7519

Two problems I see:

  • The font name should be "Arial Unicode MS", exactly like that, or the exact name of another suitable font.
  • Your web server (IIS) isn't serving this as UTF-8. I get the following:

    $ curl --head http://200.115.217.50/test.html
    HTTP/1.1 200 OK
    Content-Length: 874
    Content-Type: text/html
    Last-Modified: Wed, 11 Aug 2010 15:56:14 GMT
    Accept-Ranges: bytes
    ETag: "6ae315ba6d39cb1:1d22"
    Server: Microsoft-IIS/6.0
    X-Powered-By: ASP.NET
    Date: Wed, 11 Aug 2010 16:11:48 GMT

    It should be Content-Type: text/html; charset=UTF-8

ALSO, please next time post your code and URL clearly in the main question for everyone to see -- you are sending people on wild guessing games otherwise.

Upvotes: 0

SpliFF
SpliFF

Reputation: 39014

Remove the font setting in the style declaration. You're telling the browser to use a specific font that clearly doesn't support the characters you need.

Upvotes: 0

RoToRa
RoToRa

Reputation: 38431

For IE you'll need to explicitly set fonts in your CSS that have those characters. Unfortunately it's impossible to know which fonts your visitors have, so you'll need to add a list of popular ones. For example:

body {
   font-family: Arial Unicode MS, Lucida Sans Unicode, Code2000, sans-serif; //etc.
}

Upvotes: 3

meder omuraliev
meder omuraliev

Reputation: 186662

Make sure you have a Content-Type: text/html; charset=utf-8 header, and/or <meta charset="utf-8"> if you are directly entering the japanese/chinese/unicode characters in ( not html entities ).

This works: http://jsfiddle.net/nP87F/1/

HTML entities should work regardless, though. Are you sure it isn't just your text editor or OS that doesn't support that language set?

If you're on Windows these might be helpful:

Upvotes: 2

Josh Lee
Josh Lee

Reputation: 177715

A numeric character reference in HTML always uses characters from Unicode. For example, the first character #26641 refers to U+2611, which is a Chinese character 树.

The characters that you pasted into the question appear correctly as well. This is almost certainly a browser, font, or operating system problem. For example, if you see squares instead of characters, the browser does not have a proper font. Some browsers will automatically choose a font that has the characters you need, but you might need to explicitly set the font-family in others.

Try Help:Multilingual support (East Asian) on Wikipedia.

Upvotes: 3

Related Questions