Android Question How to detect accent characters in a text box?

Inman

Well-Known Member
Licensed User
Longtime User
In my app, some users enter their names using accent characters. Basically these are the characters you get when you long-press certain letters. Like when you do that on 'a', you can see some characters like 'a' with two dots on top and all. I want to check if a field contains one or more of such characters and show an error message.

I saw the code snippet that removes accent characters. What is the way to detect them?

iphone-accents-5953ebde3df78c1d427b96a8.jpg
 

Geezer

Active Member
Licensed User
Longtime User
If they're entering their names in an edittext you can set allowable characters and restrict the input.

If the names already exist, such as in a database, use the code snippet you referenced.
 
Upvote 0

Inman

Well-Known Member
Licensed User
Longtime User
Thanks @Geezer . How do I set allowable characters for EditText? I can see InputType but it doesn't seem to have a type for English characters only.
 
Upvote 0

Inman

Well-Known Member
Licensed User
Longtime User
While it is a good solution, unfortunately it won't work in my case. IME library works only with EditText and I am using DSFloatLabelEditText. I get an "incompatible types" error during compilation.

I am wondering if I should look at regex to check for such characters. Sadly I am not good with regex.
 
Upvote 0
Top