You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@ws.apache.org by Youngho Cho <yo...@nannet.co.kr> on 2004/10/06 02:29:08 UTC

Passing non-ASCII String value - Again

 Hello,

>> Are you sure that it objects to characters with values > 0XFF?
>> 
>> It certainly should refuse to send characters with values less than 
>> 0X20 unless they are /n, /r or /t. The XML spec spec does not allow 
>> these values in a well formed XML document.
>
> Sorry, that's right about values < 0x20. There is no problem that I
> cannot send those characters. But about characters with values > 0xFF,
> XML 1.0 allows it except for some special characters:
>
> Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] |
>         [#x10000-#x10FFFF]
> http://www.w3.org/TR/REC-xml/#charsets
>
> I think those should be allowed. The string I want to send only
> contains Unicode characters defined in above.

I found some patch for passing non ascii char from
http://jira.atlassian.com/browse/CONF-1188
 
 But I got another problem when I patching above patch into 1.2-b1 version.
 if I send some Korean Character which the hex values are
 utf8Bytes[0] = 0xea
 utf8Bytes[1] = 0xb0
 utf8Bytes[2] = 0x80
 utf8Bytes[3] = 0xea
 utf8Bytes[4] = 0xb0
 utf8Bytes[5] = 0x81
 
 The receiving value was
 utf8Bytes[0] = 0xea
 utf8Bytes[1] = 0xb0
 utf8Bytes[2] = 0x3f
 utf8Bytes[3] = 0xea
 utf8Bytes[4] = 0xb0
 utf8Bytes[5] = 0x3f
 
 Does we need another patch ?
 
 I used following Testing code
 
     /**
      * Tests client/server RPC 
      */
     public void testHangul()
     {
         try
         {
             String hangul = "가각";
             Vector params = new Vector();
             byte[] utf8Bytes = hangul.getBytes("UTF-8"); 
             // StringConverter is in java tutorial from sun
             StringConverter.printBytes(utf8Bytes, "utf8Bytes");
             params.add(hangul);
             Object response = client.execute(HANDLER_NAME + ".echo", params);  
             assertEquals(hangul, response);
         }
         catch (Exception e)
         {
             e.printStackTrace();
             fail(e.getMessage());
         }
     }   
  
     protected class TestHandler
     {
         public String echo(String message)
         {
            try
            {   
                byte[] utf8Bytes = message.getBytes(); 
                // StringConverter is in java tutorial from sun
                StringConverter.printBytes(utf8Bytes, "utf8Bytes");
            }
            catch(Exception e)
           {
                //
            }
             return message;
         }
     }
 
 
 Thanks,
 
 Youngho

Re: Passing non-ASCII String value - Again

Posted by "Shirai,Kaoru" <sh...@korinkan.co.jp>.
Hi, Youngho.

> Your additional patch works good also.

Thank you for your testing.

I wonder if the project takes atlassian's patch in.
-- 
Shirai,Kaoru <sh...@korinkan.co.jp>
Korinkan Ltd. - http://www.korinkan.co.jp/

Re: Passing non-ASCII String value - Again

Posted by Youngho Cho <yo...@nannet.co.kr>.
Hello Shirai,Kaoru


Your additional patch works good also.

Thanks !

Youngho.

----- Original Message ----- 
From: "Youngho Cho" <yo...@nannet.co.kr>
To: <xm...@ws.apache.org>; "Shirai,Kaoru" <sh...@korinkan.co.jp>
Sent: Thursday, October 07, 2004 11:59 AM
Subject: Re: Passing non-ASCII String value - Again


> Hello,
> Thanks for your reply.
> 
> I successfully pass the the Korean Character round-trip test 
> with current CVS version which is patched from the atlassian.
> ( with common-codec-1.2 )
> 
> Thanks,
> 
> Youngho
> 
> ----- Original Message ----- 
> From: "Shirai,Kaoru" <sh...@korinkan.co.jp>
> To: <xm...@ws.apache.org>; <yo...@nannet.co.kr>
> Sent: Thursday, October 07, 2004 10:32 AM
> Subject: Re: Passing non-ASCII String value - Again
> 
> 
> > >  Does we need another patch ?
> > 
> > 1. Try to insert this code before creating XmlRpcClient:
> > 
> >   XmlRpc.setEncoding("UTF8");
> > 
> > 2. Otherwise, how about this patch (string-utf8.diff)?
> >    ( Note: This patch also requires XmlRpc.setEncoding("UTF8") )
> > -- 
> > Shirai,Kaoru <sh...@korinkan.co.jp>
> > Korinkan Ltd. - http://www.korinkan.co.jp/
> > 
> 
> 
> --------------------------------------------------------------------------------
> 
> 
> > Index: src/java/org/apache/xmlrpc/XmlRpc.java
> > ===================================================================
> > RCS file: /home/cvspublic/ws-xmlrpc/src/java/org/apache/xmlrpc/XmlRpc.java,v
> > retrieving revision 1.37
> > diff -u -r1.37 XmlRpc.java
> > --- src/java/org/apache/xmlrpc/XmlRpc.java 30 Jun 2004 06:11:55 -0000 1.37
> > +++ src/java/org/apache/xmlrpc/XmlRpc.java 7 Oct 2004 01:31:24 -0000
> > @@ -56,6 +56,7 @@
> >   */
> >  
> >  import java.io.InputStream;
> > +import java.io.InputStreamReader;
> >  import java.util.Hashtable;
> >  import java.util.Stack;
> >  import java.util.Vector;
> > @@ -387,6 +388,7 @@
> >       */
> >      synchronized void parse(InputStream is) throws Exception
> >      {
> > +        InputStreamReader reader = new InputStreamReader(is, "UTF8");
> >          // reset values (XmlRpc objects are reusable)
> >          errorLevel = NONE;
> >          errorMsg = null;
> > @@ -440,7 +442,7 @@
> >          }
> >          try
> >          {
> > -            parser.parse(new InputSource (is));
> > +            parser.parse(new InputSource (reader));
> >          }
> >          finally
> >          {
> > Index: src/java/org/apache/xmlrpc/XmlWriter.java
> > ===================================================================
> > RCS file: /home/cvspublic/ws-xmlrpc/src/java/org/apache/xmlrpc/XmlWriter.java,v
> > retrieving revision 1.11
> > diff -u -r1.11 XmlWriter.java
> > --- src/java/org/apache/xmlrpc/XmlWriter.java 30 Jun 2004 18:46:58 -0000 1.11
> > +++ src/java/org/apache/xmlrpc/XmlWriter.java 7 Oct 2004 01:31:24 -0000
> > @@ -335,11 +335,6 @@
> >              char c = text.charAt (i);
> >              switch (c)
> >              {
> > -            case '\t':
> > -            case '\r':
> > -            case '\n':
> > -                write(c);
> > -                break;
> >              case '<':
> >                  write(LESS_THAN_ENTITY);
> >                  break;
> > @@ -350,8 +345,16 @@
> >                  write(AMPERSAND_ENTITY);
> >                  break;
> >              default:
> > -                if (c < 0x20 || c > 0xff)
> > -                {
> > +                boolean badChar = false;
> > +                switch (c) {
> > +                case '\t':
> > +                case '\r':
> > +                case '\n':
> > +                    break;
> > +                default:
> > +                    badChar = (c < 0x20);
> > +                }
> > +                if (badChar) {
> >                      // Though the XML-RPC spec allows any ASCII
> >                      // characters except '<' and '&', the XML spec
> >                      // does not allow this range of characters,
> > @@ -361,10 +364,7 @@
> >                                                "corresponding to XML entity &#" +
> >                                                String.valueOf((int) c) + ';', null);
> >                  }
> > -                else
> > -                {
> > -                    write(c);
> > -                }
> > +                write(c);
> >              }
> >          }
> >      }
> >

Re: Passing non-ASCII String value - Again

Posted by Youngho Cho <yo...@nannet.co.kr>.
Hello,
Thanks for your reply.

I successfully pass the the Korean Character round-trip test 
with current CVS version which is patched from the atlassian.
( with common-codec-1.2 )

Thanks,

Youngho

----- Original Message ----- 
From: "Shirai,Kaoru" <sh...@korinkan.co.jp>
To: <xm...@ws.apache.org>; <yo...@nannet.co.kr>
Sent: Thursday, October 07, 2004 10:32 AM
Subject: Re: Passing non-ASCII String value - Again


> >  Does we need another patch ?
> 
> 1. Try to insert this code before creating XmlRpcClient:
> 
>   XmlRpc.setEncoding("UTF8");
> 
> 2. Otherwise, how about this patch (string-utf8.diff)?
>    ( Note: This patch also requires XmlRpc.setEncoding("UTF8") )
> -- 
> Shirai,Kaoru <sh...@korinkan.co.jp>
> Korinkan Ltd. - http://www.korinkan.co.jp/
> 


--------------------------------------------------------------------------------


> Index: src/java/org/apache/xmlrpc/XmlRpc.java
> ===================================================================
> RCS file: /home/cvspublic/ws-xmlrpc/src/java/org/apache/xmlrpc/XmlRpc.java,v
> retrieving revision 1.37
> diff -u -r1.37 XmlRpc.java
> --- src/java/org/apache/xmlrpc/XmlRpc.java 30 Jun 2004 06:11:55 -0000 1.37
> +++ src/java/org/apache/xmlrpc/XmlRpc.java 7 Oct 2004 01:31:24 -0000
> @@ -56,6 +56,7 @@
>   */
>  
>  import java.io.InputStream;
> +import java.io.InputStreamReader;
>  import java.util.Hashtable;
>  import java.util.Stack;
>  import java.util.Vector;
> @@ -387,6 +388,7 @@
>       */
>      synchronized void parse(InputStream is) throws Exception
>      {
> +        InputStreamReader reader = new InputStreamReader(is, "UTF8");
>          // reset values (XmlRpc objects are reusable)
>          errorLevel = NONE;
>          errorMsg = null;
> @@ -440,7 +442,7 @@
>          }
>          try
>          {
> -            parser.parse(new InputSource (is));
> +            parser.parse(new InputSource (reader));
>          }
>          finally
>          {
> Index: src/java/org/apache/xmlrpc/XmlWriter.java
> ===================================================================
> RCS file: /home/cvspublic/ws-xmlrpc/src/java/org/apache/xmlrpc/XmlWriter.java,v
> retrieving revision 1.11
> diff -u -r1.11 XmlWriter.java
> --- src/java/org/apache/xmlrpc/XmlWriter.java 30 Jun 2004 18:46:58 -0000 1.11
> +++ src/java/org/apache/xmlrpc/XmlWriter.java 7 Oct 2004 01:31:24 -0000
> @@ -335,11 +335,6 @@
>              char c = text.charAt (i);
>              switch (c)
>              {
> -            case '\t':
> -            case '\r':
> -            case '\n':
> -                write(c);
> -                break;
>              case '<':
>                  write(LESS_THAN_ENTITY);
>                  break;
> @@ -350,8 +345,16 @@
>                  write(AMPERSAND_ENTITY);
>                  break;
>              default:
> -                if (c < 0x20 || c > 0xff)
> -                {
> +                boolean badChar = false;
> +                switch (c) {
> +                case '\t':
> +                case '\r':
> +                case '\n':
> +                    break;
> +                default:
> +                    badChar = (c < 0x20);
> +                }
> +                if (badChar) {
>                      // Though the XML-RPC spec allows any ASCII
>                      // characters except '<' and '&', the XML spec
>                      // does not allow this range of characters,
> @@ -361,10 +364,7 @@
>                                                "corresponding to XML entity &#" +
>                                                String.valueOf((int) c) + ';', null);
>                  }
> -                else
> -                {
> -                    write(c);
> -                }
> +                write(c);
>              }
>          }
>      }
> 

Re: Passing non-ASCII String value - Again

Posted by "Shirai,Kaoru" <sh...@korinkan.co.jp>.
>  Does we need another patch ?

1. Try to insert this code before creating XmlRpcClient:

  XmlRpc.setEncoding("UTF8");

2. Otherwise, how about this patch (string-utf8.diff)?
   ( Note: This patch also requires XmlRpc.setEncoding("UTF8") )
-- 
Shirai,Kaoru <sh...@korinkan.co.jp>
Korinkan Ltd. - http://www.korinkan.co.jp/