My Project
|
Contains miscellaneous functions. More...
#include <ParaScriptingMisc.h>
Static Public Member Functions | |
static int | GetUnicodeCharNum (const char *str) |
get the number of characters in str. More... | |
static std::string | UniSubString (const char *str, int nFrom, int nTo) |
same as LUA string.sub(), except that the index is character. More... | |
static std::string | UTF8ToUTF16 (const std::string &utf8) |
Converts utf8 string to utf16 string. More... | |
static std::string | UTF16ToUTF8 (const std::string &utf16) |
Converts utf16 string to utf8 string. More... | |
static std::string | SimpleEncode (const std::string &source) |
encode a string using really simple algorithm. More... | |
static std::string | SimpleDecode (const std::string &source) |
decode a string using really simple algorithm. More... | |
static string | md5 (const string &source) |
convert the md5 of the input source string. More... | |
static string | md5_ (const string &source, bool bBinary) |
static string | sha1 (const string &source) |
convert the sha1 of the input source string. More... | |
static string | sha1_ (const string &source, bool bBinary) |
static string | base64 (const string &source) |
convert the base64 of the input source string. More... | |
static string | unbase64 (const string &source) |
return the unbase64 of the input source string. More... | |
static long | RandomLong (const object &seedTable) |
Generating [-MAX, MAX] long integer. More... | |
static double | RandomDouble (const object &seedTable) |
generating [0,1] double value | |
static const std::string & | EncodingConvert (const std::string &srcEncoding, const std::string &dstEncoding, const std::string &bytes) |
Converts an entire byte array from one encoding to another. More... | |
static bool | CopyTextToClipboard (const char *text) |
copy text to clipboard. More... | |
static const char * | GetTextFromClipboard () |
get text from clipboard. More... | |
Contains miscellaneous functions.
|
static |
convert the base64 of the input source string.
|
static |
copy text to clipboard.
Input is ANSI code page
|
static |
Converts an entire byte array from one encoding to another.
srcEncoding | any encoding name. If nil or "", it is the default coding in NPL. see Encoding.GetEncoding(). Below are some commonly used field | Code Page | Name | | 950 | big5 | | 936 | gb2312 | | 65001 | utf-8 | | | utf-16 | | 65005 | utf-32 | There is one special code name called "HTML", which contains HTML special characters in ascii code page. This is usually true for most "iso8859-15" encoding in western worlds. It just writes the unicode number+XXXX in ascii character "&#XXXX;" where & is optional. |
dstEncoding | save as above. If nil or "", it will be converted to default coding in NPL. : the source bytes. e.g. The most common use of this function is to create HTML special character to NPL string, like below local text = ParaMisc.EncodingConvert("HTML", "", "Chinese characters: 开发") log(text); |
|
static |
get text from clipboard.
text is converted to ANSI code page when returned.
|
static |
get the number of characters in str.
Str is assumed to be in ANSI code page. it is converted to Unicode and return the character count.
|
static |
convert the md5 of the input source string.
|
static |
Generating [-MAX, MAX] long integer.
seedTable | nil or a table containing {_seed=integer} when the function returned the seedTable._seed will be modified. |
|
static |
convert the sha1 of the input source string.
|
static |
decode a string using really simple algorithm.
str = SimpleDecode(SimpleEncode(str))
|
static |
encode a string using really simple algorithm.
it just makes the source ineligible. It is still not immune to crackers. str = SimpleDecode(SimpleEncode(str))
|
static |
return the unbase64 of the input source string.
|
static |
same as LUA string.sub(), except that the index is character.
get a sub string of a ANSI Code page string. However, the index are unicode characters.
str | the string to use |
nFrom | character index beginning from 1. |
|
static |
Converts utf16 string to utf8 string.
utf16 | The utf16 string to be converted |
|
static |
Converts utf8 string to utf16 string.
utf8 | The utf8 string to be converted |