Page 1 of 1

Access keys and multi languages

Posted: Mon Feb 19, 2007 1:32 am
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? :)

Posted: Mon Feb 19, 2007 1:50 am
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?

Posted: Mon Feb 19, 2007 3:20 am
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 :)

Posted: Mon Feb 19, 2007 11:56 am
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.