Changeset 2807

Show
Ignore:
Timestamp:
03/25/06 23:21:46 (18 years ago)
Author:
jerome
Message:

Backported unicode fix from pykoticon

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/tool.py

    r2804 r2807  
    242242            try : 
    243243                return unicode(text, "UTF-8").encode(self.charset)  
    244             except UnicodeError :     
     244            except (UnicodeError, TypeError) :     
    245245                try : 
    246246                    # Incorrect locale settings ? 
    247247                    return unicode(text, "UTF-8").encode("ISO-8859-15")  
    248                 except UnicodeError :     
    249                     pass 
     248                except (UnicodeError, TypeError) :     
     249                    try : 
     250                        return text.encode(self.charset)  
     251                    except (UnicodeError, TypeError, AttributeError) : 
     252                        pass 
    250253        return text 
    251254         
     
    255258            try : 
    256259                return unicode(text, self.charset).encode("UTF-8")  
    257             except UnicodeError :     
     260            except (UnicodeError, TypeError) :     
    258261                try : 
    259262                    # Incorrect locale settings ? 
    260263                    return unicode(text, "ISO-8859-15").encode("UTF-8")  
    261                 except UnicodeError :     
    262                     pass 
     264                except (UnicodeError, TypeError) :     
     265                    try : 
     266                        return text.encode("UTF-8")  
     267                    except (UnicodeError, TypeError, AttributeError) : 
     268                        pass 
    263269        return text 
    264270