changeset 364:9cb8be5e6119

Merge
author lana
date Tue, 03 Jul 2012 18:24:03 -0700
parents 219e720a1baa (diff) 300f45e99064 (current diff)
children 404521944ac9 6e444b892c99
files
diffstat 1 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java	Thu Jun 28 09:32:52 2012 -0700
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java	Tue Jul 03 18:24:03 2012 -0700
@@ -2609,6 +2609,18 @@
         if (str == null) {
             return str;
         }
+        int len = str.length(), i=0, ch;
+        for (; i < len; i++) {
+            ch = str.charAt(i);
+            // if it's not an ASCII 7 character, break here, and use UTF-8 encoding
+            if (ch >= 128)
+                break;
+        }
+
+        // we saw no non-ascii-7 character
+        if (i == len) {
+            return str;
+        }
 
         // get UTF-8 bytes for the string
         StringBuffer buffer = new StringBuffer();
@@ -2620,11 +2632,11 @@
             // should never happen
             return str;
         }
-        int len = bytes.length;
-        int ch;
+
+        len = bytes.length;
 
         // for each byte
-        for (int i = 0; i < len; i++) {
+        for (i = 0; i < len; i++) {
             b = bytes[i];
             // for non-ascii character: make it positive, then escape
             if (b < 0) {