[wp-hackers] Adding non English character ranges

Ryan McCue lists at rotorised.com
Wed Oct 3 12:59:10 UTC 2012


Tom Barrett wrote:
> It is for plugin functionality. I would like the user to be able to specify
> the alpha range, and be able to match against them. Ideally, this would
> mean not matching ø against o. Leave it as it's own unique character and
> coming after z in the alphabet.

Ah, in that case, specifying a range depends entirely on how you want to
handle it. Simply having a string isn't enough to be able to order, you
need language-specific context. For example, ö is treated as if it were
oe in German, while in Swedish, it's at the end of the alphabet.

Your best shot is to use the Unicode collation algorithm. You'll need
the intl PHP extension for that:

http://stackoverflow.com/questions/5056586/uca-natural-sorting

(If this seems more complicated than it should be, it's because it is.
Localisation/internationalisation is hard.)

-- 
Ryan McCue
<http://ryanmccue.info/>


More information about the wp-hackers mailing list