Charset (hopefully for the last time I ask)

MRAB google at mrabarnett.plus.com
Fri Jun 13 03:20:09 CEST 2008


On Jun 12, 8:04 pm, Gandalf <goldn... at gmail.com> wrote:
> now I understand my problem better so their is a good chance you
> manage to help me.
>
> I have a SQlite database full with ANSI Hebrew text , and program that
> uses WXpython
> Now, I use a- 'wx.TextCtrl' item to receive input from the user, and
> when I try to search the database he don't understand this chars.
>
> it's quite reasonable consider the fact the program set to work on
> UTF-8 charset, except for:
>
> 1. it doesn't work when I delete the charset too
>
> 2. when I try to use function like decode and encode it output error
> like this:
> ascii' codec can't encode characters in position 0-4: ordinal not in
> range(128)
> ascii' codec can't encode characters in position 0-2: ordinal not in
> range(128)
>
> 3. I don't know how to translate my DB from ANSI to UTF-8
>
> 4. when I don't use the user WX items input I can change my editor
> charset to ansi and it works fine
>
> Thank you  all

Have you tried something like:

    unicode_text = text_from_db.decode("cp1255")
    print unicode_text
    utf8_text = unicode_text.encode("utf8")
    print utf8_text

(I believe the codepage 1255 is Hebrew.)



More information about the Python-list mailing list