Question on using "strcmp" to compare unicode strings

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lian

    Question on using "strcmp" to compare unicode strings

    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

    #2
    Re: Question on using "strcmp&qu ot; to compare unicode strings

    Lian <Lian@hehe.ne t> wrote:[color=blue]
    > 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?[/color]

    My guess would be that it works the same as in ASCII, the position of
    the character in the unicode characterset.

    --

    Daniel Tryba

    Comment

    • Andy Hassall

      #3
      Re: Question on using &quot;strcmp&qu ot; to compare unicode strings

      On Wed, 15 Sep 2004 16:41:41 +0800, Lian <Lian@hehe.ne t> wrote:
      [color=blue]
      > 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?[/color]

      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 / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
      <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

      Comment

      Working...