Backslash Line Continuation is interpretted literally

  • Thom A

    SSC Guru

    Points: 98406

    When writing, use of the \ characters, followed by a Line Break/Carriage Return & Line Break will be read by SSC as a line continuation. This means that you can't actually display this syntax to others.

    Here are a few tests: The screen shot of how it looks in the editor and then below will be how it is now displayed:

    This is followed by

    a line continuation

    /*
    There is a linecontinuation in this
    */

    'A literal stringwith continuation'

    --Binary value
    0x123456DEFABC

    --Number
    123456123456

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.

  • Thom A

    SSC Guru

    Points: 98406

    Appears this "feature" only occurs in Code Snippets, however, note that the \ is missing from the line outside of the code snippet.

    Will test using \\ now:

    This has a double\

    backslash

    /*
    Comments with a double\backslash
    */

    'Literal String with a\double backslash'

    --Binary
    0x123456\DEFABC

    --Number
    12345\456789

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.

  • Thom A

    SSC Guru

    Points: 98406

    To add context, I'm trying to submit a QOTD about Backslash (Line Continuation) behaviour and I can't, as the question content becomes "malformed" due to the Backslash (Line Continuation) characters being literally interpreted with seemingly no way to override them.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.

  • MVDBA (Mike Vessey)

    SSC-Insane

    Points: 21010

    looks like it might be that the web control is trying to protect against HTML injection and forcing you to double escape the backslash

    it's fairly common

    very similar to the concept of using dynamic sql and not letting the user put ;-- in an input string

    MVDBA

  • Thom A

    SSC Guru

    Points: 98406

    MVDBA (Mike Vessey) wrote:

    looks like it might be that the web control is trying to protect against HTML injection and forcing you to double escape the backslash

    it's fairly common

    very similar to the concept of using dynamic sql and not letting the user put ;-- in an input string

    The problem is that doubling up the backslash doesn't actually work either, as can be seen above. If it was as simple as that (and when I editted the post the double backslash was displayed to me) I wouldn't have posted this an an issue. In the example above ,using 2 blackslashes, the first backslash is clearly being ignored as it's not escaping the second. If it were correctly escaping the \, then Comments with a double\backslash would have been on 2 lines, not one.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.

  • Thom A

    SSC Guru

    Points: 98406

    Also, as a result the the behaviour, the QOTD I want to send is literally impossible to write, as the question becomes entire malformed.

    I have, however, attempted to guess it'll format correctly, however, impossible to verify and the question never loads:

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.

  • Steve Jones - SSC Editor

    SSC Guru

    Points: 716216

    I'll submit a bug. About to jump on a plane, so can't really test this minute.

  • Solomon Rutzky

    SSCoach

    Points: 16135

    SIMPLE TEST

    This is a test\of line continuation (outside of a code block)

     

    This is a testof line continuation (inside a code block)

     


    SPACE AFTER BACKSLASH TEST

    This is a test\of line continuation (outside of a code block)

     

    This is a test\ 
    of line continuation (inside a code block)

     


    HTML ESCAPE INSTEAD OF LITERAL BACKSLASH TEST

    This is a test\\

    of line continuation (outside of a code block)

     

    This is a test\
    of line continuation (inside a code block)

     

    SQL#https://SQLsharp.com/ ( SQLCLR library ofover 340 Functions and Procedures)
    Sql Quantum Lifthttps://SqlQuantumLift.com/ ( company )
    Sql Quantum Leaphttps://SqlQuantumLeap.com/ ( blog )
    Info sitesCollations     •     Module Signing     •     SQLCLR

  • Solomon Rutzky

    SSCoach

    Points: 16135

    For my test (immediately) above, I used double-backslashes outside of the code block because that seemed to work for O.P. The tests seem to indicate that within a code block, you can either put a space after the backslash, or use the HTML escape sequence of " \ ". I used two of the HTML escapes in the 3rd test to be consistent with using two backslashes outside of the code block, so that is why it shows up twice.

    The implication is that using the HTML escape sequence is better as it works in both cases, but in reality, there is a huge caveat to using any HTML escape sequence on this new site: they only work heading into the system the first time. If you ever edit that article / post / question, etc, then that escape sequence will be translated into the actual character it represents, such that saving the second time will put you right back where you started with using the literal backslash (or whatever other character that is not on code page Windows-1252). So, you can use the HTML escape sequence, you just need to make sure that if you ever edit an item (article, post, etc) with them, you translate their character representations back into the escape sequence before saving.

     

    Take care,

    Solomon...

     

    SQL#https://SQLsharp.com/ ( SQLCLR library ofover 340 Functions and Procedures)
    Sql Quantum Lifthttps://SqlQuantumLift.com/ ( company )
    Sql Quantum Leaphttps://SqlQuantumLeap.com/ ( blog )
    Info sitesCollations     •     Module Signing     •     SQLCLR

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply