[PythonCE] iso8859-2 or latin2

infopazo at hdsnet.hu infopazo at hdsnet.hu
Mon Feb 26 12:11:59 CET 2007


#!/usr/bin/python
# -*- coding: latin2 -*-
import os, sys
print sys.getdefaultencoding()
print sys.getfilesystemencoding()

The result is the folowing:

mbcs
ascii

I use hungarian characters in my program.
I write an application for polisters in PythonCE 2.5
I'd like use it with tkinter and sqlite.

The sqlite database encoding can be utf-8 or iso8859-2.
I tried both.

The test code is folowing:
# -*- coding:utf-8 -*-
latin2_decoder = lambda s: s.encode("iso8859-2", "replace") # str(s)
from sqlite3 import dbapi2 as sqlite
con=sqlite.connect("\\SD Card\\work\\python\\cdata.db",isolation_level=None)
con.text_factory=latin2_decoder
cur=con.cursor()

cur.execute("select ctyid,name from cities")
row=cur.fetchone()
while row:
  print row[0],row[1]
  row=cur.fetchone()
con.close()

Printing hungarian specific characters are failed or simply rectangles
displayed in place of characters.

sys.setdefaultencoding() procedure doesnt exists.
Can anybody help me, please?

best regards
Zoltan



More information about the PythonCE mailing list