473,326 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Charset (hopefully for the last time I ask)

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
3 1346
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: lawrence | last post by:
How do I get PHP to tell the server that when I echo text to the screen, I need for the text to be sent as UTF-8? How does Apache know the right encoding when all the text is being generated by...
35
by: The Bicycling Guitarist | last post by:
My web site has not been spidered by Googlebot since April 2003. The site in question is at www.TheBicyclingGuitarist.net/ I received much help from this NG and the stylesheets NG when updating the...
15
by: Ben Sharvy | last post by:
I hae a page which validates, but produces a warning about a charset mismatch. The warning claims I specify a charset in the http header. I don't specify a charset in the http header. What gives?...
0
by: FAQPoster | last post by:
An HTML version of this document is available at: http://www.mvps.org/access/netiquette.htm Feeling left out? Alone? Wondering why everyone's ignoring you? Or why you're being flamed for what...
0
by: FAQPoster | last post by:
An HTML version of this document is available at: http://www.mvps.org/access/netiquette.htm Feeling left out? Alone? Wondering why everyone's ignoring you? Or why you're being flamed for what...
0
by: FAQPoster | last post by:
An HTML version of this document is available at: http://www.mvps.org/access/netiquette.htm Feeling left out? Alone? Wondering why everyone's ignoring you? Or why you're being flamed for what...
4
by: Rémi | last post by:
Question: How can you determine the character set used by a webpage you built? My understanding of the issue is that the character set used by an HTML file (or any other file, for that matter)...
11
by: Joshua Haberman | last post by:
I've spent the last two days delving into the state of charset support in C, and I wrote a blog post summarizing my findings. http://blog.reverberate.org/2007/04/21/transcoding-adventures-with-c/...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.