Re: Help on exceptions (was: Convertion of Unicode to ASCII NIGHTMARE)

2006-04-10 Thread Roger Binns
"Serge Orlov" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > It can be like this. Notice special url, it is pointing to a > non-existing :) tutorial about why concatenating byte strings with > unicode strings can produce UnicodeDecodeError An alternate is to give an error code that

Help on exceptions (was: Convertion of Unicode to ASCII NIGHTMARE)

2006-04-10 Thread Serge Orlov
ChaosKCW wrote: > Ok I get it now. Sorry for the slowness. I have to say as a lover of > python for its simplicity and clarity, the charatcer set thing has been > harder than I would have liked to figure out. I think there is a room for improvement here. In my opinion the message is too confusing

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-10 Thread ChaosKCW
> > When python tries to concatenate a byte string and a unicode string, it > assumes that the byte string is encoded ascii and tries to convert from > encoded ascii to unicode. It calls ascii decoder to do the decoding. If > decoding fails you see message from ascii decoder about the error. > >

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-10 Thread Paul Boddie
ChaosKCW wrote: > > > > There's an Oracle environment variable that appears to make a > > difference: NLS_CHARSET, perhaps - it's been a while since I've had to > > deal with Oracle, and I'm not looking for another adventure into > > Oracle's hideous documentation to find out. > > That is an EVIL s

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-10 Thread Serge Orlov
ChaosKCW wrote: > Roger Binns wrote: > > > > > No. APSW converts it *to* Unicode. SQLite only accepts Unicode > > so a Unicode string has to be supplied. If you supply a non-Unicode > > string then conversion has to happen. APSW asks Python to > > supply the string in Unicode. If Python can't

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-10 Thread ChaosKCW
> > There's an Oracle environment variable that appears to make a > difference: NLS_CHARSET, perhaps - it's been a while since I've had to > deal with Oracle, and I'm not looking for another adventure into > Oracle's hideous documentation to find out. > That is an EVIL setting which should not be

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-10 Thread ChaosKCW
Roger Binns wrote: > > No. APSW converts it *to* Unicode. SQLite only accepts Unicode > so a Unicode string has to be supplied. If you supply a non-Unicode > string then conversion has to happen. APSW asks Python to > supply the string in Unicode. If Python can't do that (eg > it doesn't kno

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-06 Thread Serge Orlov
Roger Binns wrote: > "Serge Orlov" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > I have an impression that handling/production of byte order marks is > > pretty clear: they are produced/consumed only by two codecs: utf-16 and > > utf-8-sig. What is not clear? > > Are you talking

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-05 Thread Roger Binns
"Serge Orlov" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have an impression that handling/production of byte order marks is > pretty clear: they are produced/consumed only by two codecs: utf-16 and > utf-8-sig. What is not clear? Are you talking about the C APIs in Python/SQL

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-05 Thread Serge Orlov
Roger Binns wrote: > "Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Roger Binns wrote: > > > >> SQLite only accepts Unicode so a Unicode string has to be supplied. > > > > fact or FUD? let's see: > > Note I said SQLite. For APIs that take/give strings, you can eit

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-05 Thread Roger Binns
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > sounds like your understanding of Unicode and Python's Unicode system > is a bit unclear. Err, no. Relaying unicode data between two disparate C APIs requires being careful and thorough. That means paying attention to

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-05 Thread Fredrik Lundh
Roger Binns wrote: > > fact or FUD? let's see: > > Note I said SQLite. For APIs that take/give strings, you can either > supply/get a UTF-8 encoded sequence of bytes, or two bytes per character > host byte order sequence. Any wrapper of SQLite that doesn't do > Unicode in/out is seriously break

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-05 Thread Roger Binns
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Roger Binns wrote: > >> SQLite only accepts Unicode so a Unicode string has to be supplied. > > fact or FUD? let's see: Note I said SQLite. For APIs that take/give strings, you can either supply/get a UTF-8 encoded se

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-04 Thread Fredrik Lundh
Roger Binns wrote: > SQLite only accepts Unicode so a Unicode string has to be supplied. fact or FUD? let's see: import pysqlite2.dbapi2 as DB db = DB.connect("test.db") cur = db.cursor() cur.execute("create table if not exists test (col text)") cur.execute("insert into t

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-04 Thread Roger Binns
"ChaosKCW" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > me. As for SQLite supporting unicode, it probably does, No, SQLite *ONLY* supports Unicode. It will *only* accept strings in Unicode and only produces strings in Unicode. All the functionality built into SQLite such as comp

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-04 Thread Paul Boddie
Robert Kern wrote: > Roger Binns wrote: > > "Paul Boddie" <[EMAIL PROTECTED]> wrote > >>It looks like you may have Unicode objects that you're presenting to > >>sqlite. In any case, with earlier versions of pysqlite that I've used, > >>you need to connect with a special unicode_results parameter,

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-04 Thread Robert Kern
Roger Binns wrote: > "Paul Boddie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > >>It looks like you may have Unicode objects that you're presenting to >>sqlite. In any case, with earlier versions of pysqlite that I've used, >>you need to connect with a special unicode_results para

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-04 Thread John Machin
"Thus you lose data, but thats just dandy with me.": Please reconsider this attitude, before you perpetrate a nonsense or even a disaster. Wrt your last para: 1. Roger didn't say "ignore" -- he said "won't accept" (a major difference). 2. The ASCII code comprises 128 characters, *NOT* 256. 3. What

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-04 Thread ChaosKCW
Hi Thanks for all the posts. I am still digesting it all but here are my initial comments. >Don't. You can't. Those characters don't exist in the ASCII character set. >SQLite 3.0 deals with UTF-8 encoded SQL statements, though. >http://www.sqlite.org/version3.html As mentioned by the next poster

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-03 Thread Roger Binns
"Paul Boddie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > It looks like you may have Unicode objects that you're presenting to > sqlite. In any case, with earlier versions of pysqlite that I've used, > you need to connect with a special unicode_results parameter, He is using apsw

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-03 Thread Paul Boddie
Oh, and it occurs to me, as I seem to have mentioned a document about PgSQL rather than pysqlite (although they both have the same principal developer), that you might need to investigate the client_encoding parameter when setting up your connection. The following message gives some information (bu

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-03 Thread Diez B. Roggisch
> Don't. You can't. Those characters don't exist in the ASCII character set. > SQLite 3.0 deals with UTF-8 encoded SQL statements, though. That is not entirely correct - one can, if losing information is ok. The OPs code that normalized UTF-8 to NFKD, an umlaut like รค is transformed to a two-chara

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-03 Thread Robert Kern
ChaosKCW wrote: > Hi > > I am reading from an oracle database using cx_Oracle. I am writing to a > SQLite database using apsw. > > The oracle database is returning utf-8 characters for euopean item > names, ie special charcaters from an ASCII perspective. I'm not sure that you are using those te

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-03 Thread Paul Boddie
ChaosKCW wrote: > Hi > > I am reading from an oracle database using cx_Oracle. I am writing to a > SQLite database using apsw. > > The oracle database is returning utf-8 characters for euopean item > names, ie special charcaters from an ASCII perspective. And does cx_Oracle return those as Unicode

Convertion of Unicode to ASCII NIGHTMARE

2006-04-03 Thread ChaosKCW
Hi I am reading from an oracle database using cx_Oracle. I am writing to a SQLite database using apsw. The oracle database is returning utf-8 characters for euopean item names, ie special charcaters from an ASCII perspective. I get the following error: >SQLiteCur.execute(sql, row) >UnicodeDe