Menu

charset

Help
jkulesza
2005-04-20
2012-09-19
  • jkulesza

    jkulesza - 2005-04-20

    i have problem with inserting to mysql:
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 10: ordinal not in range(128)

    tables are in utf8, data in iso-8859-2, after connection i run "set character set latin2"

    mysql 41, mysqldb1.2, active state python 2.4.1

     
    • Andy Dustman

      Andy Dustman - 2005-04-20

      Changing the connection character set after you open the connection probably won't work the way you expect. MySQLdb checks the character set after establishing the connection, and sets some of the converters to use it. The best way to manage this in 1.2 is to set it in a configuration file and read it with the read_default_file option to connect (and maybe also use read_default_group). You need an option like this:

      [client]
      default-character-set = latin2

      If you use something other than client, you need read_default_group as well.

      If you ever use anything out of the latin2 range, maybe you should use utf8 instead for the default.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.