Android due to simple byte on String operation

Why does the following code crash my Android app?

new String("é".getBytes(StandardCharsets.UTF_8), "UTF8") 

or simply

 new String("é".getBytes()) 

How to do it?

Some information:

Error:

08-18 20: 30: 04.877 18914-18924 / com.nextwebart.senego W / google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ### 08-18 20: 30: 04.877 18914-18924 / com.nextwebart.senego W / google-breakpad: fingerprint Chrome build: 08-18 20: 30: 04.877 18914-18924 /com.nextwebart.senego W / google-breakpad: 4.2.8 08-18 20: 30: 04.877 18914-18924 / com.nextwebart.senego W / google-breakpad: 70 08-18 20: 30: 04.877 18914-18924 /com.nextwebart.senego W / google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ## # 08-18 20: 30: 04.877 18914-18924 / com.nextwebart.senego A / libc: fatal signal 11 (SIGSEGV), code 1, error addr 0x5 in tid 18924 (JDWP)

A related question: Encoding Java Strings of characters - for French - Dutch locale

------- EDIT:

This only happens in my Android Studio debugger! Therefore, when I use it as a watch or "evaluate expression". But when I do this in code and then Log.d (...), it works fine !!! Android Studio 2.1.3

I created a problem with Android Studio for this: https://code.google.com/p/android/issues/detail?id=220366

+6
source share
1 answer
 new String("é".getBytes()) 

It works great for me. I tested it with android min API 14. Please check if this can happen on any other problem.

0
source

All Articles