From e7ee6f3ae480b9464734403d885d9cf519f83599 Mon Sep 17 00:00:00 2001 From: crykn Date: Sun, 20 Sep 2020 21:36:33 +0200 Subject: [PATCH] Remove Charset stuff. Should fix #1. --- build.gradle | 2 +- .../de/damios/guacamole/gdx/assets/Text.java | 20 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index f306233..c9ed8ca 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ allprojects { apply plugin: "eclipse" apply plugin: "idea" - version = "0.2.0" + version = "0.2.2" ext { appName = "guacamole" formicVersion = "0.1.4" diff --git a/gdx/src/main/java/de/damios/guacamole/gdx/assets/Text.java b/gdx/src/main/java/de/damios/guacamole/gdx/assets/Text.java index 5f3ed34..9c0e27d 100644 --- a/gdx/src/main/java/de/damios/guacamole/gdx/assets/Text.java +++ b/gdx/src/main/java/de/damios/guacamole/gdx/assets/Text.java @@ -15,13 +15,13 @@ package de.damios.guacamole.gdx.assets; -import java.nio.charset.Charset; +import java.io.UnsupportedEncodingException; import com.badlogic.gdx.files.FileHandle; /** * A simple asset type for text files. Uses the UTF-8-encoding if supported by - * the local JVM. + * the local JVM; the platform's default encoding otherwise. * * @author damios * @see TextLoader The respective asset loader. @@ -30,17 +30,23 @@ */ public class Text { - private static final Charset CHARSET = Charset.isSupported("UTF-8") - ? Charset.forName("UTF-8") - : Charset.defaultCharset(); + private static final String CHARSET = "UTF-8"; // Charset.defaultCharset() etc. is not supported on GWT private String string; public Text(String string) { - this.string = new String(string.getBytes(), CHARSET); + this(string.getBytes()); } public Text(FileHandle file) { - this(new String(file.readBytes(), CHARSET)); + this(file.readBytes()); + } + + public Text(byte[] bytes) { + try { + this.string = new String(bytes, CHARSET); + } catch (UnsupportedEncodingException e) { + this.string = new String(bytes); + } } /**