ARSA Language  2.8
(Encryption, GPU and Web 3.0)
string Class Reference

#include <string.h>

Public Member Functions

char charat (const char *str, int index)
 Returns character at index. More...
 
*int size (const char *str)
 Returns length of the string's content. More...
 
const char * replace (const char *str, const char *toReplace, const char *replaceWith)
 Replaces all instances of a string with another one. More...
 
const char * sub (const char *str, int begin, int length)
 Returns a substring. More...
 
const char * erase (const char *str, int index)
 
const char * trim (const char *str)
 
const char * lower (const char *str)
 Makes the string lower case. More...
 
const char * upper (const char *str)
 Makes the string upper case. More...
 
*bool empty (const char *str)
 Informs if the string is empty or not. More...
 
int find (const char *str, const char *another, int start=0)
 finds another string in this string More...
 
const char * cat (const char *str, const char *strcat1,...)
 The function concatenates the str string and the strcat string, and the result is stored in return string. More...
 
const char * strip (const char *str)
 The strip removes any whitespace at start and end characters. More...
 
int tok (const char *str, const char *tok_chars=" |,", bool use_all_tok_chars=false)
 
const char * tokn (const char *str, int num, const char *tok_chars=" |,", bool use_all_tok_chars=false)
 
bool tofile (const char *filename, const char *str, bool append=false, const char *encode="utf8")
 Save string to file. More...
 
bool cmp (const char *str1, const char *str2)
 string compare between str1 and str2.
More...
 
const char * replacewhitespace (const char *str)
 replace string \t\n\r\0 to whitespace programming code.
More...
 
const char * addprefix (const char *src, const char *prefix)
 add prefix to string.
More...
 
const char * addsuffix (const char *src, const char *suffix)
 add suffix to string.
More...
 
*int findlast (const char *str, const char *findwhat)
 finds position the ended string by string. More...
 
*const char * findclearlast (const char *str, const char *findwhat)
 finds and clear string at last position. More...
 
const char * findclearfirst (const char *str, const char *findwhat)
 finds and clear string at first position. More...
 
const char * base64encode (const char *str)
 base64 encode More...
 
const char * base64decode (const char *str)
 base64 decode More...
 
const char * urlencode (const char *str)
 url encode More...
 
const char * urldecode (const char *str)
 url decode More...
 
const char * hexencode (const char *str)
 hex encode More...
 
const char * hexdecode (const char *str)
 hex decode More...
 
const char * decencode (const char *str)
 dec encode More...
 
const char * decdecode (const char *str)
 dec decode More...
 
const char * binaryencode (const char *str)
 binary encode More...
 
const char * binarydecode (const char *str)
 binary decode More...
 
const char * zip (const char *str, const char *aliasname=0, const char *password=0, int ram=16834, int compress_level=-1)
 
const char * unzip (const char *str, const char *aliasname=0, const char *password=0, int ram=16834)
 decompress string in a zip file, option: another way if you want to open its then use faddzip(), fadd() More...
 
const char * compress (const char *str, int ram=16834, bool speed=false)
 compress string More...
 
const char * uncompress (const char *str, int ram=16834)
 uncompress string More...
 
const char * crc32 (const char *str)
 get crc32 More...
 
const char * md5 (const char *str)
 get md5 More...
 
const char * sha256 (const char *str)
 get sha256 More...
 
const char * encryption (const char *str, const char *layer, const char *password=0, int ram=16834, bool finalize=true)
 encryption string More...
 
const char * decryption (const char *str, const char *layer, const char *password=0, int ram=16834, bool finalize=true)
 decryption string More...
 
const char * encryption2 (const char *str, int ram=16834)
 encryption string with algotithms version 2 More...
 
const char * decryption2 (const char *str, int ram=16834)
 decryption string with algotithms version 2 More...
 

Detailed Description

Definition at line 137 of file string.h.

Member Function Documentation

◆ addprefix()

const char* string::addprefix ( const char *  src,
const char *  prefix 
)

add prefix to string.

Parameters
srcstring source.
prefixprefix string.
Returns
string with prefix.
Example:
set($str, "hello - how are you?")
alog( string.addprefix($str,"john: ") ) // result: "john: hello - how are you?"

◆ addsuffix()

const char* string::addsuffix ( const char *  src,
const char *  suffix 
)

add suffix to string.

Parameters
srcstring source.
suffixsuffix string.
Returns
string with suffix.
Example:
set($str, "hello - how are you?")
alog( string.addsuffix($str," [end]") ) // result: "hello - how are you? [end]"

◆ base64decode()

const char* string::base64decode ( const char *  str)

base64 decode

Parameters
strstring that want decode.
Returns
base64 decode string, empty is otherwise.
Example:
alog( string.base64decode("aGVsbG8gLSBob3cgYXJlIHlvdT8=") ) // result: "hello - how are you?"

◆ base64encode()

const char* string::base64encode ( const char *  str)

base64 encode

Parameters
strstring that want encode.
Returns
base64 encode string.
Example:
set($str, "hello - how are you?")
alog( string.base64encode($str) ) // result: "aGVsbG8gLSBob3cgYXJlIHlvdT8="

◆ binarydecode()

const char* string::binarydecode ( const char *  str)

binary decode

Parameters
strstring that binary decode.
Returns
binary decode string, empty is otherwise.
Example:
alog( string.binarydecode("0110100001100101011011000110110001101111001000000010110100100000011010000110111101110111001000000110000101110010011001010010000001111001011011110111010100111111") ) // result: "hello - how are you?"

◆ binaryencode()

const char* string::binaryencode ( const char *  str)

binary encode

Parameters
strstring that binary encode.
Returns
binary encode string, empty is otherwise.
Example:
set($str, "hello - how are you?")
alog( string.binaryencode($str) ) // result: "0110100001100101011011000110110001101111001000000010110100100000011010000110111101110111001000000110000101110010011001010010000001111001011011110111010100111111"

◆ cat()

const char* string::cat ( const char *  str,
const char *  strcat1,
  ... 
)

The function concatenates the str string and the strcat string, and the result is stored in return string.

Parameters
stroriginal string
strcat1cat string, can send more parameters for strcat.
Returns
a string cat.
Example 1:
set($str, "hello - how are you?")
alog( string.cat($str," [end]") ) // result: "hello - how are you? [end]"

Example 2:
set($str, "hello - how are you?")
alog( string.cat($str," string1"," string2"," string3"," string4") ) // result: "hello - how are you? string1 string2 string3 string4"

◆ charat()

char string::charat ( const char *  str,
int  index 
)

Returns character at index.

Parameters
stroriginal string
indexstring index, 0 is start character.
Returns
character at index.
Example:
set($str, "hello - how are you?")
alog( string.charat($str,8) ) // result: h

◆ cmp()

bool string::cmp ( const char *  str1,
const char *  str2 
)

string compare between str1 and str2.

Parameters
str1string1
str2string2
Returns
true is equal, false is otherwise.

◆ compress()

const char* string::compress ( const char *  str,
int  ram = 16834,
bool  speed = false 
)

compress string

Parameters
strstring that compress.
rambuffer in byte, default 16k
speedcompression speed, true = fast, false = slow.
Returns
compress string, empty is otherwise.
Example:
set($str, "hello - how are you?")
string.tofile( "a.zip", string.compress($str) ) // a.zip

◆ crc32()

const char* string::crc32 ( const char *  str)

get crc32

Parameters
strcheck sum from string
Returns
crc32 hash of a string
Example:
set($str, "hello - how are you?")
alog( string.crc32($str) ) // result: 3787c4f1

◆ decdecode()

const char* string::decdecode ( const char *  str)

dec decode

Parameters
strstring that dec decode.
Returns
binary dec string, empty is otherwise.
Example:
alog( string.decdecode("") ) // result: "hello - how are you?"

◆ decencode()

const char* string::decencode ( const char *  str)

dec encode

Parameters
strstring that dec encode.
Returns
dec encode string, empty is otherwise.
Example:
set($str, "hello - how are you?")
alog( string.decencode($str) ) // result: ""

◆ decryption()

const char* string::decryption ( const char *  str,
const char *  layer,
const char *  password = 0,
int  ram = 16834,
bool  finalize = true 
)

decryption string

Parameters
strstring to decryption.
layeris alphabet only: a...z, not a number, recommended is 5 digits, if more layer then very slow encrypt and decrypt.
passworddecryption password
rambuffer in byte, default 16k
finalizedecryption with finalize processing (when encryption must same flags), secured but very slow
Returns
decryption string, empty is otherwise.
Example:
alog( string.decryption(ftostring("b.zip", ascii), "hello", "password") ) // result: "hello - how are you?"

◆ decryption2()

const char* string::decryption2 ( const char *  str,
int  ram = 16834 
)

decryption string with algotithms version 2

Parameters
strstring to decryption.
rambuffer in byte, default 16k
Returns
decryption string, empty is otherwise.
Example:
alog( string.decryption2(ftostring("b.zip", ascii)) ) // result: "hello - how are you?"

◆ empty()

* bool string::empty ( const char *  str)

Informs if the string is empty or not.

Parameters
stroriginal string
Returns
true if the string is empty, false if not.
Example:
set($str, "hello - how are you?")
alog( string.empty($str) ) // result: false
alog( string.empty("") ) // result: true

◆ encryption()

const char* string::encryption ( const char *  str,
const char *  layer,
const char *  password = 0,
int  ram = 16834,
bool  finalize = true 
)

encryption string

Parameters
strstring to encryption.
layerlayer is alphabet only: a...z, not a number, recommended is 5 digits, if more layer then very slow encrypt and decrypt.
passwordencryption password
rambuffer in byte, default 16k
finalizeencryption with finalize processing (when decryption must same flags), secured but very slow
Returns
encryption string, empty is otherwise.
Example:
string.tofile( "b.zip", string.encryption($str, "hello", "password"), false, ascii ) // result: b.zip

◆ encryption2()

const char* string::encryption2 ( const char *  str,
int  ram = 16834 
)

encryption string with algotithms version 2

Parameters
strstring to encryption.
rambuffer in byte, default 16k
Returns
encryption stringwith algotithms version 2, empty is otherwise.
Example:
string.tofile( "b.zip", string.encryption2($str), false, ascii ) // result: b.zip

◆ erase()

const char* string::erase ( const char *  str,
int  index 
)

Erases a character from the string.
May be slow, because all elements following after the erased element have to be copied.

Parameters
stroriginal string
indexIndex of element to be erased.
Returns
an erased string.
Example:
set($str, "hello - how are you?")
alog( string.erase($str,8) ) // result: "hello - ow are you?"

◆ find()

int string::find ( const char *  str,
const char *  another,
int  start = 0 
)

finds another string in this string

Parameters
stroriginal string
anotherAnother string
startStart position of the search
Returns
Positions where the string has been found, or -1 if not found.
Example:
set($str, "hello - how are you?")
alog( string.find($str,"h") ) // result: 0

◆ findclearfirst()

const char* string::findclearfirst ( const char *  str,
const char *  findwhat 
)

finds and clear string at first position.

Parameters
stroriginal string.
findwhatstring finding.
Returns
string with clear first position.
Example:
set($str, "hello - how are you?")
alog( string.findclearfirst($str,"h") ) // result: "ello - how are you?"

◆ findclearlast()

* const char* string::findclearlast ( const char *  str,
const char *  findwhat 
)

finds and clear string at last position.

Parameters
stroriginal string.
findwhatstring finding.
Returns
string with clear last position.
Example:
set($str, "hello - how are you?")
alog( string.findclearfirst($str,"?") ) // result: "hello - how are you"

◆ findlast()

* int string::findlast ( const char *  str,
const char *  findwhat 
)

finds position the ended string by string.

Parameters
stroriginal string.
findwhatstring finding.
Returns
zero based positions where the string has been found, or -1 if not found.
Example:
set($str, "hello - how are you?")
alog( string.findlast($str,"h") ) // result: 8

◆ hexdecode()

const char* string::hexdecode ( const char *  str)

hex decode

Parameters
strstring that hex decode.
Returns
hex decode string, empty is otherwise.
Example:
alog( string.hexdecode("") ) // result: "hello - how are you?"

◆ hexencode()

const char* string::hexencode ( const char *  str)

hex encode

Parameters
strstring that hex encode.
Returns
hex encode string, empty is otherwise.
Example:
set($str, "hello - how are you?")
alog( string.hexcode($str) ) // result:

◆ lower()

const char* string::lower ( const char *  str)

Makes the string lower case.

Parameters
stroriginal string
Returns
a lower case string.
Example:
set($str, "hello - how are you?")
alog( string.lower($str) ) // result: "hello - how are you?"

◆ md5()

const char* string::md5 ( const char *  str)

get md5

Parameters
strcheck sum from string
Returns
md5 hash of a string
Example:
set($str, "hello - how are you?")
alog( string.md5($str) ) // result: "aea36ff47f10470c66746aeda9fa0d18"

◆ replace()

const char* string::replace ( const char *  str,
const char *  toReplace,
const char *  replaceWith 
)

Replaces all instances of a string with another one.

Parameters
stroriginal string
toReplaceThe string to replace.
replaceWithThe string replacing the old one.
Returns
a replaced string.
Example:
set($str, "hello - how are you?")
alog( string.replace($str,"you", "me") ) // result: "hello - how are me?"

◆ replacewhitespace()

const char* string::replacewhitespace ( const char *  str)

replace string \t\n\r\0 to whitespace programming code.

Parameters
stroriginal string under \"..."\ power quote
Returns
a replaced whitespace string.
Example:
set($str, "hello - how are you?")
alog( string.replacewhitespace(\"\thello\thow \nare you?"\) ) // result: " hello how are you?"

◆ sha256()

const char* string::sha256 ( const char *  str)

get sha256

Parameters
strcheck sum from file or string
Returns
sha256 hash of a string
Example:
set($str, "hello - how are you?")
alog( string.sha256($str) ) // result: "08ddca8914dd34e00b708f18fcf632f161b6cfbe85c230e971cc167fc267f8b3"

◆ size()

* int string::size ( const char *  str)

Returns length of the string's content.

Parameters
stroriginal string
Returns
Length of the string's content in characters, excluding the trailing NULL.
Example:
set($str, "hello - how are you?")
alog( string.size($str) ) // result: 20

◆ strip()

const char* string::strip ( const char *  str)

The strip removes any whitespace at start and end characters.

Parameters
stroriginal string
Returns
a strip string.

◆ sub()

const char* string::sub ( const char *  str,
int  begin,
int  length 
)

Returns a substring.

Parameters
stroriginal string
beginStart of substring.
lengthLength of substring.
Returns
a substring.
Example:
set($str, "hello - how are you?")
alog( string.sub($str,8, 3) ) // result: "how"

◆ tofile()

bool string::tofile ( const char *  filename,
const char *  str,
bool  append = false,
const char *  encode = "utf8" 
)

Save string to file.

Parameters
filenamefilename save on disk
stroriginal string
appendsave string append or renew file before saving
encodeforce encoding string to. default: utf8, (ascii for binary file)
auto
ascii
utf8
utf16
utf32
wchar
Returns
true is successed, false is cannot save.

◆ tok()

int string::tok ( const char *  str,
const char *  tok_chars = " |,",
bool  use_all_tok_chars = false 
)

The string token from start to end with specific characters.
RECOMMENDED: use string.tokn() instread this function.

Parameters
stroriginal string
tok_charscharacter is tokenization default is " |,"
use_all_tok_charsenable all char in tok_chars be token word.
Returns
token array id MUST use array.close() after finish, false is -1.

◆ tokn()

const char* string::tokn ( const char *  str,
int  num,
const char *  tok_chars = " |,",
bool  use_all_tok_chars = false 
)

The string token from start to end with specific characters.
and return string in slot that user enter as num.

Parameters
stroriginal string
numarray slot that user want after token done.
tok_charscharacter is tokenization default is " |,"
use_all_tok_charsenable all char in tok_chars be token word.
Returns
string by array number, successed always return not empty string, false is empty.
Example:
set($str, "hello - how are you?")
alog( string.tokn($str,2) ) // result: "how"
alog( string.tokn($str,3) ) // result: "are"
alog( string.tokn($str,4) ) // result: "you?"

◆ trim()

const char* string::trim ( const char *  str)

Trims the string.
Removes the whitespace from the begining until the end of the string.
whitespace chars are " \t\n\r"

Parameters
stroriginal string
Returns
a trim string.

◆ uncompress()

const char* string::uncompress ( const char *  str,
int  ram = 16834 
)

uncompress string

Parameters
strstring that uncompress.
rambuffer in byte, default 16k
Returns
uncompress string, empty is otherwise.
Example:
alog( string.uncompress(ftostring("a.zip")) ) // result: "hello - how are you?"

◆ unzip()

const char* string::unzip ( const char *  str,
const char *  aliasname = 0,
const char *  password = 0,
int  ram = 16834 
)

decompress string in a zip file, option: another way if you want to open its then use faddzip(), fadd()

Parameters
strstring that compress.
aliasnameopen reference name in zip file, if empty string then used the first file found!
passwordzip password
rambuffer in byte, default 16k
Returns
decompress string, empty is otherwise.
Example:
alog( string.unzip(ftostring("d.zip",ascii), "dummy", "password") ) // hello - how are you?

◆ upper()

const char* string::upper ( const char *  str)

Makes the string upper case.

Parameters
stroriginal string
Returns
a upper case string.
Example:
set($str, "hello - how are you?")
alog( string.upper($str) ) // result: "HELLO - HOW ARE YOU?"

◆ urldecode()

const char* string::urldecode ( const char *  str)

url decode

Parameters
strstring that url decode.
Returns
url decode string, empty is otherwise.
Example:
alog( string.urldecode("hello+-+how+are+you%3f") ) // result: "hello - how are you?"

◆ urlencode()

const char* string::urlencode ( const char *  str)

url encode

Parameters
strstring that url encode.
Returns
url encode string.
Example:
set($str, "hello - how are you?")
alog( string.urlencode($str) ) // result: "hello+-+how+are+you%3f"

◆ zip()

const char* string::zip ( const char *  str,
const char *  aliasname = 0,
const char *  password = 0,
int  ram = 16834,
int  compress_level = -1 
)

compress string and put to a zip file, option: after zip() done: another way if you want to open its then use faddzip(), fadd() or unzip()
NOTE: unzip() is only support password, !!! faddzip() or fadd() is not support password from this zip() function!!!

Parameters
strstring that compress.
aliasnamesaving reference name in zip file, can be a empty string then program replace to "-" automatic
passwordzip password
rambuffer in byte, default 16k
compress_level0 = no compress, 1 = best speed, 9 = best compression, default: -1 is default compression
Returns
compress string, empty is otherwise.
Example:
set($str, "hello - how are you?")
string.tofile( "d.zip", string.zip($str, "dummy", "password"), false, ascii ) // d.zip, ascii flag is save as binary file.

The documentation for this class was generated from the following file: