Literals/String: Difference between revisions

Content added Content deleted
(Added TOML)
m (\u, \U are now properly explained in the official documentation.)
Line 1,833: Line 1,833:
\t #09 tab
\t #09 tab
\\ #5C backslash
\\ #5C backslash
\" #22 double quote
\" #22 double quote (the \ is optional in ', mandatory in ")
\' #27 single quote
\' #27 single quote (the \ is optional in ", mandatory in ')
\0 #00 null
\0 #00 null
\#HH #HH any hexadecimal byte
\#HH #HH any hexadecimal byte
\xHH #HH any hexadecimal byte (\u, \U currently omitted, see note below)
\xHH #HH any hexadecimal byte
\uH4 - any 16-bit unicode point, eg "\u1234", max #FFFF
\UH8 - any 32-bit unicode point, eg "\U00105678", max #10FFFF
</pre>
</pre>
There are no other automatic substitutions, other than through explict function calls such as printf.
There are no other automatic substitutions or interpolation, other than through explict function calls such as [s]printf().


Strings can also be entered by using triple quotes or backticks intead of double quotes to include linebreaks and avoid any backslash interpretation.
Strings can also be entered by using triple quotes or backticks intead of double quotes to include linebreaks and avoid any backslash interpretation.
Line 1,851: Line 1,853:
string\thing"""
string\thing"""


ts = 'this
ts = `this
string\thing'
string\thing`


ts = "this\nstring\\thing"</lang>
ts = "this\nstring\\thing"</lang>
Line 1,863: Line 1,865:
Hex string literals are also supported (mainly for compatibility with OpenEuphoria, x/u/U for 1/2/4 byte codes), eg:
Hex string literals are also supported (mainly for compatibility with OpenEuphoria, x/u/U for 1/2/4 byte codes), eg:
<lang Phix>?x"68 65 6c 6c 6f"; -- displays "hello"</lang>
<lang Phix>?x"68 65 6c 6c 6f"; -- displays "hello"</lang>
As noted above, escapes \u and \U are currently omitted from the previous table, but as the source (ptok.e) notes, it is more about testing/documenting than any technical
difficulty handling them in the tokeniser.


=={{header|PHP}}==
=={{header|PHP}}==