[Tutor] pymssql and encoding

Evert Rol evert.rol at gmail.com
Wed Oct 6 22:38:18 CEST 2010

> >>> print customerName
> ImmobiliŠre (whatever)
> >>> customerName
> 'Immobili\x8are (whatever)'
> There should be a small E with a grave accent (è) instead of the capital S with a caron (Š) I'm getting.
> I've tried applying various encodings, but to no avail:
<snip />

> When executed from MS SQL Server's Management Studio, the same query returns "Immobilière (whatever)", with an 'è', as it should.
> The field in question is of type nvarchar, with collation SQL_Latin1_General_CP850_CI_AS.

Well, you're SQL server seems to use CP850, which is (almost) the first encoding I tried:

>>> name= 'Immobili\x8are'
>>> name
>>> print name.decode('cp850')

Seems to work for me.


More information about the Tutor mailing list