Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

Commit

Permalink
Fixed unicode exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
devjeonghwan committed Nov 7, 2020
1 parent 2bf67b2 commit 9235590
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 42 deletions.
12 changes: 0 additions & 12 deletions .classpath

This file was deleted.

5 changes: 4 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 0 additions & 23 deletions .project

This file was deleted.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ task fatJar(type: Jar) {
}

dependencies {
implementation 'com.github.realtimetech-solution:reflection:0.2.4'
implementation 'com.github.realtimetech-solution:reflection:0.2.7'
}

jar {
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/realtimetech/kson/KsonContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,24 @@ public JsonValue fromString(String kson) throws IOException {
case '\\':
this.stringMaker.add('\\');
break;
case 'u':
char result = 0;
for(int i = 2; i <= 5; i++){
char c = charArray[pointer + i];
result <<= 4;
if (c >= '0' && c <= '9') {
result += (c - '0');
} else if (c >= 'a' && c <= 'f') {
result += (c - 'a' + 10);
} else if (c >= 'A' && c <= 'F') {
result += (c - 'A' + 10);
} else {
throw new IOException("An exception occurred at " + (pointer - 1) + " position character(" + charArray[(pointer - 1)] + ")");
}
}
pointer+=4;
this.stringMaker.add(result);
break;
case 'b':
this.stringMaker.add('\b');
break;
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/com/realtimetech/kson/test/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,5 @@ public void run() {

System.out.println("Kson : " + ((endTime - startTime)) + "ms");
}

while (true) {
Thread.sleep(100000);
}

}
}
3 changes: 3 additions & 0 deletions src/main/java/com/realtimetech/kson/test/TestObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class TestObject {
@Ignore
private byte[] bytes;

private String unicodeString;

private Test[] testArray;

private int[] intArray;
Expand Down Expand Up @@ -197,6 +199,7 @@ public TestObject(Test test) {
this.emptyArray = new String[0];
this.stringArray = new String[] { "A", "B", "C" };
this.string = "ABC";
this.unicodeString = "\u0000\u0001\u0302\u0777\u0000";

this.testInterfaceImpl = new TestInterfaceImpl();
this.testAbstractImpl = new TestAbstractImpl();
Expand Down

0 comments on commit 9235590

Please sign in to comment.