Skip to content
Permalink
Browse files

Override the charset of bytes in SQLitePersistentStorage

  • Loading branch information...
me4502 committed Jul 6, 2019
1 parent 6b39846 commit 0c50c2fe65223d9fa3493911be0f77b5173b5053
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/main/java/com/sk89q/craftbook/util/persistent/SQLitePersistentStorage.java
@@ -5,6 +5,7 @@
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
@@ -252,7 +253,7 @@ public void importData (Map<String, Object> data, boolean replace) {
}

private static Object fromString(String s) throws IOException, ClassNotFoundException {
byte[] data = s.getBytes();
byte[] data = s.getBytes(StandardCharsets.UTF_8);
BukkitObjectInputStream ois = new BukkitObjectInputStream(new ByteArrayInputStream(data));
Object o = ois.readObject();
ois.close();
@@ -264,6 +265,6 @@ private static String toString(Object o) throws IOException {
BukkitObjectOutputStream oos = new BukkitObjectOutputStream(baos);
oos.writeObject(o);
oos.close();
return new String(baos.toByteArray());
return new String(baos.toByteArray(), StandardCharsets.UTF_8);
}
}

0 comments on commit 0c50c2f

Please sign in to comment.
You can’t perform that action at this time.