Android Studio does not display English characters correctly

Asked

Viewed 842 times

2

My project is not displaying any English characters correctly. When I display a string as "no", it displays "no".

The strange thing is, when I call the string straight from the res/string.xml, it works properly. Does anyone have any idea why? I’ve asked at Stackoverflow gringo and no one has been able to answer me.

What I’ve tried so far:

File -> Settings -> Editor -> File Encondings, I put everything UTF-8 and even some others, dei rebuild/clean in the project and nothing, still the same.

If necessary, I can record a video and upload to Youtube to show!

EDIT:

inserir a descrição da imagem aqui

  • 1

    This seems to be what happens when you read multiple bytes and convert each byte individually to character, ignoring the fact that some characters need more than one byte to be encoded. Can you tell more in depth what is the procedure that generates these strings and what it does? If possible post his code.

  • Hello! thanks for the reply. I posted an image as example!

  • It happens at all times that I will display any type of text on the screen except for the /res/strings.xml

  • Dear friend, a question... You are using Linux?

1 answer

1

Hence it seems that this is what happens when you read multiple bytes and convert each byte individually to character, ignoring the fact that some characters need more than one byte to be encoded.

Since even the strings in your source code are being corrupted and the source code is in UTF-8, try to pass -encoding UTF-8 as command line parameters for the java compiler. For example:

javac -encoding UTF-8 SuaClasse.java
  • Hello friend, thanks for the reply! I’m getting the following error when I apply the code on the terminal of android studio: '-encoding' is not recognized as an internal & #Xa; or external command, a operable program, or a batch file. I’m doing something wrong?

  • @Diegoforts Yes, it is a command line parameter of javac, and not the command itself. I updated the answer, although my example should be too simplistic.

  • I’m sorry, but I’m pretty layy when it comes to command lines. I should use windows CMD or the IDE itself?

  • You can search your IDE to put this as a parameter for the compiler.

  • still having the same problem :\

  • @Diegoforts So, I don’t know. :\

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.