[cx-oracle-users] RE: strange character encoding problems
Brought to you by:
atuining
From: Henning v. B. <H.v...@t-...> - 2006-01-31 09:19:59
|
Ahmm, might be a dumb question, but have you checked your environment variables and (on Windows) Oracle Regstry keys? In particular, how is NLS_LANG set? If the character set in NLS_LANG differs from that used in the database, then Oracle will convert characters. If the character set are equal, Oracle will pass all characters AS IS, and your program can even use characters that are not defined at all in the character set. Henning > -----Urspr=FCngliche Nachricht----- > Von: cx-...@li... > [mailto:cx-...@li...]Im Auftrag von > cx-...@li... > Gesendet: Dienstag, 31. Januar 2006 05:01 > An: cx-...@li... > Betreff: cx-oracle-users digest, Vol 1 #193 - 2 msgs >=20 >=20 > Send cx-oracle-users mailing list submissions to > cx-...@li... >=20 > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > or, via email, send a message with subject or body 'help' to > cx-...@li... >=20 > You can reach the person managing the list at > cx-...@li... >=20 > When replying, please edit your Subject line so it is more specific > than "Re: Contents of cx-oracle-users digest..." >=20 >=20 > Today's Topics: >=20 > 1. RE: strange character encoding problems (Amaury Forgeotdarc) > 2. Re: strange character encoding problems (Marcus Eggenberger) >=20 > --__--__-- >=20 > Message: 1 > Subject: RE: [cx-oracle-users] strange character encoding problems > Date: Mon, 30 Jan 2006 09:31:40 +0100 > From: "Amaury Forgeotdarc" <Ama...@gl...> > To: <cx-...@li...> > Reply-To: cx-...@li... >=20 > Hello, >=20 > Marcus Eggenberger wrote: > > I am not able to store characters of the latin-1 charset in my=3D20 > > oracle-database. I've encoded them according to=20 > NLS_CHARACTERSET but=3D20 > > that doesn't help. > > I'm running Oracle 10g XE, Python 2.4.1 and cx_Oracle 4.1 > >=3D20 > > Here is some sample code which shows the very strange results: > >=3D20 > >=3D20 > > #!/usr/bin/python=3D20 > >=3D20 > > # -*- coding: iso-8859-1 -*-=3D20 > >=3D20 > > import cx_Oracle > >=3D20 > > db =3D3D cx_Oracle.connect('TESTUSER/TESTPASSWORD@localhost') > > c =3D3D db.cursor() > >=3D20 > > query =3D3D unicode("SELECT '=3DE4=3DF6=3DFC' FROM dual", = 'iso-8859-1') > > charsets =3D3D ['iso-8859-1', 'cp1252', 'utf-8', 'utf-16'] > >=3D20 > > c.execute('SELECT * FROM V$NLS_PARAMETERS') > > for row in c: > > print row > >=3D20 > > for charset in charsets: > > try: > > c.execute(query.encode(charset)) > > except cx_Oracle.Error, err: > > print err > > else: > > print charset, c.fetchone()[0] > >=3D20 > > c.close() > > db.close() >=20 > I tried the same script, and I get correct results on my database > for the first two charsets, as expected. >=20 > Did you check that your database can handle latin-1 characters? > Take a look at NLS_CHARACTERSET in the NLS_DATABASE_PARAMETERS view. >=20 > Another thing: the -*- coding -*- line is not correctly placed. > It must be the first or second line of the script. > I don't know if this makes the difference. >=20 > --=3D20 > Amaury Forgeot d'Arc > Ubix Development > www.ubitrade.com >=20 >=20 > --__--__-- >=20 > Message: 2 > Date: Mon, 30 Jan 2006 12:50:29 +0100 > From: Marcus Eggenberger <i...@eg...> > To: cx-...@li... > Subject: Re: [cx-oracle-users] strange character encoding problems > Reply-To: cx-...@li... >=20 > Hi, >=20 > thanks for the reply. >=20 > Amaury Forgeotdarc wrote: > > Hello, > >=20 > > Marcus Eggenberger wrote: > >=20 > >>I am not able to store characters of the latin-1 charset in my=20 > >>oracle-database. I've encoded them according to=20 > NLS_CHARACTERSET but=20 > >>that doesn't help. > >>I'm running Oracle 10g XE, Python 2.4.1 and cx_Oracle 4.1 > >> > >>Here is some sample code which shows the very strange results: > >> > >> > >>#!/usr/bin/python=20 > >> > >># -*- coding: iso-8859-1 -*-=20 > >> > >>import cx_Oracle > >>>=20 > >=20 > > I tried the same script, and I get correct results on my database > > for the first two charsets, as expected. > >=20 > Darn, I really hoped my code would be wrong... >=20 > > Did you check that your database can handle latin-1 characters? > > Take a look at NLS_CHARACTERSET in the NLS_DATABASE_PARAMETERS view. > >=20 > The Output of NLS_DATABASE_PARAMETERS is the very same as=20 > V$NLS_PARAMETERS. > NLS_CHARACTERSET: WE8MSWIN1252 > NLS_NCHAR_CHARACTERSET: AL16UTF16 >=20 > > Another thing: the -*- coding -*- line is not correctly placed. > > It must be the first or second line of the script. > > I don't know if this makes the difference. > >=20 > In my sources the line was right beneath the shebang line. Otherwise=20 > python would have raised an Warning. >=20 > What's strange too: > When I insert a latin-1 character via the oracle htmldb, it is stored=20 > correctly. Since it shows up correctly in the htmldb object browser. > But when I'm reading this value via my python script the=20 > umlauts are gone. > This means: =E4 -> a, =F6 -> o, =FC -> u >=20 > I'm totally lost with this one. > Any other Ideas? >=20 > Kind regards, > Marcus >=20 >=20 >=20 > --__--__-- >=20 > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users >=20 >=20 > End of cx-oracle-users Digest >=20 |