You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Szymon Stasik <sz...@3dart.pl> on 2000/05/25 06:01:36 UTC

encoding, encoding, encoding...


Hello,

I have found (and that not only me :), that to have correct encoding
while using xsp I have set it in the config file. However I've found one
more encoding problem - while using sql processor and retrieving data
from database (particulary MySQL) I have no possibility to use
apriopriate encoding :(

regards,

Szymon

Re: encoding, encoding, encoding...

Posted by Szymon Stasik <sz...@3dart.pl>.
Hmm - on the other side:

(byte[])(new String("±æê³ñó  ")).getBytes("iso-8859-2")

(byte[])(RS.getObject(1).toString().getBytes("iso-8859-2"))

gives me same bytes for same characters while using  the XSP


Szymon.

Re: encoding, encoding, encoding...

Posted by Szymon Stasik <sz...@3dart.pl>.
Donald Ball wrote:

> > While investigating my current status is that while testing XSP (XSP
> > itserf is configured to use ios-8859-2 encoding) i have:
> >
> > document.createTextNode("PL ok -- ±æê³ñó -- | PL not --" +
> > RS.getObject(1).toString()));
> >
> > where:
> > - first part ("PL ok -- ±æê³ñó --") shows correctly in HTML
> > - RS is latin2 encoded (but badly interpreted under cocoon) result of
> > some query I had prepared.
> > - exactly the same query prepared in exactly same way compiled
> > standalone gives me correct results on the console
> 
> can you send me the source code for the standalone app? i'm sure by
> stepping through your example v.s. mine that i oughta at least be able to
> single out the method calls that are responsible.
> 
> - donald


Below I am sending the code that is working for me ok on the console.
New ideas are:

new String((byte[])(new String("±æê³ñó  ")).getBytes("iso-8859-2"),
"iso-8859-2")

^^^^^^^ this works fine while using XSP, but any other encoding breaks
it


new
String((byte[])(RS.getObject(1).toString().getBytes("iso-8859-2")),"iso-8859-2"))

^^^^^^^^^ and this doesn't work 

IMO method toString() of Object class doesn't work ok in the cocoon
context (however any other actions works well)
but there should be some standard solution for that


Szymon.

--------------------------------------
import java.io.*;
import java.sql.*;

public class Hello {
    Hello() { }
    public static void main(String[] Args) {
        try {
            Class.forName("org.gjt.mm.mysql.Driver").newInstance();
        } catch (Exception E) {
            System.err.println("Unable to load driver.");
            E.printStackTrace();
        }
        try {
            Connection Conn = DriverManager.getConnection(
              "jdbc:mysql://localhost/...."); // <<< db and auth

            // Do something with the Connection
            Statement Stmt = Conn.createStatement();

            ResultSet RS = Stmt.executeQuery("SELECT tree FROM opis
WHERE short='12334'");

            while (RS.next()) {
                System.out.println(RS.getObject(1).toString());
                // ^^^^^^^^^^^^^^^^ this gives correct result on the
output
                // exactly the same whole code makes problem within XSP
page
            }
            // Clean up after ourselves
            RS.close();
            Stmt.close();
            Conn.close();
        } catch (SQLException E) {
            System.out.println("SQLException: " + E.getMessage());
            System.out.println("SQLState:     " + E.getSQLState());
            System.out.println("VendorError:  " + E.getErrorCode());
        }
        System.out.println("\nDone");
    }
}

Re: encoding, encoding, encoding...

Posted by Donald Ball <ba...@webslingerZ.com>.
On Fri, 26 May 2000, Szymon Stasik wrote:

> Szymon Stasik wrote:
> > plain mysql seems to be enough to get correctly encoded (eg. as-is) data
> > from MySQL without aditional settings (of course I need to recompile for
> > apriopriate sorting)
> > 
> > =>
> > 
> > there is one more encoding problem in cocoon :(
> 
> 
> While investigating my current status is that while testing XSP (XSP
> itserf is configured to use ios-8859-2 encoding) i have:
> 
> document.createTextNode("PL ok -- ����� -- | PL not --" +
> RS.getObject(1).toString()));
> 
> where:
> - first part ("PL ok -- ����� --") shows correctly in HTML
> - RS is latin2 encoded (but badly interpreted under cocoon) result of
> some query I had prepared. 
> - exactly the same query prepared in exactly same way compiled
> standalone gives me correct results on the console

can you send me the source code for the standalone app? i'm sure by
stepping through your example v.s. mine that i oughta at least be able to
single out the method calls that are responsible.

- donald


Re: encoding, encoding, encoding...

Posted by Szymon Stasik <sz...@3dart.pl>.
Szymon Stasik wrote:
> plain mysql seems to be enough to get correctly encoded (eg. as-is) data
> from MySQL without aditional settings (of course I need to recompile for
> apriopriate sorting)
> 
> =>
> 
> there is one more encoding problem in cocoon :(


While investigating my current status is that while testing XSP (XSP
itserf is configured to use ios-8859-2 encoding) i have:

document.createTextNode("PL ok -- ±æê³ñó -- | PL not --" +
RS.getObject(1).toString()));

where:
- first part ("PL ok -- ±æê³ñó --") shows correctly in HTML
- RS is latin2 encoded (but badly interpreted under cocoon) result of
some query I had prepared. 
- exactly the same query prepared in exactly same way compiled
standalone gives me correct results on the console



any ideas?

Szymon.

Re: encoding, encoding, encoding...

Posted by Szymon Stasik <sz...@3dart.pl>.
Pawel Pesz wrote:
> 
> "Szymon Stasik" <sz...@3dart.pl> wrote:
> > Pawel Pesz wrote:
> >>
> >> "Donald Ball" <ba...@webslingerZ.com> wrote:
> >>> [...]
> >>> Where do you set the encoding when using the mysql driver?
> >>> i don't see any encoding options in the standard JDBC API
> >>> - or am i just not looking in the right places?
> >>
> >> There are two connection properties for this:
> >>
> >>   useUnicode -> <boolean>
> >>   characterEncoding -> <encoding>
> >>
> >> They are actually documented in MM driver's (v. 2.0 pre5)
> >> tutorial :-)
> >
> >
> > yep - however seting those doesn't seems to help :((
> 
> Ah, I forgot to mention that you need to have MySQL
> compiled to handle "exotic" ;-) encodings (at least
> as far as version 3.22.X is concerned -- I haven't
> used 3.23.X).

plain mysql seems to be enough to get correctly encoded (eg. as-is) data
from MySQL without aditional settings (of course I need to recompile for
apriopriate sorting)

=>

there is one more encoding problem in cocoon :(


Szymon.

Re: encoding, encoding, encoding...

Posted by Pawel Pesz <Pa...@insert.com.pl>.
"Szymon Stasik" <sz...@3dart.pl> wrote:
> Pawel Pesz wrote:
>> 
>> "Donald Ball" <ba...@webslingerZ.com> wrote:
>>> [...]
>>> Where do you set the encoding when using the mysql driver?
>>> i don't see any encoding options in the standard JDBC API
>>> - or am i just not looking in the right places?
>> 
>> There are two connection properties for this:
>> 
>>   useUnicode -> <boolean>
>>   characterEncoding -> <encoding>
>> 
>> They are actually documented in MM driver's (v. 2.0 pre5)
>> tutorial :-)
> 
> 
> yep - however seting those doesn't seems to help :((

Ah, I forgot to mention that you need to have MySQL
compiled to handle "exotic" ;-) encodings (at least
as far as version 3.22.X is concerned -- I haven't
used 3.23.X).

--
Pawel Pesz
InsERT.net, Wroclaw, Poland
mailto:webmaster@insert.net.pl
http://www.insert.net.pl


Re: encoding, encoding, encoding...

Posted by Pawel Pesz <we...@insert.net.pl>.
Duh, sorry for the double posting. I thought the first
would be bounced because I used a different address to
that I'm subscribed under. Maybe the list's configuration
should be changed?
--
Pawel Pesz
InsERT.net, Wroclaw, Poland
mailto:webmaster@insert.net.pl
http://www.insert.net.pl


Re: encoding, encoding, encoding...

Posted by Pawel Pesz <we...@insert.net.pl>.
"Szymon Stasik" <sz...@3dart.pl> wrote:
> Pawel Pesz wrote:
>> 
>> "Donald Ball" <ba...@webslingerZ.com> wrote:
>>> [...]
>>> Where do you set the encoding when using the mysql driver?
>>> i don't see any encoding options in the standard JDBC API
>>> - or am i just not looking in the right places?
>> 
>> There are two connection properties for this:
>> 
>>   useUnicode -> <boolean>
>>   characterEncoding -> <encoding>
>> 
>> They are actually documented in MM driver's (v. 2.0 pre5)
>> tutorial :-)
> 
> 
> yep - however seting those doesn't seems to help :((

Ah, I forgot to mention that you need to have MySQL
compiled to handle "exotic" ;-) encodings (at least
as far as version 3.22.X is concerned -- I haven't
used 3.23.X).

--
Pawel Pesz
InsERT.net, Wroclaw, Poland
mailto:webmaster@insert.net.pl
http://www.insert.net.pl


Re: encoding, encoding, encoding...

Posted by Szymon Stasik <sz...@3dart.pl>.
Pawel Pesz wrote:
> 
> "Donald Ball" <ba...@webslingerZ.com> wrote:
> > [...]
> > Where do you set the encoding when using the mysql driver?
> > i don't see any encoding options in the standard JDBC API
> > - or am i just not looking in the right places?
> 
> There are two connection properties for this:
> 
>   useUnicode -> <boolean>
>   characterEncoding -> <encoding>
> 
> They are actually documented in MM driver's (v. 2.0 pre5)
> tutorial :-)


yep - however seting those doesn't seems to help :((

Re: encoding, encoding, encoding...

Posted by Pawel Pesz <we...@insert.net.pl>.
"Donald Ball" <ba...@webslingerZ.com> wrote:
> [...]
> Where do you set the encoding when using the mysql driver?
> i don't see any encoding options in the standard JDBC API
> - or am i just not looking in the right places?

There are two connection properties for this:

  useUnicode -> <boolean>
  characterEncoding -> <encoding>

They are actually documented in MM driver's (v. 2.0 pre5)
tutorial :-)

--
Pawel Pesz
InsERT.net, Wroclaw, Poland
mailto:webmaster@insert.net.pl
http://www.insert.net.pl


Re: encoding, encoding, encoding...

Posted by Donald Ball <ba...@webslingerZ.com>.
On Thu, 25 May 2000, Szymon Stasik wrote:

> Donald Ball wrote:
> > 
> > On Thu, 25 May 2000, Szymon Stasik wrote:
> > 
> > > I have found (and that not only me :), that to have correct encoding
> > > while using xsp I have set it in the config file. However I've found one
> > > more encoding problem - while using sql processor and retrieving data
> > > from database (particulary MySQL) I have no possibility to use
> > > apriopriate encoding :(
> > 
> > if you retrieve the data by other methods, it is okay? i had thought that
> > mysql didn't have much in the way of i18n support. can you suggest
> > how i ought to address the problem?
> 
> Till now I was using mysql wit perl and have no problems with
> apriopriate encoding so IMO this is a problem of driver/connection
> encoding. While investigating (right now :) soruces of mm jdbc I have
> found tht there is possibility to set encoding parameter but there are
> no encoding actions in cocoon sql processor.

Where do you set the encoding when using the mysql driver? i don't see any
encoding options in the standard JDBC API - or am i just not looking in
the right places?

- donald


Re: encoding, encoding, encoding...

Posted by Szymon Stasik <sz...@3dart.pl>.
Donald Ball wrote:
> 
> On Thu, 25 May 2000, Szymon Stasik wrote:
> 
> > I have found (and that not only me :), that to have correct encoding
> > while using xsp I have set it in the config file. However I've found one
> > more encoding problem - while using sql processor and retrieving data
> > from database (particulary MySQL) I have no possibility to use
> > apriopriate encoding :(
> 
> if you retrieve the data by other methods, it is okay? i had thought that
> mysql didn't have much in the way of i18n support. can you suggest
> how i ought to address the problem?

Till now I was using mysql wit perl and have no problems with
apriopriate encoding so IMO this is a problem of driver/connection
encoding. While investigating (right now :) soruces of mm jdbc I have
found tht there is possibility to set encoding parameter but there are
no encoding actions in cocoon sql processor.

Szymon

Re: encoding, encoding, encoding...

Posted by Donald Ball <ba...@webslingerZ.com>.
On Thu, 25 May 2000, Szymon Stasik wrote:

> I have found (and that not only me :), that to have correct encoding
> while using xsp I have set it in the config file. However I've found one
> more encoding problem - while using sql processor and retrieving data
> from database (particulary MySQL) I have no possibility to use
> apriopriate encoding :(

if you retrieve the data by other methods, it is okay? i had thought that
mysql didn't have much in the way of i18n support. can you suggest
how i ought to address the problem?

- donald