Access keys and multi languages

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Access keys and multi languages

Post by alex.barylski »

This is sort of a two part question:

Browsers that support access keys do so via the accesskey attribute which takes a single character - how and does this even work when using languages which require 2byte character encoding?

If I was given a string which was in say chinese, and I translated English text into chinese, it might look somehting like:

Code: Select all

$caption = "&7464;&5235;&847;&6334;"; // And so on??
I know this is likely way off, but I'm trying to understand how I might translate a text from english to another language. Anyways, assuming I had a string like above stored in variable $caption if I wanted to underline the second character (to indicate the access key) I don't suppose I could even use substr but I would have to pass that string to the PHP multi byte string functions correct? Or set the locale to whatever the language is in, which would tell PHP to handle the string differently.

Using default string functions the above string is actually 22 bytes, but does it get interpreted as 4 * 2 = 8 bytes or four visible characters on screen???

Did I make any sense? Ca someone (AC?) clear this up for me? :)
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Code: Select all

$caption = "&7464;&5235;&847;&6334;"; // And so on??
That isn't multibyte string data. Those are HTML entities; a poor man's alternative.
Or set the locale to whatever the language is in, which would tell PHP to handle the string differently.
If you are using UTF-8 you can download PHPUTF8 explained here.

As for how accesskey handles it - who knows? It's not in the spec so that makes whatever behaviour browsers have implemented undefined. Great, isn't it?
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

ole wrote:

Code: Select all

$caption = "&7464;&5235;&847;&6334;"; // And so on??
That isn't multibyte string data. Those are HTML entities; a poor man's alternative.
Or set the locale to whatever the language is in, which would tell PHP to handle the string differently.
If you are using UTF-8 you can download PHPUTF8 explained here.

As for how accesskey handles it - who knows? It's not in the spec so that makes whatever behaviour browsers have implemented undefined. Great, isn't it?
Hey ole, what do you mean poor mans way???

That was a stab in the dark as to how it might look - but would it work? From an english QWERTY keyboard...what other ways are there?

I'll look into that article, thanks :)
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Do a search on php and utf-8 in the sitepoint blogs you should find good resources there. Better than I could explain.
Post Reply