Results 1 to 3 of 3
  1. #1
    couling is offline Member
    Join Date
    Nov 2010
    Posts
    54
    Rep Power
    0

    Default String comparison based on system locale

    Hi All

    I'm looking for a way to order an array of strings based on the system locale. As I'm writing this I'm wondering if the concept of system locale is cross platform enough for java to support it...

    Anyway what I mean is this:
    On linux there is an environment variable called LC_COLLATE which can be used by all programs to deside how to order strings "alphabetically". This is due to the large number of regional variations on how to handle Upper and Lower case / wite space / accents / punctuation etc. There are ascociated libraries for doing this so that programs do not need to be aware of every locale in advance.

    Am I going to have to write my own JNI Comparator for this or (long shot) is there a built in comparator which will order based on the system locale?

    Thanks for your time.
    Last edited by couling; 02-14-2011 at 05:09 PM.
    ----Signature ----
    Please use [CODE] tags and indent correctly. It really helps when reading your code.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,798
    Rep Power
    19

    Default

    java.text.Collator.
    Works based on the Locale.

  3. #3
    couling is offline Member
    Join Date
    Nov 2010
    Posts
    54
    Rep Power
    0

    Default

    yer that's pretty close.

    It doesn't appear to be using the O/S libraries to perform the task meaning it's not 100% compatable with my setup but I guess thats so they can ensure common behaviour between JVMs.

    Unfortunetly it's completely hammered the performance of my app anyway so I'm going to attack this from a different angle that doesnt require locale.

    Thanks for your help.
    ----Signature ----
    Please use [CODE] tags and indent correctly. It really helps when reading your code.

Similar Threads

  1. String object comparison issue
    By subith86 in forum New To Java
    Replies: 3
    Last Post: 01-19-2011, 06:18 AM
  2. String to String Comparison being ignored
    By leonsbuddydave in forum New To Java
    Replies: 4
    Last Post: 01-07-2011, 12:25 AM
  3. String Comparison
    By evant8950 in forum Java Applets
    Replies: 6
    Last Post: 04-22-2009, 08:11 AM
  4. String comparison
    By abhiN in forum New To Java
    Replies: 2
    Last Post: 04-09-2008, 04:47 AM
  5. String comparison
    By sireesha in forum New To Java
    Replies: 1
    Last Post: 12-18-2007, 12:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •