osdir.com
mailing list archive

Subject: Problem with encoding - msg#00007

List: lang.jython.user

Date: Prev Next Index Thread: Prev Next Index
Hi all,

I am using the zxJDBC application with a database which uses the UTF-8
encoding.
When I query this database, I don't get the good characters.

How can I force jython to use the UTF-8 encoding ?

Thank in advance for your help,

Regards,

Jean-Guillaume LALANNE



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click


Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

jythonc & ImportError

Hi folks, I am confused about the 'jythonc' tool. I used the following command : #----------------------- D:\test\JOrderGenerator>jythonc --core --deep --jar generator.jar *.py processing Configurator processing Generate processing ParamatersForm Required packages: javax.swing com java.awt Creating adapters: java.awt.event.ActionListener used in ParamatersForm Creating .java files: Configurator module ParamatersForm module ParamatersForm extends javax.swing.JFrame Generate module Compiling .java to .class... Compiling with args: ['C:\\j2sdk1.4.1_03\\bin\\javac', '-classpath', 'D:\\Jython \\jython.jar;;.\\jpywork;;D:\\Jython\\Tools\\jythonc;D:\\test\\JOrderGenerator\\ .;D:\\Jython\\Lib;D:\\Jython', '.\\jpywork\\Configurator.java', '.\\jpywork\\Par amatersForm.java', '.\\jpywork\\Generate.java'] 0 Building archive: generator.jar Tracking java dependencies: D:\test\JOrderGenerator> #-------------------------- At first glance it looks ok, but when i run my class, using the same classpath i used for the uncompiled version of it, i get the following error : Exception in thread "main" Traceback (innermost last): File "D:\test\JOrderGenerator\Generate.py", line 0, in main ImportError: No module named stonylic where 'stonylic' is just the path of one of my import in my *.py file; i have the following line : from com.stonylic.maths import Compute Do you know what's going on ? Every advices will be greatly appreciated, Thanks in advance, Sylvain. ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click

Next Message by Date: click to view message preview

Re: I'm not sure how to interpret this Jython response

On Mon, Jul 04, 2005 at 09:48:43AM +0200, LASSAGNE Christophe wrote: > I think the next code is okay > > fsrc = open('c:/demo/file/SRC_FILE.txt', 'r') > try: > for lsrc in fsrc.readlines(): > ... > finally: > fsrc.close() This is essentially equivalent to code which Tudza sent in a separate message -- the issue with it is just that it reads the entire file into memory. If you don't care about that (if you're sure your file will never be too large), then this pattern is fine. Otherwise, xreadlines is the old pattern for this. I distrust naive assumptions about the sizes of files; too often you get surprised later on. <rueful smile> IIRC, Jython was originally built against an older version of python -- one where the file object didn't support the form below. At the time, xreadlines was the way to do this... it still appears to work. cheers -- Ed through python 2.3 compatible bug > > > -----Message d'origine----- > De : jython-users-admin@xxxxxxxxxxxxxxxxxxxxx > [mailto:jython-users-admin@xxxxxxxxxxxxxxxxxxxxx]De la part de tudza > Envoyà : samedi 2 juillet 2005 03:01 > à : jython-users@xxxxxxxxxxxxxxxxxxxxx > Objet : [Jython-users] I'm not sure how to interpret this Jython > response > > > I have a perfectly good Python program I wanted to try and run under Jython, > since I haven't used Jython before, and it immediately gives me trouble. > > Now it may be a problem that I'm using the Jython plugin for jEdit and adding > an extra layer, but I have no idea where to start looking for the source of > this problem. > > Basically, I have this these two lines to open a file and go through the > lines in that file: > > inputFile=open('C:\\Documents and > Settings\\Administrator\\Desktop\\Oligo_List.csv','r') > > for line in inputFile: > > > and the error I get back in the Jython window is: > > Traceback (innermost last): > > File "C:\Python24\SwapNs.py", line 24, in ? > > AttributeError: __getitem__ > > > line 24 is of course the line "for line in inputFile:" > > I know this is not saying that inputFile cannot be found, I already fixed > that issue, so what is this telling me? > > > > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click > _______________________________________________ > Jython-users mailing list > Jython-users@xxxxxxxxxxxxxxxxxxxxx > https://lists.sourceforge.net/lists/listinfo/jython-users > > > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&opÃk > _______________________________________________ > Jython-users mailing list > Jython-users@xxxxxxxxxxxxxxxxxxxxx > https://lists.sourceforge.net/lists/listinfo/jython-users ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click

Previous Message by Thread: click to view message preview

jythonc & ImportError

Hi folks, I am confused about the 'jythonc' tool. I used the following command : #----------------------- D:\test\JOrderGenerator>jythonc --core --deep --jar generator.jar *.py processing Configurator processing Generate processing ParamatersForm Required packages: javax.swing com java.awt Creating adapters: java.awt.event.ActionListener used in ParamatersForm Creating .java files: Configurator module ParamatersForm module ParamatersForm extends javax.swing.JFrame Generate module Compiling .java to .class... Compiling with args: ['C:\\j2sdk1.4.1_03\\bin\\javac', '-classpath', 'D:\\Jython \\jython.jar;;.\\jpywork;;D:\\Jython\\Tools\\jythonc;D:\\test\\JOrderGenerator\\ .;D:\\Jython\\Lib;D:\\Jython', '.\\jpywork\\Configurator.java', '.\\jpywork\\Par amatersForm.java', '.\\jpywork\\Generate.java'] 0 Building archive: generator.jar Tracking java dependencies: D:\test\JOrderGenerator> #-------------------------- At first glance it looks ok, but when i run my class, using the same classpath i used for the uncompiled version of it, i get the following error : Exception in thread "main" Traceback (innermost last): File "D:\test\JOrderGenerator\Generate.py", line 0, in main ImportError: No module named stonylic where 'stonylic' is just the path of one of my import in my *.py file; i have the following line : from com.stonylic.maths import Compute Do you know what's going on ? Every advices will be greatly appreciated, Thanks in advance, Sylvain. ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click

Next Message by Thread: click to view message preview

Re: Problem with encoding

If you use a Java connector, then it's a question of telling the Java connector to use the right encoding. With MySQL's driver, you can include this in the query string, e.g. I don't know zxJDBC. If you were using something in python, again it'd likely depend on which library. At worse, you could work around it by ensuring that the default is something binary-safe (like iso-8859-1) and transforming it into unicode or utf-8 (depending on what you're going to do with it) using codecs. But it sounds like you're using a Java JDBC driver, so the docs for it are the place to look. Jython is a set of libraries which run in a JVM: Jython sets up your python program to run in a Java interpretor. Java has concepts for unicode (chars -- UTF-16 variant, IIRC) and binary data (bytes). The real question is likely the same as for other Java programs: how do you ensure that when bytes are transformed into characters, the correct encoding is used. Of course, once you start using unicode (the 'correct' way in Java), you also have to ensure that the correct encoding is used when characters are transformed into bytes, e.g. to send across the network or to put into a file. good luck -- Ed On Mon, Jul 04, 2005 at 02:38:17PM +0200, Jean Guillaume LALANNE wrote: > Hi all, > > I am using the zxJDBC application with a database which uses the UTF-8 > encoding. > When I query this database, I don't get the good characters. > > How can I force jython to use the UTF-8 encoding ? > > Thank in advance for your help, > > Regards, > > Jean-Guillaume LALANNE > > > > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click > _______________________________________________ > Jython-users mailing list > Jython-users@xxxxxxxxxxxxxxxxxxxxx > https://lists.sourceforge.net/lists/listinfo/jython-users ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by