diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusCoordinator.java index e99123bcd..b3e6a4a4f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusCoordinator.java @@ -289,6 +289,6 @@ public class HPlusCoordinator extends AbstractDeviceCoordinator { } public static boolean getUnicodeSupport(String address){ - return (prefs.getBoolean(HPlusConstants.PREF_HPLUS_UNICODE, false)); + return (prefs.getBoolean(HPlusConstants.PREF_HPLUS_UNICODE + "_" + address, false)); } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusSupport.java index b265ff379..06ba110dc 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusSupport.java @@ -808,6 +808,8 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport { private byte[] encodeStringToDevice(String s) { List outBytes = new ArrayList(); + Boolean unicode = HPlusCoordinator.getUnicodeSupport(this.gbDevice.getAddress()); + LOG.info("Encode String: Unicode=" + unicode); for (int i = 0; i < s.length(); i++) { Character c = s.charAt(i); @@ -818,12 +820,14 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport { } else { try { if(HPlusCoordinator.getUnicodeSupport(this.gbDevice.getAddress())) + if(unicode) cs = c.toString().getBytes("Unicode"); else cs = c.toString().getBytes("GB2312"); } catch (UnsupportedEncodingException e) { //Fallback. Result string may be strange, but better than nothing cs = c.toString().getBytes(); + LOG.error("Could not convert String to Bytes: " + e.getMessage()); } } for (int j = 0; j < cs.length; j++)