Discussion:
Question on using "strcmp" to compare unicode strings
(too old to reply)
Lian
2004-09-15 08:41:41 UTC
Permalink
Hi all,
I am confused by the rule of comparing two unicode string using
function "strcmp".
For exmaple, using "strcmp" to compare two Chinese uincode string,
depending on what rule can "PHP" decide one string is greater or less
than the other string?

Thank you for suggestions!
Daniel Tryba
2004-09-15 09:15:12 UTC
Permalink
Post by Lian
I am confused by the rule of comparing two unicode string using
function "strcmp".
For exmaple, using "strcmp" to compare two Chinese uincode string,
depending on what rule can "PHP" decide one string is greater or less
than the other string?
My guess would be that it works the same as in ASCII, the position of
the character in the unicode characterset.
--
Daniel Tryba
Andy Hassall
2004-09-15 11:12:27 UTC
Permalink
Post by Lian
I am confused by the rule of comparing two unicode string using
function "strcmp".
For exmaple, using "strcmp" to compare two Chinese uincode string,
depending on what rule can "PHP" decide one string is greater or less
than the other string?
If you use strcmp, it'll just do a comparison of the (presumably UTF-8)
encoding, which will have nothing to do with the characters themselves.

See http://www.unicode.org/reports/tr10/ for details on sorting Unicode
strings, but I don't think PHP has an implementation of this.
--
Andy Hassall / <***@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Loading...