From 008df649f0762714a4394a285034f1144695f360 Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 26 Oct 2018 22:53:19 -0400 Subject: [PATCH] Configurable string charset --- core/src/io/anuke/mindustry/io/TypeIO.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/io/anuke/mindustry/io/TypeIO.java b/core/src/io/anuke/mindustry/io/TypeIO.java index d10b7ef744..b55cee8236 100644 --- a/core/src/io/anuke/mindustry/io/TypeIO.java +++ b/core/src/io/anuke/mindustry/io/TypeIO.java @@ -26,13 +26,14 @@ import io.anuke.ucore.core.Effects.Effect; import io.anuke.ucore.entities.Entities; import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; +import java.nio.charset.Charset; import static io.anuke.mindustry.Vars.*; /** Class for specifying read/write methods for code generation.*/ @SuppressWarnings("unused") public class TypeIO{ + private static final Charset charset = Charset.forName("UTF-8"); @WriteClass(Player.class) public static void writePlayer(ByteBuffer buffer, Player player){ @@ -330,7 +331,7 @@ public class TypeIO{ @WriteClass(String.class) public static void writeString(ByteBuffer buffer, String string){ if(string != null){ - byte[] bytes = string.getBytes(StandardCharsets.UTF_8); + byte[] bytes = string.getBytes(charset); buffer.putShort((short) bytes.length); buffer.put(bytes); }else{ @@ -344,7 +345,7 @@ public class TypeIO{ if(length != -1){ byte[] bytes = new byte[length]; buffer.get(bytes); - return new String(bytes, StandardCharsets.UTF_8); + return new String(bytes, charset); }else{ return null; }