Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: locales, encodings, collations, charsets... how can I match a given MySQL collation?

by rhesa (Vicar)
on Apr 02, 2007 at 03:13 UTC ( [id://607749]=note: print w/replies, xml ) Need Help??


in reply to locales, encodings, collations, charsets... how can I match a given MySQL collation?

Have a look at Unicode::Collate.
#!/usr/bin/perl use Unicode::Collate; my $coll = Unicode::Collate->new; my $e = "\xe9clair"; my @cmp = qw/ aardvark each eden zarkon /; for my $d ( @cmp ) { printf "%10s ccmp %5s = %d\n", $d, $e, $coll->cmp( $d, $e ); } __END__ aardvark ccmp éclair = -1 each ccmp éclair = -1 eden ccmp éclair = 1 zarkon ccmp éclair = 1
Update:: Another approach would be to use Text::Unidecode, and strip off any accents before doing the comparison.
  • Comment on Re: locales, encodings, collations, charsets... how can I match a given MySQL collation?
  • Download Code

Replies are listed 'Best First'.
Re^2: locales, encodings, collations, charsets... how can I match a given MySQL collation?
by xaprb (Scribe) on Apr 02, 2007 at 14:18 UTC

    I'm still nervous about this approach matching exactly MySQL. I need to match it exactly, even if MySQL's sorting is wrong, or the algorithm will run off the rails. I think varian's idea will probably work well. Thank you for the suggestions though!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://607749]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-19 21:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found