sorting slovak utf
Stano Paska
paska at kios.sk
Wed Dec 10 02:39:12 EST 2003
Serge Orlov wrote:
> "Stano Paska" <paska at kios.sk> wrote in message news:mailman.256.1070955895.16879.python-list at python.org...
>
>>I had an imagination, that there is some easy way
>>to work with slovak, russian, english and german text in one application.
>
> Depends on what you mean "work". Upcase? Split words? Sort? Spell check?
> Translate? Display?
>
Get from database or text file, show in wxTextCtrl, upper, lower, maybe
sort, store into database or text file.
>
>>I only change locale from sk_SK.utf-8 to ru_RU.utf-8, ... and system works.
>>Input and output are in utf-8.
>>
>>Is this a fantasy?
>
> If you mean sorting, yes. Python does not have handy functions to do that.
> The good news is that the solution is only 10-15 lines away from you. You've
> been given all information in this thread. Let me summarize it:
> 1. Convert your input to unicode.
> 2. Use locale named 'Slovak' (see my previous post why)
On windows, 'slovak' works. I discover that 'sl' works too, but 'sk'
does not (M$'s way of standardization?).
> 3. Use DSU trick to sort the words, here's the (untested) D part of it:
> def decorate(seq, locale_encoding):
> return [(locale.strxfrm(s.encode(locale_encoding,'replace'),s) \
> for s in seq]
Ok, I will try this.
>
> It's not as scary as strxfrm name implies.
> -- Serge.
>
>
>
>
Thanks for your time to explain me this.
Stano.
More information about the Python-list
mailing list