473,800 Members | 2,722 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1369
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.de code("cp1255")
print unicode_text
utf8_text = unicode_text.en code("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.Get Value()
search= search.decode(" cp1255")
search=search.e ncode("utf8")
word=''
category=1
cur.execute('se lect * 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.Get Value()
search= search.encode(" cp1255")
cur.execute('se lect * 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
3748
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 PHP? If I build a content management system (I have) and I make sure that all input is encoded as UTF-8, how will the server know that the text in the MySql database is UTF-8? I'm taking all user input and using this function on the input: ...
35
4644
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 code before then. My host's tech guy just sent me the following. Isn't it okay to specify UTF-8 as the charset in the HTTP headers at the server level? Isn't it okay to have validated XHTML 1.0 strict code? ...
15
2980
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? Here's the w3c validator link: http://validator.w3.org/check?uri=http%3A%2F%2Fwww.efn.org%2F%7Ebsharvy%2Fnukes.html
0
1169
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 you deemed an innocent post? The following tips will not only help you, they will help us help you. Please note: The latest changes to this document are marked with a | at the left-most side of the line that has been changed.
0
1139
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 you deemed an innocent post? The following tips will not only help you, they will help us help you. Please note: The latest changes to this document are marked with a | at the left-most side of the line that has been changed.
0
1468
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 you deemed an innocent post? The following tips will not only help you, they will help us help you. Please note: The latest changes to this document are marked with a | at the left-most side of the line that has been changed.
4
2066
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) depends on your own system, and the encoding used by it; you cannot randomly insert a <META HTTP-EQUIV="Content-Type" content="text/html; charset=xxx-1234-567">
11
1305
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/ I'm new to this stuff, and I would very much appreciate gentle corrections about any mistakes or misconceptions I've made! I'd also appreciate hearing about the situation on Windows and more obscure UNIXes. For example, is iconv() available...
0
9691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10279
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10036
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6815
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2948
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.