0

I have a spinner with accents string

<string-array name="typelist">
        <item>Médicament</item>
        <item>Pharmacie</item>
    </string-array>

When I insert them in the database, they are added with weird characters

final String drop = typelist.getSelectedItem().toString();

How can I correct this error please

Lara Fab
  • 33
  • 7

1 Answers1

-1

Please check following code

it works for me

My be it help you

this is my string

String string = "éàù";

Solution

  string = Normalizer.normalize(string, Normalizer.Form.NFD);
        string = string.replaceAll("[^\\p{ASCII}]", "");

        Toast.makeText(SplashActivity.this, string, Toast.LENGTH_SHORT).show();

Output

enter image description here

Sachin
  • 1,307
  • 13
  • 23