waliwali / ibm-db

Automatically exported from code.google.com/p/ibm-db
0 stars 0 forks source link

Charset Troubles #89

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Connect through ds driver to a DB2 instance which is encoded with ISO-8859-15
2. Bind with sqlachemy to any of the tables on this DB which has a text column
3. Retrieve one row of this table and fetch the text field you want, make sure 
it contains a special character such as ç
4. Print it to console or format it into a string

What is the expected output? What do you see instead?
The console output is correct, whereas the text field cannot be used in a 
formated string, it fails because python tries to convert to ascii.

What version of the product are you using? On what operating system?
last ibm_db, remote 9.7 db2 on Linux, client on a linux machine using odbc cli 
provided in dsdriver.

Please provide any additional information below.
How can I Handle those special characters ?

Regards.

Original issue reported on code.google.com by julien.c...@gmail.com on 4 Nov 2011 at 4:52

GoogleCodeExporter commented 9 years ago
For instance the self.c_dessoen field contains special chars

ibm_db_sa.base.IBM_DBDialect
[Comptoir Français de l'Image           <<<<<<<<<<< This is what is should 
always be
Traceback (most recent call last):
  File "ibm_db_sa_check.py", line 36, in <module>
    print s.query(Enseigne).all()
  File "ibm_db_sa_check.py", line 28, in __repr__
    return 'u{0} u{1}'.format(self.c_refsoen,self.c_dessoen)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe7' in position 
13: ordinal not in range(128)

Original comment by julien.c...@gmail.com on 4 Nov 2011 at 5:01

GoogleCodeExporter commented 9 years ago
Solved myself. 
I was using __repr__(): which will always perform the ascii conversion.
switch to __unicode__() which is I need.
Sorry for opening a dummy issue.

Original comment by julien.c...@gmail.com on 4 Nov 2011 at 5:38

GoogleCodeExporter commented 9 years ago

Original comment by rahul.pr...@in.ibm.com on 14 Nov 2011 at 7:42