Hi,

Am 30.10.2013 19:48, schrieb Skip Montanaro:
Perhaps this? 
http://stackoverflow.com/questions/816285/where-is-pythons-best-ascii-for-this-unicode-database

There I found the module unidecode
(http://pypi.python.org/pypi/Unidecode),
and I found it very helpful. Thanks a lot!

So my function normal() now looks like this:

from unidecode import unidecode

def normal (s):
  r = s
  r = r.strip()              # take away blanks at the ends
  r = r.replace(u' ', '')    # take away all other blanks
  r = unidecode(r)           # makes the main work
                             # - see the docu of unidecode
  r = r.upper()              # changes all to uppercase letters
  return r

def compare (a, b):
  aa = normal(a)
  bb = normal(b)
  if aa < bb:
    return -1
  elif aa == bb:
    return 0
  else:
    return 1

For the "normal" cases, that works quiet perfect - as I want it to do. For more (extreme) difficult cases there are even limits, but they are even wide limits, I would say. For example,
  print normal(u'-£-¥-Ć-û-á-€-Đ-ø-ț-ff-ỗ-Ể-ễ-ḯ-ę-ä-ö-ü-ß-')
gives
  -PS-Y=-C-U-A-EU-D-O-T-FF-O-E-E-I-E-A-O-U-SS-
That shows a bit of what unidecode does - and what it doesn't.

There is also a rather long-ish recent topic on a similar topic that
might be worth scanning as well.

Sorry, I didn't find that.

I've no direct/recent experience with this topic. I'm just an
interested bystander.

But even a helpful bystander. Thank You!

Ulrich

--
Ulrich Goebel
Paracelsusstr. 120, 53177 Bonn
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to