diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java index 9dbf3c6ac..76ceaf43d 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java @@ -32,6 +32,7 @@ package com.esotericsoftware.spine; import java.io.IOException; +import java.nio.charset.Charset; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Color; @@ -104,8 +105,9 @@ public class SkeletonBinary { SkeletonData skeletonData = new SkeletonData(); skeletonData.name = file.nameWithoutExtension(); + final Charset utf8 = Charset.forName("UTF-8"); DataInput input = new DataInput(file.read(512)) { - private char[] chars = new char[32]; + private byte[] bytes = new byte[32]; public String readString () throws IOException { int byteCount = readInt(true); @@ -116,33 +118,9 @@ public class SkeletonBinary { return ""; } byteCount--; - if (chars.length < byteCount) chars = new char[byteCount]; - int charCount = 0; - for (int i = 0; i < byteCount; i++, charCount++) { - 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); + if (bytes.length < byteCount) bytes = new byte[byteCount]; + readFully(bytes, 0, byteCount); + return new String(bytes, 0, byteCount, utf8); } }; try {