axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: ws-axis/java/test/encoding TestString.java
Date Wed, 26 Nov 2003 10:44:08 GMT
dims        2003/11/26 02:44:08

  Modified:    java/src/org/apache/axis/components/encoding
                        AbstractXMLEncoder.java EncodedByteArray.java
               java/test/encoding TestString.java
  Log:
  Fix for Bug 24896 - problem with acute/grave accents
  from 	cchabanois@cognicase.fr
  
  Revision  Changes    Path
  1.4       +9 -1      ws-axis/java/src/org/apache/axis/components/encoding/AbstractXMLEncoder.java
  
  Index: AbstractXMLEncoder.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/components/encoding/AbstractXMLEncoder.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractXMLEncoder.java	5 Oct 2003 07:04:34 -0000	1.3
  +++ AbstractXMLEncoder.java	26 Nov 2003 10:44:08 -0000	1.4
  @@ -156,7 +156,15 @@
                       break;
               }
           }
  -        return (out == null) ? xmlString : out.toString();
  +        if (out == null) {
  +            return xmlString;
  +        }
  +        try {
  +            return out.toString(getEncoding());
  +        } catch (UnsupportedEncodingException e) {
  +            // we tested it ealier, should work.
  +            throw new IllegalStateException(Messages.getMessage("encodingDisappeared00",
getEncoding()));
  +        }
       }
   
       public abstract String getEncoding();
  
  
  
  1.2       +17 -1     ws-axis/java/src/org/apache/axis/components/encoding/EncodedByteArray.java
  
  Index: EncodedByteArray.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/components/encoding/EncodedByteArray.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EncodedByteArray.java	18 Jul 2003 12:40:39 -0000	1.1
  +++ EncodedByteArray.java	26 Nov 2003 10:44:08 -0000	1.2
  @@ -54,6 +54,8 @@
    */
   package org.apache.axis.components.encoding;
   
  +import java.io.UnsupportedEncodingException;
  +
   /**
    *
    * Simple byte array with variable array length, used within the
  @@ -115,7 +117,21 @@
           pointer += length;
       }
   
  +    /**
  +     * convert to a string using the platform's default charset 
  +     * @return string
  +     */ 
       public String toString() {
           return new String(array, 0, pointer);
  +    }
  +
  +    /**
  +     * convert the encoded byte array to a string according to the given charset 
  +     * @param charsetName
  +     * @return string
  +     * @throws UnsupportedEncodingException
  +     */ 
  +    public String toString(String charsetName) throws UnsupportedEncodingException {
  +        return new String(array, 0, pointer, charsetName);
       }
   }
  
  
  
  1.14      +10 -3     ws-axis/java/test/encoding/TestString.java
  
  Index: TestString.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/test/encoding/TestString.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- TestString.java	25 Nov 2003 13:32:10 -0000	1.13
  +++ TestString.java	26 Nov 2003 10:44:08 -0000	1.14
  @@ -86,17 +86,24 @@
       public void testWhitespace() throws Exception {
           runtest(" \n \t "); // note: \r fails
       }
  -/*    
  +
       public void testFrenchAccents() throws Exception {
           runtest("\u00e0\u00e2\u00e4\u00e7\u00e8\u00e9\u00ea\u00eb\u00ee\u00ef\u00f4\u00f6\u00f9\u00fb\u00fc");
       }
       
       public void testFrenchAccents2() throws Exception {
  -        runtest("Une chaîne avec des caractères accentués");
  +        runtest("Une chaîne avec des caractères accentués");
       }
       
       public void testGermanUmlauts() throws Exception {
           runtest(" Some text \u00df with \u00fc special \u00f6 chars \u00e4.");
       }
  -*/    
  +    
  +    public void testWelcomeUnicode() throws Exception {
  +        // welcome in several languages
  +        runtest(
  +          "Chinese (trad.) : \u6b61\u8fce  \n" +
  +          "Greek : \u03ba\u03b1\u03bb\u03ce\u03c2 \u03bf\u03c1\u03af\u03c3\u03b1\u03c4\u03b5
\n"+
  +          "Japanese : \u3088\u3046\u3053\u305d");
  +    }
   }
  
  
  

Mime
View raw message