[NAME]
ALL.dao.type.string

[TITLE]
String Type

[DESCRIPTION]

string is a primitive data type representing a sequence of characters, which can be 
either single-byte characters or wide characters. Strings with single-byte characters are
normally declared with string literals that are quoted with single quotation marks. And 
strings with wide characters are declared with string literals that are quoted with
double qutotation marks.

 0.1  Basic Definition 

     
   1  ByteCharacterString ::= "'" Characters "'"
   2  WideCharacterString ::= '"' Characters '"'
     
where Characters can be anything but the quotation marks without backslash escapes. Any 
characters in a string can be preceded with a escape backslash to specify a charater
represented by:
  *  Single decimal digit: \d;
  *  Octal value with upto 3 digits: \ooo;
  *  Hexidecial value with upto 2 digits prefixed by x: \xhh;
  *  Hexidecial value with upto 4 digits prefixed by u: \xhhhh;
  *  Hexidecial value with upto 8 digits prefixed by U: \xhhhhhhhh; 
With backslash escapes, a tab can also be represtend by \t, and a line break by \n and a
carriage return by \r. Any other character escaped by a backslash literally represents 
that character itself.

Besides the basic quotation marks, a few other quotation marks can also be used to
enclose string literals. These include the Double Byte Characters (DBC) quotation marks
(0x27+0xfee0 for single quotation mark and 0x22+0xfee0 for double quotation mark), the
left and right single quotation marks (0x2018, 0x2019), and the left and right double
quotation marks (0x201c, 0x201d).

Dao strings are not null-terminated, so they are effectively byte or character arrays 
that can be used to store any sequences of bytes or characters. When a string of
single-byte characters is used to store text, it is interpreted as Multi-Bytes String
(MBS). Similarly a string of wide characters is interpreted as Wide Character String
(WCS) for storing text. For convenience, we will simply use Multi-Bytes String (MBS) and
Wide Character String (WCS) to refer to the two types of strings.

These two types of strings can be mixed together, one can be converted to the other
automatically when necessary. But it is better to use one of them consistently to avoid
unnecesary conversions.

 0.2  Verbatim String 

A verbatim string is a string that can contain anything without interpreting escape
characters.
     
   1  VerbatimMBString ::= '@[' [Delimiter] ']' Characters '@[' [Delimiter] ']'
   2  VerbatimWCString ::= '@@[' [Delimiter] ']' Characters '@@[' [Delimiter] ']'
     
Where Delimiter can contain letters, digits, underscores, blank spaces, dots, colons, 
dashes and assignment marks. It must be unique such that '@[' [Delimiter] ']' or '@@[' 
[Delimiter] ']' does not appear in the string content. If @[] is used to enclose a 
verbatim string, this string will be stored as multi-byte string. And if @@[] is used to
enclose a verbatim string, this string will be stored as wide character string.

 0.3  Examples 

     
   1  mbs = 'hello'
   2  wcs = "道语言"
   3  mbs2 = 'It\'s green'
   4  wcs2 = "\u9053\u8bed\u8a00" # the same as wcs;
   5  
   6  # verbatim strings:
   7  mbs = @[] some text @[]
   8  wcs = @@[] some text @@[]
   9  
  10  # C++ codes in MBS:
  11  cpp =
  12  @[cpp x]
  13  class AA
  14  {
  15  	int index;
  16  };
  17  struct BB{};
  18  @[cpp x]
  19  
  20  
  21  # Lua codes in MBS:
  22  lua =
  23  @[lua]
  24  local a = 1;
  25  function Test()
  26  	io.write( 'Hello' )
  27  end
  28  @[lua]
  29  
  30  # HTML codes in WCS:
  31  html =
  32  @@[html:123456]
  33  <body>
  34  <span name="test"></span>
  35  </body>
  36  @@[html:123456]
     



[STRUCTURE]

dao.type.string--| dao.type.string: String Type (21.0 KB)
                 |--method------| dao.type.string.method: Dao string methods (4.9 KB)
                 |              |--chop-----| dao.type.string.method.chop: chop( self :string ) (0.3 KB)
                 |              |--erase----| dao.type.string.method.erase: erase( self :string ) (0.2 KB)
                 |              |--find-----| dao.type.string.method.find: find( self :string ) (0.3 KB)
                 |              |--insert---| dao.type.string.method.insert: insert( self :string ) (0.4 KB)
                 |              |--replace--| dao.type.string.method.replace: replace( self :string ) (0.5 KB)
                 |              |--expand---| dao.type.string.method.expand: expand( self :string ) (1.5 KB)
                 |              |--resize---| dao.type.string.method.resize: resize( self :string ) (0.1 KB)
                 |              |--size-----| dao.type.string.method.size: size( self :string ) (0.1 KB)
                 |              |--split----| dao.type.string.method.split: split( self :string ) (0.5 KB)
                 |              |--tolower--| dao.type.string.method.tolower: tolower( self :string ) (0.1 KB)
                 |              |--toupper--| dao.type.string.method.toupper: toupper( self :string ) (0.1 KB)
                 |                            
                 |--functional--| dao.type.string.functional: Dao String Functional Methods (1.1 KB)
                 |              |--iterate--| dao.type.string.functional.iterate: iterate( self :string ) (0.1 KB)
                 |              |--count----| dao.type.string.functional.count: count( self :string ) (0.1 KB)
                 |              |--map------| dao.type.string.functional.map: map( self :string ) (0.1 KB)
                 |              |--select---| dao.type.string.functional.select: select( self :string ) (0.1 KB)
                 |              |--index----| dao.type.string.functional.index: index( self :string ) (0.1 KB)
                 |              |--apply----| dao.type.string.functional.apply: apply( self :string ) (0.1 KB)
                 |                            
                 |--pattern-----| dao.type.string.pattern: String Pattern Matching (11.1 KB)
                                |--pfind-----| dao.type.string.pattern.pfind: string.pfind() (0.6 KB)
                                |--match-----| dao.type.string.pattern.match: string.match() (0.3 KB)
                                |--submatch--| dao.type.string.pattern.submatch: string.submatch() (0.4 KB)
                                |--extract---| dao.type.string.pattern.extract: string.extract() (0.9 KB)
                                |--capture---| dao.type.string.pattern.capture: string.capture() (0.3 KB)
                                |--change----| dao.type.string.pattern.change: string.change() (0.7 KB)