From: Niki Roo Date: Thu, 3 Mar 2016 10:13:17 +0000 (+0100) Subject: Fix UTF8 bug, create first executable JAR file X-Git-Tag: v1.0-beta1 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=d66e24cca3ce3d2dc683358b4bcc99593900e77f;p=jvcard.git Fix UTF8 bug, create first executable JAR file --- diff --git a/jvcard-1.0-beta1.jar b/jvcard-1.0-beta1.jar new file mode 100644 index 0000000..38abb59 Binary files /dev/null and b/jvcard-1.0-beta1.jar differ diff --git a/src/be/nikiroo/jvcard/tui/Main.java b/src/be/nikiroo/jvcard/tui/Main.java index a0357be..eda0c69 100644 --- a/src/be/nikiroo/jvcard/tui/Main.java +++ b/src/be/nikiroo/jvcard/tui/Main.java @@ -2,6 +2,8 @@ package be.nikiroo.jvcard.tui; import java.io.File; import java.io.IOException; +import java.lang.reflect.Field; +import java.nio.charset.Charset; import java.util.LinkedList; import java.util.List; @@ -32,7 +34,7 @@ import com.googlecode.lanterna.terminal.Terminal; */ public class Main { public static final String APPLICATION_TITLE = "jVcard"; - public static final String APPLICATION_VERSION = "1.0-beta1-dev"; + public static final String APPLICATION_VERSION = "1.0-beta2-dev"; static private Trans transService; @@ -45,7 +47,6 @@ public class Main { * @return the translation */ static public String trans(StringId id) { - if (transService == null) return ""; @@ -119,6 +120,10 @@ public class Main { } } + if (UiColors.getInstance().isUnicode()) { + utf8(); + } + if (files.size() == 0) { if (filesTried) { System.exit(1); @@ -167,6 +172,20 @@ public class Main { return files; } + /** + * Really, really ask for UTF-8 encoding. + */ + static private void utf8() { + try { + System.setProperty("file.encoding", "UTF-8"); + Field charset = Charset.class.getDeclaredField("defaultCharset"); + charset.setAccessible(true); + charset.set(null, null); + } catch (SecurityException | NoSuchFieldException + | IllegalArgumentException | IllegalAccessException e) { + } + } + static private void fullTestTable() throws IOException { final Table table = new Table("Column 1", "Column 2", "Column 3");