Skip to content

syntax: add support for C++11 string literals - #4255

Open
Andriamanitra wants to merge 1 commit into
micro-editor:masterfrom
Andriamanitra:c++11-string-literals
Open

Andriamanitra wants to merge 1 commit into
micro-editor:masterfrom
Andriamanitra:c++11-string-literals

Conversation

@Andriamanitra

Copy link
Copy Markdown
Collaborator

https://en.cppreference.com/cpp/language/string_literal

Tags between R" and ( are still not supported because the syntax highlighting system is not advanced enough to do it, and I think omitting it altogether is less likely to cause confusion than a buggy implementation. 1

test.cpp:

const char* raw_multiline = R"(
    This is a multiline raw string.
    " does not close the string.
    Escapes are not interpreted: \n \t \"
)";

// String literals: wide
const wchar_t* wide = L"Wide string";
const wchar_t* wide_raw = LR"(Wide "raw" string)";
const wchar_t* wide_escaped = L"Wide \u03A9 string";

// String literals: UTF-8
const char8_t* utf8 = u8"UTF-8 string";
const char8_t* utf8_raw = u8R"(UTF-8 "raw" string)";
const char8_t* utf8_unicode = u8"Hello, 世界!";

// String literals: UTF-16
const char16_t* utf16 = u"UTF-16 string";
const char16_t* utf16_raw = uR"(UTF-16 "raw" string)";
const char16_t* utf16_unicode = u"\u03A9";

// String literals: UTF-32
const char32_t* utf32 = U"UTF-32 string";
const char32_t* utf32_raw = UR"(UTF-32 "raw" string)";
const char32_t* utf32_unicode = U"\U0001F600";

closes #2064

Footnotes

  1. The tag can contain up to 16 characters from the basic character set, except parentheses, backslash and spaces, and the start tag must match the end tag. We don't have a mechanism to memorize the sequence from the start tag. ↩

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problem in parsing raw string C++

1 participant