Skip to content

Instantly share code, notes, and snippets.

@d3x0r
Last active March 5, 2020 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d3x0r/32a48432660968fa249899e934c841e1 to your computer and use it in GitHub Desktop.
Save d3x0r/32a48432660968fa249899e934c841e1 to your computer and use it in GitHub Desktop.
Proposal - Generlize quoted string handling
Document number Nnnnn=yy-nnnn
Date: yyyy-mm-dd
Project Programming Language C++, Library Working Group
Reply-to this document

I. Table of Contents

II. Introduction

  • Allow any character other than a " in quoted strings. The " character itself needs to be escaped \" if included in " to a closing ". All regular escape handling can be done, but other literal characters like '\t' or '\n' that are in the source between quotes should be included as that literal character.

III. Motivation and Scope

  • Allows multiline strings for basically free; although the existing string-constant concatenation handles this in a perhaps more usable way, it could still be nice for including things like SQL scripts with newlines as just copy and paste with only slighty modification, instead of modifying every single line; long text blocks like certificates can also benefit.

IV. Impact On the Standard

  • All valid code previously written still behaves the same way.

V. Design Decisions

  • There's lot a lot of reason to require that the end of a line \r, \r\n or '\n` should cause an error in a string. Well, then again, I work with version control that checks in sources the same as it checks them out; there may be systems that change line endings and cause failures in expected output.

VI. Technical Specifications

  • None Provided

VII. Acknowledgements

  • None known, no previous proposals have been mentioned.

VIII. References

  • C++ 17 Standard draft
  • C11 standard draft

Generalize quoted string handling

Generlize strings to allow any characters in them except themselves, which ahve to be escaped (as now) """ for instance. And then only " and \ are absolutely required to be escaped. (I'm going to say this next part badly) the literal " "test\nwrapped string" " err "test\nwrapped string" (where \n isliterally codepoint 10). Does not break any existing code. Allows multiline strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment