views:

1252

answers:

7

I've got some Japanese in the ALT attribute, but the tooltip is showing me the ugly block characters in the tooltip. The rest of the content on the page renders correctly. So far, it seems to be limited to the tooltips.

+1  A: 

I'm not sure about the unicode issue but if you want the tooltip effect you should be using the title attribute, not alt.

Alt is for text you want screenreaders to speak, and it's what gets displayed if an image can't be loaded.

Dan
A: 

@Dan

It's not so much that I want the ALT to display a tooltip. It's that in IE7, it will appear. And since it does appear, I'd like it to be correct.

Larsenal
+3  A: 

This is because the font used in the tooltip doesn't include the characters you are trying to display. Try installing a font pack that includes those characters. I'm affraid you can't do much for your site's visitors other than implementating a tooltip yourself using javascript.

Coincoin
A: 

Can you sanitize the alt text so that it doesn't have the characters in it, preferably by replacing the entire text with something useful (rather than just filtering the string)? That's not ideal, but neither is displaying broken characters, or telling your users to install a new font pack.

Derek Park
+1  A: 

Where's your Japanese input coming from? It could be that it's in a non-unicode (e.g. http://en.wikipedia.org/wiki/JIS_X_0208) encoding, whereas your file is in unicode so the browser attempts to interpret the non-unicode characters as unicode and gets confused. I tried throwing together an example to reproduce your problem:

<img src="test.png" alt="日本語" />

The tooltip displays properly under IE7 with the Japanese language pack installed.

eplawless
A: 

Do note that the alt attribute isn't intended to be a tooltip. Alt is for describing the image where the image itself is not available. If you want to use tooltips, use the title attribute instead.

Andy
A: 

In IE and Firefox on Win2000/WinXP/Vista, with the Japanese Language support installed from Regional Options, this just works. On Win95/98/ME, it only worked on a Japanese OS, at least with IE, because of limitations in the Windows tooltip control in non-NT systems. (Regarding other answers which guide you to the title attribute: the same behavior applied with the title attribute).

However, it's possible that font linking/font mapping won't kick in if you haven't installed the language support, or if you've just copied some font to your fonts folder. It's also possible that your default font choice for tooltips doesn't support Japanese, though GDI font-linking fallback should kick in on Win2000 or above, unless the font lies about what it supports.

The "empty square" phenomenon is typically suggestive of a font mapping problem, though it's remotely possible that the encoding is wrong.

Are your users Japanese-speakers? Does this problem occur on a system with a Japanese default system locale?

JasonTrue