From ff32764375f5eb9da46985df3b787cf458f07764 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 2 Sep 2016 09:43:38 +0200 Subject: [PATCH] remove accents in SMS --- .idea/misc.xml | 2 +- .../plugins/SmsCommunicator/SmsCommunicatorPlugin.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index fbb68289f4..5d19981032 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -37,7 +37,7 @@ - + diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java index 71963ff219..4f18516349 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java @@ -12,6 +12,7 @@ import com.squareup.otto.Subscribe; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.text.Normalizer; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -226,11 +227,16 @@ public class SmsCommunicatorPlugin implements PluginBase { bolusWaitingForConfirmation = null; newSms.processed = true; } - smsManager.sendTextMessage(newSms.phoneNumber, null, newSms.text, null, null); + smsManager.sendTextMessage(newSms.phoneNumber, null, stripAccents(newSms.text), null, null); messages.add(newSms); } MainApp.bus().post(new EventSmsCommunicatorUpdateGui()); } - + public static String stripAccents(String s) + { + s = Normalizer.normalize(s, Normalizer.Form.NFD); + s = s.replaceAll("[\\p{InCombiningDiacriticalMarks}]", ""); + return s; + } }