FoldDoubledQuotes (StringTokenizer property): Difference between revisions
mNo edit summary |
m (→Examples) |
||
Line 46: | Line 46: | ||
<li>If <var>[[RemoveQuotes (StringTokenizer property)|RemoveQuotes]]</var> is set to <code>True</code>, folded quotes are removed. | <li>If <var>[[RemoveQuotes (StringTokenizer property)|RemoveQuotes]]</var> is set to <code>True</code>, folded quotes are removed. | ||
</ul> | </ul> | ||
==See also== | ==See also== | ||
{{Template:StringTokenizer:FoldDoubledQuotes footer}} | {{Template:StringTokenizer:FoldDoubledQuotes footer}} |
Revision as of 15:56, 5 July 2012
Doubled quotes treated as escaped quote char (StringTokenizer class)
[Introduced in Sirius Mods 7.8]
FoldDoubledQuotes provides implicit folding of a doubled Quotes character, which is common in User Language but not the default for the StringTokenizer.
Syntax
%currentBoolean = stringTokenizer:FoldDoubledQuotes stringTokenizer:FoldDoubledQuotes = newBoolean
Syntax terms
%currentBoolean | An enumeration object of type Boolean to contain the value of FoldDoubledQuotes. The default value for a new tokenizer instance is False. |
---|---|
stringTokenizer | A StringTokenizer object variable. |
newBoolean | An enumeration object of type Boolean to set the value of FoldDoubledQuotes. |
Usage notes
- The practice of doubling an apostrophe ( ' ) to yield a single apostrophe is common in User Language Print statements. For example, the result of
Print 'Please, don''t go'
is:Please, don't go
The doubled, or escaped, apostrophe is implicitly folded to a single apostrophe. Similarly, if double quotation marks instead of the apostrophes are used to indicate a quoted string (as is allowed as of Sirius Mods version 7.8):
The result is:Print "Please, don""t go"
Please, don"t go
The escaped double quotation mark is implicitly folded to one double quotation mark.
The StringTokenizer, however, does not perform this implicit folding if it encounters a doubled Quotes character within a quoted region. For example:
b %toke is object StringTokenizer %toke = new(quotes='"') %toke:string = '"Please, don""t go"' repeat while %toke:notAtEnd printtext {~} = '{%toke:nextToken}' end repeat end
The result of this request is:
%toke:nextToken = 'Please, don' %toke:nextToken = 't go'
However, if FoldDoubledQuotes is set to True (which is not the default), the tokenizer considers two adjacent Quotes characters within a quoted region that is begun by the same Quotes character to be an escape sequence for a single quotation character, and the result of tokenizing
%toke:string = '"Please, don""t go"'
from the previous request is:Please, don"t go
- If RemoveQuotes is set to
True
, folded quotes are removed.