"Sputnik" help  
Sputnik Help
Language Reference - Datatypes - Strings (Escapes)

Strings (Escapes)

Sputnik supports a wide variety of string escapes from the likes of C, C++, C#, Perl, PHP etc.

Here is a full list of all Sputniks string escapes:

Escape          Represents
\$              Dollar sign
\@              At Sign
\a              Bell (alert)
\b              Backspace
\f              Formfeed
\n              New line
\m              New line or <BR> depending if CGI mode has been set
\r              Carriage return
\t              Horizontal tab
\v              Vertical tab
\s              Space
\'              Single quotation mark
\"              Double quotation mark
\\              Backslash
\?              Literal question mark
\xhh            ASCII character in hexadecimal notation (Expects 2 digits)
\xhhhh          UNICODE character in hexadecimal notation (Expects 4 digits)
\ohhh           ASCII character in octal notation (Expects 3 digits)
\uhhhh          UNICODE character in hexadecimal notation (Expects 4 digits)
\Uhhhhhhhh      UNICODE character in hexadecimal notation (Expects 8 digits first four must be 0000)
\U(h*)          ASCII/UNICODE character in hexadecimal notation (Accepts any valid amount of digits)
\u(h*)          ASCII/UNICODE character in hexadecimal notation (Accepts any valid amount of digits)
\x(h*)          ASCII/UNICODE character in hexadecimal notation (Accepts any valid amount of digits)
\o(h*)          ASCII/UNICODE character in octal notation (Accepts any valid amount of digits)
\L              Transform all following letters to lowercase
\l              Transform the next letter to lowercase
\I              Transform all following letters to uppercase
\i              Transform the next letter to uppercase
\K              Transform all following letters to the opposite case
\Q              Do not match the following patterns (such as \n \r etc)
\E              Ends \I, \L, \l, \i, \K or \Q functions
\|              Nothing - This sequence outputs nothing useful for stuff like $Cat\|Dog to avoid $Cat being $CatDog
\_              Outputs _
\{              Outputs {
\[              Outputs [
{               The following characters become Sputnik code until } is reached
$(              The following characters become Sputnik code until ) is reached but includes any ( ) it finds along the way

There is also a { } tag which isn't technically an escape but allows code to be run like:

Function Cat()
{
    return "meow";
}
say "The word is {Cat()} ok!";
say "The value is {Floor(133.77)} ok!";
// PRINTS
// The word is meow ok!
// The value is 133 ok!

More complex example of using the { } tag:

my $Str = "\x48\x65\x6c\x6c\x6f World!";
foreach(my $c in $Str)
{
    say "Char '$c' | Hex: '0x{Hex(Asc('$c'),2)}' | Dec '{Asc('$c')}'";
}
// PRINTS
// Char 'H' | Hex: '0x48' | Dec '72'
// Char 'e' | Hex: '0x65' | Dec '101'
// Char 'l' | Hex: '0x6C' | Dec '108'
// Char 'l' | Hex: '0x6C' | Dec '108'
// Char 'o' | Hex: '0x6F' | Dec '111'
// Char ' ' | Hex: '0x20' | Dec '32'
// Char 'W' | Hex: '0x57' | Dec '87'
// Char 'o' | Hex: '0x6F' | Dec '111'
// Char 'r' | Hex: '0x72' | Dec '114'
// Char 'l' | Hex: '0x6C' | Dec '108'
// Char 'd' | Hex: '0x64' | Dec '100'
// Char '!' | Hex: '0x21' | Dec '33'

Example of using the \| escape:

my $a = "cat";
 // Note this allows you to place the $a followed by Dog directly
say "$a\|Dog"; // Prints: catDog
 // Where as this would fail
say "$aDog"; // **nothing**

If you don't want to print the return of a { } tag you need to add the ! flag example:

my $i = 0;
until($i == 10)
{
    say "Value $i {\$i++!}";
}
// The ! flag coming before the } example !} will cause
// the result value of the operation to not be appended
// to the final string
// PRINTS
// Value 0
// Value 1
// Value 2
// Value 3
// Value 4
// Value 5
// Value 6
// Value 7
// Value 8
// Value 9

To ignore an escape just place a \ next to it for example:

say "\\f";
// PRINTS
// \f

 


Contact
Cheryl (uberfox@hotmail.com)
Homepage
http://ubersoft.org