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

GStringTemplateEngine doesn't preserve new line chars (\r\n) on windows

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Not A Problem
    • 1.6.1
    • None
    • Templating
    • None
    • windows xp sp3, groovy 1.6.1

    Description

      Executing following lines

      String templateString = "First line \r\nSecond line"
      def template = new GStringTemplateEngine().createTemplate(templateString).make()
      		 
      println templateString.bytes
      println template.toString().bytes
      println System.getProperty("line.separator").getBytes()
      

      prints

      [70, 105, 114, 115, 116, 32, 108, 105, 110, 101, 32, 13, 10, 83, 101, 99, 111, 110, 100, 32, 108, 105, 110, 101]
      [70, 105, 114, 115, 116, 32, 108, 105, 110, 101, 32, 10, 83, 101, 99, 111, 110, 100, 32, 108, 105, 110, 101]
      [13, 10]
      

      As you can see second byte array is shorter then first one. Is this expected behavior or this is a bug?

      Attachments

        Activity

          People

            paulk Paul King
            mresetar Miroslav ReĀšetar
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: