views:

82

answers:

5

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

+2  A: 

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:

meder
I try, but in IE not found.
Damián Herrera
Can you be way more specific?
meder
But, in 200.115.217.50/test.html show ok in HTML and not show ok in select / option
Damián Herrera
What OS? Windows? You are most def. missing a language pack.
meder
WinXP SP3 English. But, I try with Chrome or FF and show Ok. Is not a font problem of OS.
Damián Herrera
What font-family do you have it set to? Did you try specifying a different font?
meder
+3  A: 

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.

jleedev
I agree, probably a font problem. IE is less good at falling back to a font containing a character not present in the page's chosen font.
bobince
But, in http://200.115.217.50/test.html show ok in HTML and not show ok in select / option
Damián Herrera
+1  A: 

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.
}
RoToRa
I try this, is good, but not show ok.
Damián Herrera
You'll of course need one of those fonts installed. If you know a font on your system that supports those characters add that font to the start of the list.
RoToRa
Arial Unicode MS is installed in WinXp by default. I see in Control Panel / Fonts. But not show ok.
Damián Herrera
A: 

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.

SpliFF
I removed. But the problem is the same. With Chrome and FF the unicode characters show ok.
Damián Herrera
A: 

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.

chryss
The URL is in main question (Example in: ...) and chrome and FF show ok the select / option.
Damián Herrera