41

What is the default character encoding of the Android system? Which Charset is used?

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263
Arutha
  • 26,088
  • 26
  • 67
  • 80

1 Answers1

58

The default character encoding for Android is UTF-8, as specified by the JavaDoc of the Charset.defaultCharset() method. It can be validated by calling that same method.

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
pgsandstrom
  • 14,361
  • 13
  • 70
  • 104
  • 3
    Fortunately, you don't need to run a program to verify it's UTF-8. The documentation for that method states it outright: http://developer.android.com/reference/java/nio/charset/Charset.html#defaultCharset() – Jay Lieske Jan 18 '14 at 18:12
  • 2
    @JayLieske If you want UTF-8 you're still better off by [indicating the encoding directly](https://developer.android.com/reference/java/nio/charset/StandardCharsets.html#UTF_8). That makes the code more portable, and it would protect you against changes of the Android system. – Maarten Bodewes Aug 06 '14 at 12:03
  • 3
    Actually the android developper website says that String objects are using UTF-16, so what do we mean by android default encoding ? the encoding used in strings for applications or something else ? – Virus721 Apr 30 '15 at 15:15
  • 1
    @pgsandstrom Where do you see default mentioned as UTF-8? The provided link doesn't say that! – rpattabi Aug 15 '16 at 23:29
  • @Virus721 actually strings are Unicode UTF-16 is a character encoding, just like UTF-8 or ASCII. There is an explicit process for converting bytes into the language's String type: the encoding. – escape-llc Oct 12 '16 at 12:10
  • 3
    provided link now tells that `defaultCharset` > Android note: The Android platform default is always UTF-8. – xAqweRx May 09 '17 at 12:37