1

I have the following idea:

In German we have four extra letters (ä, ö, ü, ß) and I don't know any other language which has these vocals but I think French people with their accents also know this problem. We have a lot of apps in the Google Play store for cities, bus stations, trains and other stuff like that. Now it is really exhausting that we always have to write these letters if we are on the go. It would be much easier to write Munchen (=München [de] = Munich [en]), Osterreich (Österreich [de] = Austria [en]) or something like Uberwasserstrasse (Überwasserstraße [de] = Over-Water-Street [en]). So my question is now:

A lot of apps show suggestions for our just typed word. I think in the code it is something like this:

String current = editText.getText().toString();
db.lookUp(current); // Of course SQL statement

Can we hook this so that Android thinks that we have typed an ä, ö, ü, ß if we write an a, o, u, ss and the system looks for words with one of these vowels and suggests both? Here I do not want to ask for code - I want to discuss if we are able to write a hack or hook for the Android system. Also, root-rights can be assumed with the solution. I'm looking forward to your ideas.

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Cilenco
  • 6,951
  • 17
  • 72
  • 152
  • 2
    To me, the only way to achieve what you are describing is building a custom keyboard. – rciovati Oct 28 '14 at 18:12
  • So I can give different words to the application with an own keyboard? Is maybe a service enought for that? – Cilenco Oct 28 '14 at 19:24
  • Use SwiftKey or any other decent keyboard and it will give you the desired suggestions (Österreich after typing "Oster"). I use SwiftKey because I can use multiple languages at the same time without having to switch between them. – Emanuel Moecklin Oct 29 '14 at 14:07
  • That said I think this question is too broad or not concrete enough to be considered a programming question. – Emanuel Moecklin Oct 29 '14 at 17:46
  • I'm not an Android enthusiast, but I think this might be handy: http://stackoverflow.com/questions/14009261/sqlite-accent-insensitive-search The idea is that your lookup is insensitive to accent and diacritics. This approach makes it possible to go with standard keyboards and character sets. Hope this helps. – Arthur Gevorkyan Nov 04 '14 at 03:11

2 Answers2

1

What you are looking for is called accent-insensitive collating sequence. SQLite's COLLATE operator can be used to do such searches, but I learned from another post that there might be bugs you'll need to look out for.

Community
  • 1
  • 1
Jozua
  • 1,274
  • 10
  • 18
1

You could do this the other way around, by "normalizing" typed characters into their related non-diacritical versions. You can use the java.Text.Normalizer class for this. A good snippet can be found in this article:

public static String removeAccents(String text) {
    return text == null ? null :
        Normalizer.normalize(text, Form.NFD)
            .replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
}

When applied to "Münich", this returns "Munich". That way, you can use a simple string comparison using these normalized versions.

This wouldn't work for "ß" though. If that's the only special case, you could handle it separately.

matiash
  • 54,791
  • 16
  • 125
  • 154