Dave,

It's possible that there is a problem here. Inline::Java uses a very simple
(and somewhat inefficient) encoding to pass the data between Perl and Java.

Here is the corresponding code:

sub encode {
 my $s = shift ;

 return join(".", unpack("C*", $s)) ;
}

and

 String Decode(String s){
  StringTokenizer st = new StringTokenizer(s, ".") ;
  StringBuffer sb = new StringBuffer() ;
  while (st.hasMoreTokens()){
   String ss = st.nextToken() ;
   byte b[] = {(byte)Integer.parseInt(ss)} ;
   sb.append(new String(b)) ;
  }


It breaks up the string byte by byte and reconstructs it on the other side.
It's probable that this doesn't work
with multibyte characters since it's probably creating a character for each
byte.

If you have time to check this out and send me a patch that would be great,
but I don't have the time currently to investigate this. I have no problem
reviewing the encoding completely, I did like this to make sure I could
implement the protocol line by line. Maybe only escaping the \n's would have
been sufficient.

Anyways comments/suggestions are welcome.


---------------------
Patrick LeBoutillier
Laval, Quebec, Canada
----- Original Message -----
From: "Dave LaMacchia" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 04, 2003 9:19 PM
Subject: Inline::Java and utf8


>
> I'm working on some code that uses Inline::Java to parse user input in
> order to make calls to a corba interface in front of an oracle
> database.
>
> I found when I fetch utf8 data from the database, all is well
> (assuming I've set my locale -- this is on Solaris 2.8 -- to
> en_US.UTF-8).  When I go the other way, however, passing data from
> perl to Java via Inline, I get data corruption in the non-ASCII
> characters.
>
> I thought that I might have to convert the strings to UCS2, since
> that's what Java uses internally, but this results in java errors due
> to embedded null characters.
>
> Has anyone run into this problem before?  Any suggestions how to get
> around it?  I'm using perl 5.8 so I shouldn't have to insert a use
> utf8 pragma.  Note also that I've confirmed the data is correct in the
> perl code before the embedded Java is called.
>
> Thanks!
>
> --dave
>

Reply via email to