By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,766 Members | 1,435 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,766 IT Pros & Developers. It's quick & easy.

Charset (hopefully for the last time I ask)

P: n/a
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
Jun 27 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Jun 12, 8:04 pm, Gandalf <goldn...@gmail.comwrote:
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.)
Jun 27 '08 #2

P: n/a
Yes, it is 1255 it's surprising you know that.

any way this is the code I tried

search=cnrl.GetValue()
search= search.decode("cp1255")
search=search.encode("utf8")
word=''
category=1
cur.execute('select * from hebrew_words where word like ?',
[''+search+''])

this is the error it send me :

'ascii' codec can't encode characters in position 0-1: ordinal not in
range(128)

have any idea?

Thank you for trying any way. it worms my Jewish art :)
Jun 27 '08 #3

P: n/a
OK it did worked!

I just should have been encoding to cp1255

search=cnrl.GetValue()
search= search.encode("cp1255")
cur.execute('select * from hebrew_words where word like ?',
['%'+search+'%'])
Thank you!

you are the best
Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.