MultiformeIngegno

  • Posts: 1,337
Strange behavior of jap chars on title="" tooltip
« on February 15th, 2013, 04:31 PM »
On my site I have a script that pulls the entries of an RSS feed and displays them (this is a portion):
Code: [Select]
            <li>
                <a href="<?php echo $item->get_permalink(); ?>" title="<?php echo esc_html$item->get_title() ); ?>" rel="external"><?php echo esc_html$item->get_title() ); ?></a>
            </li>

It works like a charm, the only oddity I noticed is when I deal with "special" chars. They're displayed just fine in the page, but the title="" tooltip replaces them with □□□□ (not encoded properly):



The problem is that the code that outputs text and title="" is the same. And the page is UTF-8. AND (last oddity :P) browsing the source code I can see the chars properly!


Any clue?
I'm writing this just for curiosity.. I don't care much about this "glitch"! :D

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Strange behavior of jap chars on title="" tooltip
« Reply #1, on February 15th, 2013, 04:33 PM »
No, it's not an encoding problem. It simply means that those characters are not available in the font Windows is using for tooltips. There's no way around it without rolling your own tooltips in HTML.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

MultiformeIngegno

  • Posts: 1,337
Re: Strange behavior of jap chars on title="" tooltip
« Reply #2, on February 15th, 2013, 04:36 PM »
Quote from Arantor on February 15th, 2013, 04:33 PM
No, it's not an encoding problem. It simply means that those characters are not available in the font Windows is using for tooltips. There's no way around it without rolling your own tooltips in HTML.
Uh, thanks! Seems sensed. so if I install (say) Japanese language on the system the chars should display fine? BTW, what's the default font on Windows (7/8)? Font on the page is Segoe UI.

EDIT: I edited my post and when I came back to the topic, the post was unread.. is this by design?
EDIT2: Uh, edited again but this time it was read.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Strange behavior of jap chars on title="" tooltip
« Reply #3, on February 15th, 2013, 04:48 PM »
It's nothing to do with the font for the page. You as a web developer have precisely zero control over what Windows does with tooltips.

Windows 7 makes it almost deliberately awkward to find it, too. What's curious is that Windows 7 itself uses Segoe UI by default. Earlier versions of Windows used different fonts (usually Tahoma if memory serves) which very firmly had troubles, but it would seem that something changed in Win Vista+.

Related thing I found: https://code.google.com/p/chromium/issues/detail?id=102449

Nao

  • Dadman with a boy
  • Posts: 16,082