Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7229

Charset.toString() returns incompatible name for Charset.forName on Android

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4.0-beta-3, 2.4.0-beta-4
    • Fix Version/s: 2.3.10, 2.4.0-rc-2
    • Component/s: Android
    • Labels:
      None
    • Environment:
      Android 4.4.4, groovy:2.4.0-beta-4

      Description

      Trying to use new URL('http://google.com').text fails with :

      Caused by: java.nio.charset.IllegalCharsetNameException: java.nio.charset.CharsetICU[UTF-8]
      at java.nio.charset.Charset.checkCharsetName(Charset.java:201)
      at java.nio.charset.Charset.forName(Charset.java:295)
      at java.io.InputStreamReader.<init>(InputStreamReader.java:85)
      at org.codehaus.groovy.runtime.ResourceGroovyMethods.newReader(ResourceGroovyMethods.java:2064)

      On Android, the Charset#toString prepend the class name on the returned string and thats break Charset.fromName used later to create the reader.

      Log.d("Charset", "toString() : " + CharsetToolkit.getDefaultSystemCharset().toString());
      Log.d("Charset", "displayName() : " + CharsetToolkit.getDefaultSystemCharset().displayName());
      Log.d("Charset", "name() : " + CharsetToolkit.getDefaultSystemCharset().name());

      Output :

      D/Charset﹕ toString() : java.nio.charset.CharsetICU[UTF-8]
      D/Charset﹕ displayName() : UTF-8
      D/Charset﹕ name() : UTF-8

      This was tested on Android 4.4.4.

        Attachments

          Activity

            People

            • Assignee:
              melix C├ędric Champeau
              Reporter:
              gazer Ricardo Markiewicz
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: