Putting quotes in wysiwyg strings
Bill Baxter
dnewsgroup at billbaxter.com
Wed Nov 22 00:01:15 PST 2006
From the spec: 'There are no escape sequences inside r" ":'
Shouldn't there be an exception for the " character itself?
Right now the only way to put the quote into a wysiwyg string like
foo"bar
is something like:
r"foo" ~'"'~ r"bar";
or
r"foo" "\"" r"bar";
or
r"foo" `"` r"bar";
It would be a lot nicer if one could just do:
r"foo\"bar";
And before you say I should just use ``, I'm writing an automatic
resource wrapper that turns any text file into an embedded string, so I
don't know ahead of time what's going to be in the string, and it may
contain both `'s and "'s.
The goal is that the output string should look as much like the original
text as possible. One main use will be for embedding short script
programs (like lua or minid) inside a D executable.
This:
if (k & e.Shift) { ret ~= " `"` r"Shift" `"` r"; }
if (k & e.Ctrl) { if (ret) ret~=" `"` r"|" `"` r"; ret ~= " `"`
r"Ctrl" `"` r"; }
if (k & e.Alt) { if (ret) ret~=" `"` r"|" `"` r"; ret ~= " `"`
r"Alt" `"`
r"; }
if (!ret) ret = " `"` r"None" `"` r";
definitely does not look very much like the original code. :-(
But this does look reasonably close:
if (k & e.Shift) { ret ~= \"Shift\"; }
if (k & e.Ctrl) { if (ret) ret~=\"|\"; ret ~= \"Ctrl\"; }
if (k & e.Alt) { if (ret) ret~=\"|\"; ret ~= \"Alt\"; }
if (!ret) ret = \"None\";
--bb
More information about the Digitalmars-d
mailing list