Changeset 784:64b8c0a5c0bc


Ignore:
Timestamp:
06/16/16 17:42:51 (8 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
version_0.37_maint
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Made the handling of non-Unicode strings more robust

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/util.py

    r401 r784  
    170170
    171171_utf8decoder = codecs.getdecoder("utf-8")
     172_latin2decoder = codecs.getdecoder("iso8859-2")
    172173
    173174def utf2unicode(text):
    174175    """Convert the given text from UTF-8 encoding to unicode."""
    175     return unicode(_utf8decoder(text)[0])
     176    try:
     177        return unicode(_utf8decoder(text)[0])
     178    except:
     179        try:
     180            return unicode(_latin2decoder(text)[0])
     181        except:
     182            return unicode(list(text))
Note: See TracChangeset for help on using the changeset viewer.