8

I've got a problem with Android Estudio, i'm trying to develope an application but the characters like "¿" or "ñ" and "á,é,ó,í,ú" don't appear correctly when i run the application. I've tried to solve the problem changing the encoding to UTF-8 but it doesn't matter nothing different. Can anyone help me? Thanks

4 Answers 4

6

You can solve this problem by using Unicode Characters:

http://javawiki.sowas.com/doku.php?id=java:unicode

Just replace the Number by the respective char you need:

http://unicode-table.com/de/#0115

For Example:

¿ = \u00BF
ñ = \u0148 
á = \u0227
é = \u00E9

Hope this is what u needed ;)

0
5

Instead of having to replace every accent with Unicode character to comply with the project setting of UTF-8, just simply add this line to the Module App Build Grade within android node:

android {

compileOptions.encoding "ISO-8859-1" // For Spanish [Otherwise strange accents]

Then you don't have to modify any of the existing data that you have written and you can keep those strange Spanish characters!

2
  • 1
    your solution doesn't work for me. I have the same issue using french accents.
    – edmond
    Apr 6, 2016 at 13:14
  • perfect! works for all latin languages; see wikipedia at en.wikipedia.org/wiki/ISO/IEC_8859-1
    – infero
    Dec 10, 2016 at 14:43
2

Hey I got the solution

String strJunk = "Atrévete a Soñar";

byte[] arrByteForSpanish = strJunk.getBytes("ISO-8859-1");

String strSpanish = new String(arrByteForSpanish);

I did this and now I am getting Spanish characters correctly instead of junk characters.

1
  • it helped me when the string is coming from the server.
    – Harsh Shah
    Aug 6, 2019 at 9:56
0

in bild.gradle(app model) use this configuration:

android {
compileOptions.encoding = 'ISO-8859-1' // write your encoding here
compileSdkVersion 25...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.