Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2013-03-12 13:41:37 -0400
committerEugene Tarassov2013-03-12 13:41:37 -0400
commit22f01182d00a2374000307694e327af336c34edf (patch)
tree494f6ec3b33f0bd2088d9d0677f9ba2a391f47ab /plugins
parenta3061a15550bdf00af2890ddc2f942386c87d617 (diff)
downloadorg.eclipse.tcf-22f01182d00a2374000307694e327af336c34edf.tar.gz
org.eclipse.tcf-22f01182d00a2374000307694e327af336c34edf.tar.xz
org.eclipse.tcf-22f01182d00a2374000307694e327af336c34edf.zip
TCF Core: JSON.readUTF8Char() - allow reading of 32-bit UNICODE chars
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/protocol/JSON.java41
1 files changed, 27 insertions, 14 deletions
diff --git a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/protocol/JSON.java b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/protocol/JSON.java
index 2c72f747a..160a1aec0 100644
--- a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/protocol/JSON.java
+++ b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/protocol/JSON.java
@@ -135,24 +135,37 @@ public final class JSON {
if (inp_pos >= inp.length) return -1;
int ch = inp[inp_pos++];
if (ch < 0) {
+ int n = 0;
if ((ch & 0xe0) == 0xc0) {
- ch = (ch & 0x1f) << 6;
- ch |= inp[inp_pos++] & 0x3f;
+ ch &= 0x1f;
+ n = 1;
}
else if ((ch & 0xf0) == 0xe0) {
- ch = (ch & 0x0f) << 12;
- ch |= (inp[inp_pos++] & 0x3f) << 6;
- ch |= inp[inp_pos++] & 0x3f;
+ ch &= 0x0f;
+ n = 2;
}
- else if ((ch & 0xf0) == 0xf0) {
- ch = (ch & 0x0f) << 18;
- ch |= (inp[inp_pos++] & 0x3f) << 12;
- ch |= (inp[inp_pos++] & 0x3f) << 6;
- ch |= inp[inp_pos++] & 0x3f;
+ else if ((ch & 0xf8) == 0xf0) {
+ ch &= 0x07;
+ n = 3;
}
- else {
- ch &= 0xff;
+ else if ((ch & 0xfc) == 0xf8) {
+ ch &= 0x03;
+ n = 4;
+ }
+ else if ((ch & 0xfe) == 0xfc) {
+ ch &= 0x01;
+ n = 5;
+ }
+ while (n > 0) {
+ if (inp_pos >= inp.length || (inp[inp_pos] & 0xc0) != 0x80) break;
+ ch = (ch << 6) | (inp[inp_pos++] & 0x3f);
+ n--;
+ }
+ while (n > 0) {
+ ch = ch << 6;
+ n--;
}
+ if (ch < 0) ch = 0;
}
return ch;
}
@@ -277,11 +290,11 @@ public final class JSON {
read();
tmp_buf_pos = 0;
for (;;) {
- if (cur_ch <= 0) error();
+ if (cur_ch < 0) error();
if (cur_ch == '"') break;
if (cur_ch == '\\') {
read();
- if (cur_ch <= 0) error();
+ if (cur_ch < 0) error();
switch (cur_ch) {
case '"':
case '\\':

Back to the top