HPlus: Improve transliteration

master
João Paulo Barraca 2017-04-27 00:18:46 +01:00
parent 41ecd4e7d6
commit 58cb73a756
2 changed files with 52 additions and 51 deletions

View File

@ -130,60 +130,61 @@ public final class HPlusConstants {
public static final String PREF_HPLUS_SIT_START_TIME = "hplus_sit_start_time"; public static final String PREF_HPLUS_SIT_START_TIME = "hplus_sit_start_time";
public static final String PREF_HPLUS_SIT_END_TIME = "hplus_sit_end_time"; public static final String PREF_HPLUS_SIT_END_TIME = "hplus_sit_end_time";
public static final Map<Character, Byte> transliterateMap = new HashMap<Character, Byte>(){ public static final Map<Character, byte[]> transliterateMap = new HashMap<Character, byte[]>(){
{ {
//These are missing //These are missing
put('ó', (byte) 111); put('ó', new byte[]{(byte) 111});
put('Ó', (byte) 79); put('Ó', new byte[]{(byte) 79});
put('í', (byte) 105); put('í', new byte[]{(byte) 105});
put('Í', (byte) 73); put('Í', new byte[]{(byte) 73});
put('ú', (byte) 117); put('ú', new byte[]{(byte) 117});
put('Ú', (byte) 85); put('Ú', new byte[]{(byte) 85});
//These mostly belong to the extended ASCII table //These mostly belong to the extended ASCII table
put('Ç', (byte) 128); put('Ç', new byte[]{(byte) 128});
put('ü', (byte) 129); put('ü', new byte[]{(byte) 129});
put('é', (byte) 130); put('é', new byte[]{(byte) 130});
put('â', (byte) 131); put('â', new byte[]{(byte) 131});
put('ä', (byte) 132); put('ä', new byte[]{(byte) 132});
put('à', (byte) 133); put('à', new byte[]{(byte) 133});
put('ã', (byte) 134); put('ã', new byte[]{(byte) 134});
put('ç', (byte) 135); put('ç', new byte[]{(byte) 135});
put('ê', (byte) 136); put('ê', new byte[]{(byte) 136});
put('ë', (byte) 137); put('ë', new byte[]{(byte) 137});
put('Ï', (byte) 139); put('Ï', new byte[]{(byte) 139});
put('è', (byte) 138); put('è', new byte[]{(byte) 138});
put('Î', (byte) 140); put('Î', new byte[]{(byte) 140});
put('Ì', (byte) 141); put('Ì', new byte[]{(byte) 141});
put('Ã', (byte) 142); put('Ã', new byte[]{(byte) 142});
put('Ä', (byte) 143); put('Ä', new byte[]{(byte) 143});
put('É', (byte) 144); put('É', new byte[]{(byte) 144});
put('æ', (byte) 145); put('æ', new byte[]{(byte) 145});
put('Æ', (byte) 146); put('Æ', new byte[]{(byte) 146});
put('ô', (byte) 147); put('ô', new byte[]{(byte) 147});
put('ö', (byte) 148); put('ö', new byte[]{(byte) 148});
put('ò', (byte) 149); put('ò', new byte[]{(byte) 149});
put('û', (byte) 150); put('û', new byte[]{(byte) 150});
put('ù', (byte) 151); put('ù', new byte[]{(byte) 151});
put('ÿ', (byte) 152); put('ÿ', new byte[]{(byte) 152});
put('Ö', (byte) 153); put('Ö', new byte[]{(byte) 153});
put('Ü', (byte) 154); put('Ü', new byte[]{(byte) 154});
put('¢', (byte) 155); put('¢', new byte[]{(byte) 155});
put('£', (byte) 156); put('£', new byte[]{(byte) 156});
put('¥', (byte) 157); put('¥', new byte[]{(byte) 157});
put('ƒ', (byte) 159); put('ƒ', new byte[]{(byte) 159});
put('á', (byte) 160); put('á', new byte[]{(byte) 160});
put('ñ', (byte) 164); put('ñ', new byte[]{(byte) 164});
put('Ñ', (byte) 165); put('Ñ', new byte[]{(byte) 165});
put('ª', (byte) 166); put('ª', new byte[]{(byte) 166});
put('º', (byte) 167); put('º', new byte[]{(byte) 167});
put('¿', (byte) 168); put('¿', new byte[]{(byte) 168});
put('¬', (byte) 170); put('¬', new byte[]{(byte) 170});
put('½', (byte) 171); put('½', new byte[]{(byte) 171});
put('¼', (byte) 172); put('¼', new byte[]{(byte) 172});
put('¡', (byte) 173); put('¡', new byte[]{(byte) 173});
put('«', (byte) 174); put('«', new byte[]{(byte) 174});
put('»', (byte) 175); put('»', new byte[]{(byte) 175});
put('°', new byte[]{(byte) 0xa1, (byte) 0xe3});
} }
}; };
} }

View File

@ -806,7 +806,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
byte[] cs; byte[] cs;
if (HPlusConstants.transliterateMap.containsKey(c)) { if (HPlusConstants.transliterateMap.containsKey(c)) {
cs = new byte[]{HPlusConstants.transliterateMap.get(c)}; cs = HPlusConstants.transliterateMap.get(c);
} else { } else {
try { try {
if (HPlusCoordinator.getLanguage(this.gbDevice.getAddress()) == HPlusConstants.ARG_LANGUAGE_CN) if (HPlusCoordinator.getLanguage(this.gbDevice.getAddress()) == HPlusConstants.ARG_LANGUAGE_CN)