collate

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

    #1

    collate

    I'm trying to compare strings written in Swedish using:

    std::locale loc(""); // System locale is Swedish
    loc(first, second);

    But this does not give me the right return value.
    for example,

    loc(string("å") , string("ä"));

    should yield true, since 'å' is less than 'ä' in Swedish, but it doesn't.

    Is this a bug?

    --
    Dag Henriksson


  • Bo Persson

    #2
    Re: collate


    "Dag Henriksson" <dag.henriksson @quidsoft.se> skrev i meddelandet
    news:%239vshxuV DHA.2100@TK2MSF TNGP11.phx.gbl. ..[color=blue][color=green][color=darkred]
    > > > I'm trying to compare strings written in Swedish using:
    > > >
    > > > std::locale loc(""); // System locale is Swedish
    > > > loc(first, second);
    > > >
    > > > But this does not give me the right return value.
    > > > for example,
    > > >
    > > > loc(string("å") , string("ä"));
    > > >
    > > > should yield true, since 'å' is less than 'ä' in Swedish, but it[/color]
    > > doesn't.[color=darkred]
    > > >
    > > > Is this a bug?[/color]
    > >
    > > Well, not really, it just doesn't work.
    > >
    > > The C++ standard doesn't say much what happens for letters outside[/color][/color]
    of[color=blue][color=green]
    > > a-z. In Windows their positions even varies between different
    > > character sets (try looking at them with the program
    > > "Teckenuppsättn ing"). Most often 'ä' comes before 'å' (in an area
    > > filled with varying sets of other accented glyphs that are not
    > > "proper" letters).[/color]
    >
    > Yes, I know that the C++ standard does not put any requirements on[/color]
    any[color=blue]
    > other facets than "C", but if an implementation can create a locale
    > named for example "Sweden_Swedish ", shouldn't the collate facet in[/color]
    that[color=blue]
    > locale then follow the rules of Swedish, or are you saying that this[/color]
    is[color=blue]
    > impossible in Windows because the AscII of a letter depends of the
    > character set? Most lists I've seen of supported locales say what
    > charmap is used for each locale, for example ISO-8859-1 for Swedish,[/color]
    so[color=blue]
    > this should not be a problem.[/color]

    Ok, I change my statement to "it might work". I see that in the latest
    library collate<char> indirectly calls the undocumented function
    _Strcoll. Don't know what that means though.

    If you say that it still doesn't work, I'm not the least surprised.


    Bo Persson
    bop2@telia.com

    [color=blue]
    >
    > All book I have read suggests that it should be possible to compare
    > strings according to local rules using collate. See for example
    > http://www.research.att.com/~bs/3rd_loc.pdf
    > where Stroustrup writes:
    > "given the dk locale, we can construct a locale that reads and[/color]
    compares[color=blue]
    > strings according to the rules of Danish (that give three extra[/color]
    vowels[color=blue]
    > compared to English)"
    >
    > But maybe I've misunderstood something...
    >
    > --
    > Dag Henriksson
    >
    >[/color]

    Comment

    Working...