JShell: control characters should be escaped in String values

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P2
    • 9
    • Affects Version/s: 9
    • Component/s: tools
    • None
    • b156
    • Verified

        jshell> String s = "A!\rB!"
        B!"=> "A!

        jshell> String s = "A!\rFOOOOOOOOOOOOOOOOOO"
        FOOOOOOOOOOOOOOOOOO"

        It seems when printing Strings, \r is treated literally as a carriage
        return signal to the shell, which means the next char in the string
        is printed from the beginning of the current line.

        I'm a bit torn: while it's nice that \n (or whichever is native) is
        printed as a new line, maybe it's best (and least bug-prone) to simply
        escape all control characters?

        jshell> String s = "A!\nFOOOOOOOOOOOOOOOOOO"
        s ==> "A!
        FOOOOOOOOOOOOOOOOOO"

        vs

        jshell> String s = "A!\nFOOOOOOOOOOOOOOOOOO"
        s ==> "A!\nFOOOOOOOOOOOOOOOOOO"

              Assignee:
              Robert Field (Inactive)
              Reporter:
              Robert Field (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: