mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
Fixed reading UTF8.
This commit is contained in:
parent
709e2dafcb
commit
8c55aa1f62
@ -32,6 +32,7 @@
|
|||||||
package com.esotericsoftware.spine;
|
package com.esotericsoftware.spine;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
@ -104,8 +105,9 @@ public class SkeletonBinary {
|
|||||||
SkeletonData skeletonData = new SkeletonData();
|
SkeletonData skeletonData = new SkeletonData();
|
||||||
skeletonData.name = file.nameWithoutExtension();
|
skeletonData.name = file.nameWithoutExtension();
|
||||||
|
|
||||||
|
final Charset utf8 = Charset.forName("UTF-8");
|
||||||
DataInput input = new DataInput(file.read(512)) {
|
DataInput input = new DataInput(file.read(512)) {
|
||||||
private char[] chars = new char[32];
|
private byte[] bytes = new byte[32];
|
||||||
|
|
||||||
public String readString () throws IOException {
|
public String readString () throws IOException {
|
||||||
int byteCount = readInt(true);
|
int byteCount = readInt(true);
|
||||||
@ -116,33 +118,9 @@ public class SkeletonBinary {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
byteCount--;
|
byteCount--;
|
||||||
if (chars.length < byteCount) chars = new char[byteCount];
|
if (bytes.length < byteCount) bytes = new byte[byteCount];
|
||||||
int charCount = 0;
|
readFully(bytes, 0, byteCount);
|
||||||
for (int i = 0; i < byteCount; i++, charCount++) {
|
return new String(bytes, 0, byteCount, utf8);
|
||||||
int b = read();
|
|
||||||
switch (b >> 4) {
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
case 3:
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
case 6:
|
|
||||||
case 7:
|
|
||||||
chars[charCount] = (char)b;
|
|
||||||
break;
|
|
||||||
case 12:
|
|
||||||
case 13:
|
|
||||||
chars[charCount] = (char)((b & 0x1F) << 6 | read() & 0x3F);
|
|
||||||
i++;
|
|
||||||
break;
|
|
||||||
case 14:
|
|
||||||
chars[charCount] = (char)((b & 0x0F) << 12 | (read() & 0x3F) << 6 | read() & 0x3F);
|
|
||||||
i += 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new String(chars, 0, charCount);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user