Jesse Sherlock
Jesse Sherlock

Reputation: 3110

Locale aware collation in jruby

I've tracked down a bug in the rubyrep replication library that results from Ruby's collation not being locale aware. It thinks that '-' comes before 'a' when sorting, which is not correct, at least for the en_US.UTF-8 locale (and the C locale).

Right now the database is sorting these strings in a proper locale aware way but ruby is not.

What's the easiest way for a jruby novice to get locale aware string comparisons working so I can patch this code? I'm fine with hardcoding the locale I want into the code if that's necessary.

(If there is no easy way I will abandon jruby and use this lib but I'm hoping there is a jruby way so I can keep the speed advantage)

Upvotes: 0

Views: 118

Answers (1)

banzaiman
banzaiman

Reputation: 2663

Pardon my asking, but how did you figure that - should sort after a in UTF-8? In this ASCII-compatible block, at least, I expect - to come before a.

JRuby strives to be compatible with how MRI behaves, so no matter how MRI is behaving, this is how JRuby will behave.

Also, JRuby has FFI built in, so you are free to use the library you mention.

Upvotes: 1

Related Questions