This caused incorrect loading of utf8 strings with
character codes >= 0x80.
Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
regression/jvm/StringTest.java | 5 +++++
vm/utf8.c | 10 +++++-----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/regression/jvm/StringTest.java b/regression/jvm/StringTest.java
index 245da22..7640b5e 100644
--- a/regression/jvm/StringTest.java
+++ b/regression/jvm/StringTest.java
@@ -10,6 +10,11 @@ public class StringTest extends TestCase {
String t = "ãã©ã¬ã";
assertEquals(t.length(), 4);
+
+ String p = "\u1234\u5678\uabcd";
+ assertEquals(0x1234, (int)p.charAt(0));
+ assertEquals(0x5678, (int)p.charAt(1));
+ assertEquals(0xabcd, (int)p.charAt(2));
}
public static void testStringConcatenation() {
diff --git a/vm/utf8.c b/vm/utf8.c
index c9caf88..43c8f44 100644
--- a/vm/utf8.c
+++ b/vm/utf8.c
@@ -66,16 +66,16 @@ struct vm_object *utf8_to_char_array(const uint8_t *bytes,
unsigned int n)
}
if ((bytes[i] & 0xe0) == 0xc0) {
- uint16_t ch = (uint16_t) (bytes[i++] & 0x1f) << 6;
- ch += bytes[i++] & 0x3f;
+ uint16_t ch = (uint16_t) (bytes[i] & 0x1f) << 6;
+ ch += bytes[++i] & 0x3f;
array_set_field_char(array, j++, ch);
continue;
}
if ((bytes[i] & 0xf0) == 0xe0) {
- uint16_t ch = (uint16_t) (bytes[i++] & 0xf) << 12;
- ch += (uint16_t) (bytes[i++] & 0x3f) << 6;
- ch += bytes[i++] & 0x3f;
+ uint16_t ch = (uint16_t) (bytes[i] & 0xf) << 12;
+ ch += (uint16_t) (bytes[++i] & 0x3f) << 6;
+ ch += bytes[++i] & 0x3f;
array_set_field_char(array, j++, ch);
continue;
}
--
1.6.0.6
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel