handling unicode data

"Martin v. Löwis" martin at v.loewis.de
Wed Jun 28 12:34:04 EDT 2006


Fredrik Lundh wrote:
> looks like the DB-API driver returns 8-bit ISO-8859-1 strings instead of Unicode
> strings.  there might be some configuration option for this; see
> 

Where did you want to point the OP here?

> in worst case, you could do something like
> 
>     def unicodify(value):
>         if isinstance(value, str):
>             value = unicode(value, "iso-8859-1")
>         return value
> 
>     term = unicodify(row[1])
> 
> but it's definitely better if you can get the DB-API driver to do the right thing.

It seems pymssql does not support such a thing.

Also, it appears that DB-Library (the API used by pymssql) always
returns CP_ACP characters (unless ANSI-to-OEM conversion is enabled);
so the "right" encoding to use is "mbcs".

Notice that Microsoft plans to abandon DB-Library, so it might be
best to switch to a different module for SQL Server access.

Regards,
Martin



More information about the Python-list mailing list