File hp/lang/string.lua

Functions

string.decrypt (str) String encryption
string.encrypt (str, code) String encryption
string.fromNumberWithZeros (n, l) Converts number to string, filling in zeros at beginning.
string.hexToRGB (s, returnAsTable) Converts hex number to rgb (format: #FF00FF)
string.split (self, delim, toNumber) Splits string into a table of strings using delimiter.
Usage: local table = a:split( ",", false )
TODO: Does not correspond to multi-byte.
string.splitToLines (self, numLines, delim) Splits string into N lines, using default ("#") or custom delimiter Routine separate words by spaces so make sure you have them.
string.toNumber (self) Converts the string to number, or returns string if fail.
string.toTable (self, delimiter) Splits string into N lines, using default ("#") or custom delimiter Routine separate words by spaces so make sure you have them.

Tables

string modules that extend functionality of the string.


Functions

string.decrypt (str)
String encryption

Parameters

  • str:
string.encrypt (str, code)
String encryption

Parameters

  • str:
  • code:
string.fromNumberWithZeros (n, l)
Converts number to string, filling in zeros at beginning. Technically, this shouldn't really extend string class because it doesn't operate on string (doesn't have a "self" ) Usage: print( string.fromNumbersWithZeros( 421, 6 ) ) 000421

Parameters

  • n:
  • l:
string.hexToRGB (s, returnAsTable)
Converts hex number to rgb (format: #FF00FF)

Parameters

  • s:
  • returnAsTable:
string.split (self, delim, toNumber)
Splits string into a table of strings using delimiter.
Usage: local table = a:split( ",", false )
TODO: Does not correspond to multi-byte.

Parameters

  • self: string.
  • delim: Delimiter.
  • toNumber: If set to true or to be converted to a numeric value.

Return value:

Split the resulting table
string.splitToLines (self, numLines, delim)
Splits string into N lines, using default ("#") or custom delimiter Routine separate words by spaces so make sure you have them. Usage: local string = s:splitIntoLines( 3, "\n" )

Parameters

  • self:
  • numLines:
  • delim:
string.toNumber (self)
Converts the string to number, or returns string if fail.

Parameters

  • self:
string.toTable (self, delimiter)
Splits string into N lines, using default ("#") or custom delimiter Routine separate words by spaces so make sure you have them. USAGE: For a string "width:150 height:150", or "width:150_height:150" returns a table { width=150, height=150 }

Parameters

  • self:
  • delimiter:

Tables

string
modules that extend functionality of the string.

Valid XHTML 1.0!