public class StringModule extends AbstractQuercusModule
Modifier and Type | Field and Description |
---|---|
static int |
CHAR_MAX |
static int |
CRYPT_BLOWFISH |
static int |
CRYPT_EXT_DES |
static int |
CRYPT_MD5 |
static int |
CRYPT_SALT_LENGTH |
static int |
CRYPT_STD_DES |
static int |
LC_ALL |
static int |
LC_COLLATE |
static int |
LC_CTYPE |
static int |
LC_MESSAGES |
static int |
LC_MONETARY |
static int |
LC_NUMERIC |
static int |
LC_TIME |
static int |
STR_PAD_BOTH |
static int |
STR_PAD_LEFT |
static int |
STR_PAD_RIGHT |
PHP_INI_ALL, PHP_INI_PERDIR, PHP_INI_SYSTEM, PHP_INI_USER
Constructor and Description |
---|
StringModule() |
Modifier and Type | Method and Description |
---|---|
static StringValue |
addcslashes(Env env,
StringValue source,
java.lang.String characters)
Escapes a string using C syntax.
|
static StringValue |
addslashes(StringValue source)
Escapes a string for db characters.
|
static StringValue |
bin2hex(Env env,
java.io.InputStream is)
Converts a binary value to a hex value.
|
static StringValue |
chop(Env env,
StringValue str,
java.lang.String charset)
Alias of rtrim.
|
static StringValue |
chr(Env env,
long value)
converts a number to its character equivalent
|
static java.lang.String |
chunk_split(java.lang.String body,
int chunkLen,
java.lang.String end)
Splits a string into chunks
|
static java.lang.String |
convert_cyr_string(Env env,
java.lang.String str,
java.lang.String from,
java.lang.String to)
Converts from one cyrillic set to another.
|
static Value |
convert_uudecode(Env env,
StringValue source) |
static Value |
convert_uuencode(StringValue source)
uuencode a string.
|
static Value |
count_chars(StringValue data,
int mode)
Returns an array of information about the characters.
|
static long |
crc32(StringValue str)
Calculates the crc32 value for a string
|
static java.lang.String |
crypt(java.lang.String string,
java.lang.String salt) |
static Value |
explode(Env env,
StringValue separator,
StringValue string,
long limit)
Explodes a string into an array
|
static Value |
fprintf(Env env,
BinaryOutput os,
StringValue format,
Value[] args)
Use printf style formatting to write a string to a file.
|
static StringValue |
hex2bin(Env env,
StringValue s)
Converts a binary value to a hex value.
|
protected static int |
hexToDigit(char ch) |
static Value |
implode(Env env,
Value glueV,
Value piecesV)
implodes an array into a string
|
protected static boolean |
isWhitespace(char ch)
Returns true if the character is a whitespace character.
|
static Value |
join(Env env,
Value glueV,
Value piecesV)
implodes an array into a string
|
static ArrayValue |
localeconv(Env env)
Gets locale-specific symbols.
|
static StringValue |
ltrim(Env env,
StringValue string,
java.lang.String characters)
Removes leading whitespace.
|
static Value |
md5_file(Env env,
Path source,
boolean rawOutput)
returns the md5 hash
|
static Value |
md5(Env env,
java.io.InputStream is,
boolean rawOutput)
returns the md5 hash
|
static java.lang.String |
metaphone(java.lang.String string)
Returns the metaphone of a string.
|
static java.lang.String |
money_format(Env env,
java.lang.String format,
double value)
Returns a formatted money value.
|
static java.lang.String |
number_format(Env env,
double value,
int decimals,
Value pointValue,
Value groupValue)
Returns a formatted number.
|
protected static int |
octToDigit(char ch) |
static long |
ord(StringValue string)
Converts the first character to an integer.
|
static Value |
parse_str(Env env,
StringValue str,
Value ref)
Parses the string as a query string.
|
static long |
print(Env env,
Value value)
Prints the string.
|
static int |
printf(Env env,
StringValue format,
Value[] args)
print to the output with a formatter
|
static java.lang.String |
quoted_printable_decode(java.lang.String str)
Converts a RFC2045 quoted printable string to a string.
|
static Value |
quotemeta(StringValue string)
Escapes meta characters.
|
static StringValue |
rtrim(Env env,
StringValue string,
java.lang.String characters)
Removes trailing whitespace.
|
static Value |
setlocale(Env env,
int category,
Value localeArg,
Value[] fallback)
Sets locale configuration.
|
static Value |
sha1_file(Env env,
Path source,
boolean rawOutput)
returns the md5 hash
|
static Value |
sha1(Env env,
java.io.InputStream is,
boolean rawOutput)
returns the md5 hash
|
static Value |
soundex(StringValue string) |
static Value |
sprintf(Env env,
StringValue format,
Value[] args)
Print to a string with a formatter
|
static Value |
sscanf(Env env,
StringValue string,
StringValue format,
Value[] args)
scans a string
|
static Value |
sscanfOld(Env env,
StringValue string,
StringValue format,
Value[] args)
scans a string
|
static Value |
str_ireplace(Env env,
Value search,
Value replace,
Value subject,
Value count)
replaces substrings.
|
static StringValue |
str_pad(StringValue string,
int length,
java.lang.String pad,
int type)
Pads strings
|
static Value |
str_repeat(StringValue string,
int count)
repeats a string
|
static Value |
str_replace(Env env,
Value search,
Value replace,
Value subject,
Value count)
replaces substrings.
|
static Value |
str_rot13(StringValue string)
rot13 conversion
|
static java.lang.String |
str_shuffle(java.lang.String string)
shuffles a string
|
static Value |
str_split(StringValue string,
int chunk)
split into an array
|
static Value |
str_word_count(StringValue string,
int format,
java.lang.String additionalWordCharacters) |
static int |
strcasecmp(StringValue a,
StringValue b)
Case-insensitive comparison
|
static Value |
strchr(Env env,
StringValue haystack,
Value needle)
Finds the index of a substring
|
static int |
strcmp(StringValue a,
StringValue b)
Case-sensitive comparison
|
static Value |
strcoll(java.lang.String a,
java.lang.String b)
Locale-based comparison
XXX: i18n
|
static Value |
strcspn(StringValue string,
StringValue characters,
int offset,
int length)
Finds the number of initial characters in string that do not match
one of the characters in characters
|
static StringValue |
strip_tags(Env env,
StringValue string,
Value allowTags)
Removes tags from a string.
|
static java.lang.String |
stripcslashes(java.lang.String source)
Strip out the backslashes, recognizing the escape sequences, octal,
and hexadecimal representations.
|
static Value |
stripos(Env env,
StringValue haystack,
Value needleV,
int offset)
Returns the position of a substring, testing case insensitive.
|
static StringValue |
stripslashes(StringValue string)
Strips out the backslashes.
|
static Value |
stristr(Env env,
StringValue haystack,
Value needleV)
Finds the first instance of a substring, testing case insensitively
|
static Value |
strlen(Value value)
Returns the length of a string.
|
static int |
strnatcasecmp(StringValue a,
StringValue b)
Case-insensitive comparison
|
static int |
strnatcmp(StringValue a,
StringValue b)
Case-sensitive comparison
|
static Value |
strncasecmp(Env env,
StringValue a,
StringValue b,
int length)
Case-insensitive comparison
|
static Value |
strncmp(Env env,
StringValue a,
StringValue b,
int length)
Case-sensitive comparison
|
static Value |
strpbrk(StringValue haystack,
StringValue charList)
Returns a substring of haystack starting from the earliest
occurence of any char in charList
|
static Value |
strpos(Env env,
StringValue haystack,
Value needleV,
int offset)
Returns the position of a substring.
|
static Value |
strrchr(Env env,
StringValue haystack,
Value needleV)
Finds the last instance of a substring
|
static Value |
strrev(StringValue string)
Reverses a string.
|
static Value |
strripos(Env env,
java.lang.String haystack,
Value needleV,
Value offsetV)
Returns the position of a substring, testing case-insensitive.
|
static Value |
strrpos(Env env,
StringValue haystack,
Value needleV,
Value offsetV)
Returns the position of a substring.
|
static Value |
strspn(StringValue string,
StringValue characters,
int offset,
int length)
Finds the number of initial characters in string that match one of
the characters in characters
|
static Value |
strstr(Env env,
StringValue haystackV,
Value needleV)
Finds the first instance of a needle in haystack and returns
the portion of haystack from the beginning of
needle to the end of haystack.
|
static Value |
strtok(Env env,
StringValue string1,
Value string2)
Split a string into tokens using any character
in another string as a delimiter.
|
static StringValue |
strtolower(StringValue string)
Converts to lower case.
|
static StringValue |
strtoupper(StringValue string)
Converts to upper case.
|
static StringValue |
strtr(Env env,
StringValue string,
Value fromV,
StringValue to)
Translates characters in a string to target values.
|
static Value |
substr_compare(Env env,
StringValue mainStr,
StringValue str,
int offset,
Value lenV,
boolean isCaseInsensitive) |
static Value |
substr_count(Env env,
StringValue haystackV,
StringValue needleV,
int offset,
int length) |
static Value |
substr_replace(Env env,
Value subjectV,
StringValue replacement,
Value startV,
Value lengthV)
Replaces a substring with a replacement
|
static Value |
substr(Env env,
StringValue string,
int start,
Value lenV)
Returns a substring
|
protected static char |
toHexChar(int d) |
protected static char |
toUpperCase(char ch)
Returns the uppercase equivalent of the caharacter
|
protected static char |
toUpperHexChar(int d) |
protected static char |
toUUChar(int d)
Converts an integer digit to a uuencoded char.
|
static Value |
trim(Env env,
StringValue string,
java.lang.String characters)
Removes leading and trailing whitespace.
|
static StringValue |
ucfirst(Env env,
StringValue string)
Uppercases the first character
|
static java.lang.String |
ucwords(java.lang.String string)
Uppercases the first character of each word
|
static int |
vprintf(Env env,
StringValue format,
ArrayValue array)
Formatted strings with array arguments
|
static Value |
vsprintf(Env env,
StringValue format,
ArrayValue array)
Formatted strings with array arguments
|
static Value |
wordwrap(Env env,
Value value,
Value widthV,
Value breakV,
Value cutV)
Wraps a string to the given number of characters.
|
addConstant, addConstant, addConstant, getConstMap, getIniDefinitions, getLoadedExtensions
public static final int CRYPT_SALT_LENGTH
public static final int CRYPT_STD_DES
public static final int CRYPT_EXT_DES
public static final int CRYPT_MD5
public static final int CRYPT_BLOWFISH
public static final int CHAR_MAX
public static final int LC_CTYPE
public static final int LC_NUMERIC
public static final int LC_TIME
public static final int LC_COLLATE
public static final int LC_MONETARY
public static final int LC_ALL
public static final int LC_MESSAGES
public static final int STR_PAD_LEFT
public static final int STR_PAD_RIGHT
public static final int STR_PAD_BOTH
public static StringValue addcslashes(Env env, StringValue source, java.lang.String characters)
source
- the source string to convertcharacters
- the set of characters to convertstripcslashes(java.lang.String)
public static StringValue addslashes(StringValue source)
source
- the source string to convertpublic static StringValue bin2hex(Env env, java.io.InputStream is)
public static StringValue chop(Env env, StringValue str, java.lang.String charset)
env
- the quercus environmentstr
- the string to be trimmedcharset
- optional set of characters to trimpublic static StringValue chr(Env env, long value)
value
- the integer valuepublic static java.lang.String chunk_split(java.lang.String body, int chunkLen, java.lang.String end)
body
- the body stringchunkLen
- the optional chunk length, defaults to 76end
- the optional end value, defaults to "\r\n"public static java.lang.String convert_cyr_string(Env env, java.lang.String str, java.lang.String from, java.lang.String to)
public static Value convert_uudecode(Env env, StringValue source)
public static Value convert_uuencode(StringValue source)
public static Value count_chars(StringValue data, int mode)
public static long crc32(StringValue str)
str
- the string valuepublic static java.lang.String crypt(java.lang.String string, java.lang.String salt)
public static Value explode(Env env, StringValue separator, StringValue string, long limit)
separator
- the separator stringstring
- the string to be explodedlimit
- the max number of elementspublic static Value fprintf(Env env, BinaryOutput os, StringValue format, Value[] args)
fd
- the file to write toformat
- the format stringargs
- the valujes to apply to the format stringpublic static StringValue hex2bin(Env env, StringValue s)
public static Value implode(Env env, Value glueV, Value piecesV)
glueV
- the separator stringpiecesV
- the array to be implodedpublic static Value join(Env env, Value glueV, Value piecesV)
glueV
- the separator stringpiecesV
- the array to be implodedpublic static ArrayValue localeconv(Env env)
public static StringValue ltrim(Env env, StringValue string, java.lang.String characters)
string
- the string to be trimmedcharacters
- optional set of characters to trimpublic static Value md5(Env env, java.io.InputStream is, boolean rawOutput)
source
- the stringrawOutput
- if true, return the raw binarypublic static Value md5_file(Env env, Path source, boolean rawOutput)
source
- the stringrawOutput
- if true, return the raw binarypublic static java.lang.String metaphone(java.lang.String string)
public static java.lang.String money_format(Env env, java.lang.String format, double value)
format
- the formatvalue
- the valuepublic static java.lang.String number_format(Env env, double value, int decimals, Value pointValue, Value groupValue)
value
- the valuedecimals
- the number of decimalspointValue
- the decimal point stringgroupValue
- the thousands separatorpublic static long ord(StringValue string)
string
- the string to be convertedpublic static Value parse_str(Env env, StringValue str, Value ref)
env
- the calling environmentstr
- the query stringarray
- the optional result arraypublic static long print(Env env, Value value)
env
- the quercus environmentvalue
- the string to printpublic static int printf(Env env, StringValue format, Value[] args)
env
- the quercus environmentformat
- the format stringargs
- the format argumentspublic static java.lang.String quoted_printable_decode(java.lang.String str)
public static Value quotemeta(StringValue string)
string
- the string to be quotedpublic static StringValue rtrim(Env env, StringValue string, java.lang.String characters)
env
- the quercus environmentstring
- the string to be trimmedcharacters
- optional set of characters to trimpublic static Value setlocale(Env env, int category, Value localeArg, Value[] fallback)
public static Value sha1(Env env, java.io.InputStream is, boolean rawOutput)
source
- the stringrawOutput
- if true, return the raw binarypublic static Value sha1_file(Env env, Path source, boolean rawOutput)
source
- the stringrawOutput
- if true, return the raw binarypublic static Value soundex(StringValue string)
public static Value sprintf(Env env, StringValue format, Value[] args)
format
- the format stringargs
- the format argumentspublic static Value sscanf(Env env, StringValue string, StringValue format, Value[] args)
format
- the format stringargs
- the format argumentspublic static Value sscanfOld(Env env, StringValue string, StringValue format, Value[] args)
format
- the format stringargs
- the format argumentspublic static Value str_ireplace(Env env, Value search, Value replace, Value subject, Value count)
search
- search stringreplace
- replacement stringsubject
- replacementcount
- return valuepublic static StringValue str_pad(StringValue string, int length, java.lang.String pad, int type)
string
- stringlength
- lengthpad
- padding stringtype
- padding typepublic static Value str_repeat(StringValue string, int count)
string
- string to repeatcount
- number of times to repeatpublic static Value str_replace(Env env, Value search, Value replace, Value subject, Value count)
search
- search stringreplace
- replacement stringsubject
- replacementcount
- return valuepublic static Value str_rot13(StringValue string)
string
- string to convertpublic static java.lang.String str_shuffle(java.lang.String string)
public static Value str_split(StringValue string, int chunk)
string
- string to splitchunk
- chunk sizepublic static Value str_word_count(StringValue string, int format, java.lang.String additionalWordCharacters)
public static int strcasecmp(StringValue a, StringValue b)
a
- left valueb
- right valuepublic static Value strchr(Env env, StringValue haystack, Value needle)
env
- the calling environmentpublic static int strcmp(StringValue a, StringValue b)
a
- left valueb
- right valuepublic static Value strcoll(java.lang.String a, java.lang.String b)
a
- left valueb
- right valuepublic static Value strcspn(StringValue string, StringValue characters, int offset, int length)
string
- the string to search incharacters
- the character setoffset
- the starting offsetlength
- the lengthpublic static StringValue strip_tags(Env env, StringValue string, Value allowTags)
string
- the string to removeallowTags
- the allowable tagspublic static java.lang.String stripcslashes(java.lang.String source)
source
- the string to cleanaddcslashes(com.caucho.quercus.env.Env, com.caucho.quercus.env.StringValue, java.lang.String)
public static Value stripos(Env env, StringValue haystack, Value needleV, int offset)
haystack
- the full argument to checkneedleV
- the substring argument to checkoffsetV
- optional starting positionpublic static StringValue stripslashes(StringValue string)
string
- the string to cleanpublic static Value stristr(Env env, StringValue haystack, Value needleV)
haystack
- the string to search inneedleV
- the string to search forpublic static Value strlen(Value value)
value
- the argument valuepublic static int strnatcasecmp(StringValue a, StringValue b)
a
- left valueb
- right valuepublic static int strnatcmp(StringValue a, StringValue b)
a
- left valueb
- right valuepublic static Value strncasecmp(Env env, StringValue a, StringValue b, int length)
a
- left valueb
- right valuepublic static Value strncmp(Env env, StringValue a, StringValue b, int length)
a
- left valueb
- right valuepublic static Value strpbrk(StringValue haystack, StringValue charList)
haystack
- the string to search incharList
- list of chars that would trigger matchpublic static Value strpos(Env env, StringValue haystack, Value needleV, int offset)
haystack
- the string to search inneedleV
- the string to search forpublic static Value strrchr(Env env, StringValue haystack, Value needleV)
haystack
- the string to search inneedleV
- the string to search forpublic static Value strrev(StringValue string)
public static Value strripos(Env env, java.lang.String haystack, Value needleV, Value offsetV)
haystack
- the full string to testneedleV
- the substring string to testoffsetV
- the optional offset to start searchingpublic static Value strrpos(Env env, StringValue haystack, Value needleV, Value offsetV)
haystack
- the string to search inneedleV
- the string to search forpublic static Value strspn(StringValue string, StringValue characters, int offset, int length)
string
- the string to search incharacters
- the character setoffset
- the starting offsetlength
- the lengthpublic static Value strstr(Env env, StringValue haystackV, Value needleV)
env
- the calling environmenthaystackV
- the string to search inneedleV
- the string to search for, or the
original value of a characterpublic static Value strtok(Env env, StringValue string1, Value string2)
strtok("hello, world", ", ") => "hello"Subsequent calls pass only the token characters, the next token is returned:
strtok("hello, world", ", ") => "hello" strtok(", ") => "world"False is returned if there are no more tokens:
strtok("hello, world", ", ") => "hello" strtok(", ") => "world" strtok(", ") => falseCalls that pass two arguments reset the search string:
strtok("hello, world", ", ") => "hello" strtok("goodbye, world", ", ") => "goodbye" strtok("world") => false strtok(", ") => false
public static StringValue strtolower(StringValue string)
string
- the input stringpublic static StringValue strtoupper(StringValue string)
string
- the input stringpublic static StringValue strtr(Env env, StringValue string, Value fromV, StringValue to)
string
- the source stringfromV
- the from charactersto
- the to character mappublic static Value substr(Env env, StringValue string, int start, Value lenV)
env
- the calling environmentstring
- the stringstart
- the start offsetlenV
- the optional lengthpublic static Value substr_compare(Env env, StringValue mainStr, StringValue str, int offset, Value lenV, boolean isCaseInsensitive)
public static Value substr_count(Env env, StringValue haystackV, StringValue needleV, int offset, int length)
public static Value substr_replace(Env env, Value subjectV, StringValue replacement, Value startV, Value lengthV)
subjectV
- a string to modify, or an array of strings to modifyreplacement
- the replacement stringstartV
- the start offsetlengthV
- the optional lengthpublic static Value trim(Env env, StringValue string, java.lang.String characters)
string
- the string to be trimmedcharacters
- optional set of characters to trimpublic static StringValue ucfirst(Env env, StringValue string)
string
- the input stringpublic static java.lang.String ucwords(java.lang.String string)
string
- the input stringpublic static int vprintf(Env env, StringValue format, ArrayValue array)
format
- the format stringarray
- the arguments to apply to the format stringpublic static Value vsprintf(Env env, StringValue format, ArrayValue array)
format
- the format stringarray
- the arguments to apply to the format stringpublic static Value wordwrap(Env env, Value value, Value widthV, Value breakV, Value cutV)
string
- the input stringwidth
- the widthbreakString
- the break stringcut
- if true, break on exact matchprotected static boolean isWhitespace(char ch)
protected static char toUpperCase(char ch)
protected static char toUUChar(int d)
protected static char toHexChar(int d)
protected static char toUpperHexChar(int d)
protected static int hexToDigit(char ch)
protected static int octToDigit(char ch)