Jump to content

Literals/String: Difference between revisions

m
\u, \U are now properly explained in the official documentation.
(Added TOML)
m (\u, \U are now properly explained in the official documentation.)
Line 1,833:
\t #09 tab
\\ #5C backslash
\" #22 double quote (the \ is optional in ', mandatory in ")
\' #27 single quote (the \ is optional in ", mandatory in ')
\0 #00 null
\#HH #HH any hexadecimal byte
\xHH #HH any hexadecimal byte (\u, \U currently omitted, see note below)
\uH4 - any 16-bit unicode point, eg "\u1234", max #FFFF
\UH8 - any 32-bit unicode point, eg "\U00105678", max #10FFFF
</pre>
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.
Line 1,851 ⟶ 1,853:
string\thing"""
 
ts = '`this
string\thing'`
 
ts = "this\nstring\\thing"</lang>
Line 1,863 ⟶ 1,865:
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>
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}}==
7,813

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.