mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-01 06:22:55 +01:00
HPlus: Fix Unicode handling
This commit is contained in:
parent
845869e25e
commit
759b9c81a3
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -808,6 +808,8 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||
private byte[] encodeStringToDevice(String s) {
|
||||
|
||||
List<Byte> outBytes = new ArrayList<Byte>();
|
||||
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++)
|
||||
|
Loading…
Reference in New Issue
Block a user