Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upadds new logical 'escape' parameter for switching on/off escaping special … #27
Conversation
…characters in strings
Codecov Report
@@ Coverage Diff @@
## master #27 +/- ##
==========================================
+ Coverage 60.51% 60.56% +0.05%
==========================================
Files 3 3
Lines 1332 1334 +2
==========================================
+ Hits 806 808 +2
Misses 526 526
Continue to review full report at Codecov.
|
|
That looks really promising -- I was busy yesterday and only glanced at but realized the same approach: new boolean toggle we need to pass through 'all the way'. Only minor quip I have may be to possibly renamed the variable to |
|
Yes, naming is hard :-) May also be The thing is that maybe we should, for the sake of consistency, cover the other symbols with special treatment in TOML as well. From TOML spec:
"...All other escape sequences not listed above are reserved and, if used, TOML should produce an error." |
|
Hm. So you mean expand this // this function is borrowed with credits from cpptoml :)
std::string escapeString(const std::string& str) {
std::string res;
for (auto it = str.begin(); it != str.end(); ++it) {
if (*it == '\\')
res += "\\\\";
else if (*it == '"')
res += "\\\"";
else if (*it == '\n')
res += "\\n";
else
res += *it;
}
return res;
}to cover other chars? Maybe. Less pressing though as ... they are even less frequently used? |
|
Yes, it is definitely not urgent. There is one more strange thing concerning line breaks. From spec: A newline immediately following the opening delimiter will be trimmed. All other content between the delimiters is interpreted as-is without modification. but
So any first new line symbol is trimmed even if it is not the first char in the input string. But this seems to be attributed to Edit: copy-paste mistake in the R code |
|
Correction, I should write:
|
|
Hm. Upstream does not seem to do anything special either. Or am I missing something? edd@rob:~/git/cpptoml/examples(master)$ echo "value = '''Hello\nWorld'''" | ./parse_stdin_2018-10-22
{"value":{"type":"string","value":"Hello\\nWorld"}}
edd@rob:~/git/cpptoml/examples(master)$ echo "value = '''\nHello\nWorld'''" | ./parse_stdin_2018-10-22
{"value":{"type":"string","value":"\\nHello\\nWorld"}}
edd@rob:~/git/cpptoml/examples(master)$ |
|
I am surprised as well. This "upstream" means some CLI tools based on Well, that's interesting. I don't see any postprocessing of line breaks in |
|
I will open this as a new issue and will try to finish the #26 first, if you agree. So, which one do you prefer? |
|
I think we can still take this PR and I'll merge it now. And yes, upstream aka |
Should solve the GitHub issue #26 .
Haven't written any c++ in ages so please double-check the c++ side of the changes.