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

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

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.4.0-beta-3, 2.4.0-beta-4
    • 2.3.10, 2.4.0-rc-2
    • Android
    • None
    • 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

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            melix Cédric Champeau
            gazer Ricardo Markiewicz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment