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

sprintf breaks encoding on Windows

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.5.6
    • Fix Version/s: None
    • Component/s: groovy-jdk
    • Labels:
      None
    • Environment:
      Windows 10

      Description

       

      On Windows when running groovy from command line this code does not write proper UTF-8 character into the file:

      def out=new PrintStream(new File('test.txt'), 'UTF-8')
      out.println sprintf('%s', '\u0439')"

      while String.format() does it right:

      def out=new PrintStream(new File('test.txt'), 'UTF-8')
      out.println String.format('%s', '\u0439')"

      Now if I add JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8 before groovy command it works properly. But the problem is that sprintf() does not write to output stream so it should keep Unicode character properly encoded without -Dfile.encoding options.

       

       

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              arysin Andriy Rysin
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: