harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r996934 - in /harmony/enhanced/java/branches/java6: ./ classlib/ classlib/depends/libs/ classlib/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/ classlib/modules/nio_char/src/test/java/tests/api/java/nio/charset/ drlvm/ j...
Date Tue, 14 Sep 2010 15:04:38 GMT
Author: hindessm
Date: Tue Sep 14 15:04:38 2010
New Revision: 996934

URL: http://svn.apache.org/viewvc?rev=996934&view=rev
Log:
Merge change from /harmony/enhanced/java/trunk@996904:

  r996904 | tellison | 2010-09-14 15:05:44 +0100 (Tue, 14 Sep 2010) | 2 lines
  
  Apply patch and test case for HARMONY-6640 (UTF8 decoder doesn't properly decode supplementary
characters)
  


Modified:
    harmony/enhanced/java/branches/java6/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/depends/libs/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/UTF_8.java
    harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF8CharsetTest.java
    harmony/enhanced/java/branches/java6/drlvm/   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/   (props changed)

Propchange: harmony/enhanced/java/branches/java6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 14 15:04:38 2010
@@ -1,4 +1,4 @@
 /harmony/enhanced/java/branches/mrh:935751-941490
-/harmony/enhanced/java/trunk:929253-996210,996457,996567,996687,996798,996801,996806,996812,996814,996824
+/harmony/enhanced/java/trunk:929253-996210,996457,996567,996687,996798,996801,996806,996812,996814,996824,996904
 /harmony/enhanced/trunk:476395-929252
 /incubator/harmony/enhanced/trunk:292550-476394

Propchange: harmony/enhanced/java/branches/java6/classlib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 14 15:04:38 2010
@@ -1,7 +1,7 @@
 /harmony/enhanced/classlib/trunk:713674-735919,765923-926091,926318-926838
 /harmony/enhanced/classlib/trunk/working_classlib:884014-884286
 /harmony/enhanced/java/branches/mrh/classlib:935751-941490
-/harmony/enhanced/java/trunk/classlib:929253-996210,996457,996567,996687,996798,996801,996806,996812,996814,996824
+/harmony/enhanced/java/trunk/classlib:929253-996210,996457,996567,996687,996798,996801,996806,996812,996814,996824,996904
 /harmony/enhanced/trunk/classlib:476395-929252
 /harmony/enhanced/trunk/working_classlib:476396-920147
 /incubator/harmony/enhanced/trunk/classlib:292550-476394

Propchange: harmony/enhanced/java/branches/java6/classlib/depends/libs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 14 15:04:38 2010
@@ -1,4 +1,4 @@
 /harmony/enhanced/classlib/trunk/depends/libs:544451-926091
-/harmony/enhanced/java/trunk/classlib/depends/libs:929253-996210,996457,996567,996687,996798,996801,996806,996812,996814,996824
+/harmony/enhanced/java/trunk/classlib/depends/libs:929253-996210,996457,996567,996687,996798,996801,996806,996812,996814,996824,996904
 /harmony/enhanced/trunk/classlib/depends/libs:476395-929252
 /incubator/harmony/enhanced/trunk/classlib/depends/libs:292550-476394

Modified: harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/UTF_8.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/UTF_8.java?rev=996934&r1=996933&r2=996934&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/UTF_8.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/main/java/org/apache/harmony/niochar/charset/UTF_8.java
Tue Sep 14 15:04:38 2010
@@ -157,8 +157,17 @@ public class UTF_8 extends Charset {
                         }
                         inIndex += tail;
                     }
-                    cArr[outIndex++] = (char) jchar;
-                    outRemaining--;
+                    if (jchar <= 0xffff) {
+                      cArr[outIndex++] = (char) jchar;
+                      outRemaining--;
+                    } else {
+                      if (outRemaining < 2) {
+                          return CoderResult.OVERFLOW;
+                      }
+                      cArr[outIndex++] = (char) ((jchar >> 0xA) + 0xD7C0);
+                      cArr[outIndex++] = (char) ((jchar & 0x3FF) + 0xDC00);
+                      outRemaining -= 2;
+                    }
                 }
                 in.position(inIndex - in.arrayOffset());
                 out.position(outIndex - out.arrayOffset());
@@ -198,9 +207,18 @@ public class UTF_8 extends Charset {
                             }
                             pos += tail;
                         }
+                        if (jchar <= 0xffff) {
+                          out.put((char) jchar);
+                          outRemaining--;
+                        } else {
+                          if (outRemaining < 2) {
+                              return CoderResult.OVERFLOW;
+                          }
+                          out.put((char) ((jchar >> 0xA) + 0xD7C0));
+                          out.put((char) ((jchar & 0x3FF) + 0xDC00));
+                          outRemaining -= 2;
+                        }
                         pos++;
-                        out.put((char) jchar);
-                        outRemaining--;
                     }
                     return CoderResult.UNDERFLOW;
                 } finally {

Modified: harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF8CharsetTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF8CharsetTest.java?rev=996934&r1=996933&r2=996934&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF8CharsetTest.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF8CharsetTest.java
Tue Sep 14 15:04:38 2010
@@ -16,6 +16,8 @@
 
 package tests.api.java.nio.charset;
 
+import java.io.UnsupportedEncodingException;
+
 /**
  * Test UTF-8 charset.
  */
@@ -50,4 +52,11 @@ public class UTF8CharsetTest extends Abs
 		byte[] output = new byte[] { 97, 98, -27, -76, -108, -26, -107, -113 };
 		internalTestEncode(input, output);
 	}
+	
+    public void test_surrogate() throws UnsupportedEncodingException {
+        // U+1D11E: MUSICAL SYMBOL G CLEF
+        String s = new StringBuilder().appendCodePoint(0x1D11E).toString();
+        byte utf8[] = s.getBytes("UTF-8");
+        assertEquals(s, new String(utf8, 0, utf8.length, "UTF-8"));
+    }
 }

Propchange: harmony/enhanced/java/branches/java6/drlvm/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 14 15:04:38 2010
@@ -1,5 +1,5 @@
 /harmony/enhanced/java/branches/mrh/drlvm:935751-941490
-/harmony/enhanced/java/trunk/drlvm:929253-996210,996457,996567,996687,996798,996801,996806,996812,996814,996824
+/harmony/enhanced/java/trunk/drlvm:929253-996210,996457,996567,996687,996798,996801,996806,996812,996814,996824,996904
 /harmony/enhanced/trunk/drlvm:476395-929252
 /harmony/enhanced/trunk/working_vm:476396-920147
 /incubator/harmony/enhanced/trunk/drlvm:292550-476394

Propchange: harmony/enhanced/java/branches/java6/jdktools/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 14 15:04:38 2010
@@ -1,4 +1,4 @@
-/harmony/enhanced/java/trunk/jdktools:929253-996210,996457,996567,996687,996798,996801,996806,996812,996814,996824
+/harmony/enhanced/java/trunk/jdktools:929253-996210,996457,996567,996687,996798,996801,996806,996812,996814,996824,996904
 /harmony/enhanced/jdktools/trunk:630107-925933
 /harmony/enhanced/trunk/jdktools:476395-929252
 /harmony/enhanced/trunk/working_jdktools:476396-920147



Mime
View raw message