[Tutor] pymssql and encoding

Emmanuel Ruellan emmanuel.ruellan at laposte.net
Thu Oct 7 00:14:15 CEST 2010


Perfect! Thanks Evert.

I realise now that I don't fully grasp the concepts of encoding and
collation and their relationship.

-- 
Emmanuel


On Wed, Oct 6, 2010 at 10:38 PM, Evert Rol <evert.rol at gmail.com> wrote:

>
>
> > >>> 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
> 'Immobili\x8are'
> >>> print name.decode('cp850')
> Immobilière
> >>>
>
> Seems to work for me.
>
>  Evert
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101007/21f1bf04/attachment.html>


More information about the Tutor mailing list