com.caucho.quercus.lib.string
Class StringModule

java.lang.Object
  extended by com.caucho.quercus.module.AbstractQuercusModule
      extended by com.caucho.quercus.lib.string.StringModule
All Implemented Interfaces:
QuercusModule

public class StringModule
extends AbstractQuercusModule

PHP functions implemented from the string module


Field Summary
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
           
 
Fields inherited from class com.caucho.quercus.module.AbstractQuercusModule
PHP_INI_ALL, PHP_INI_PERDIR, PHP_INI_SYSTEM, PHP_INI_USER
 
Constructor Summary
StringModule()
           
 
Method Summary
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.
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.lang.String source, 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(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(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(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(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.
 
Methods inherited from class com.caucho.quercus.module.AbstractQuercusModule
addConstant, addConstant, addConstant, getConstMap, getIniDefinitions, getLoadedExtensions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CRYPT_SALT_LENGTH

public static final int CRYPT_SALT_LENGTH
See Also:
Constant Field Values

CRYPT_STD_DES

public static final int CRYPT_STD_DES
See Also:
Constant Field Values

CRYPT_EXT_DES

public static final int CRYPT_EXT_DES
See Also:
Constant Field Values

CRYPT_MD5

public static final int CRYPT_MD5
See Also:
Constant Field Values

CRYPT_BLOWFISH

public static final int CRYPT_BLOWFISH
See Also:
Constant Field Values

CHAR_MAX

public static final int CHAR_MAX
See Also:
Constant Field Values

LC_CTYPE

public static final int LC_CTYPE
See Also:
Constant Field Values

LC_NUMERIC

public static final int LC_NUMERIC
See Also:
Constant Field Values

LC_TIME

public static final int LC_TIME
See Also:
Constant Field Values

LC_COLLATE

public static final int LC_COLLATE
See Also:
Constant Field Values

LC_MONETARY

public static final int LC_MONETARY
See Also:
Constant Field Values

LC_ALL

public static final int LC_ALL
See Also:
Constant Field Values

LC_MESSAGES

public static final int LC_MESSAGES
See Also:
Constant Field Values

STR_PAD_LEFT

public static final int STR_PAD_LEFT
See Also:
Constant Field Values

STR_PAD_RIGHT

public static final int STR_PAD_RIGHT
See Also:
Constant Field Values

STR_PAD_BOTH

public static final int STR_PAD_BOTH
See Also:
Constant Field Values
Constructor Detail

StringModule

public StringModule()
Method Detail

addcslashes

public static StringValue addcslashes(Env env,
                                      StringValue source,
                                      java.lang.String characters)
Escapes a string using C syntax.

Parameters:
source - the source string to convert
characters - the set of characters to convert
Returns:
the escaped string
See Also:
stripcslashes(java.lang.String)

addslashes

public static StringValue addslashes(StringValue source)
Escapes a string for db characters.

Parameters:
source - the source string to convert
Returns:
the escaped string

bin2hex

public static StringValue bin2hex(Env env,
                                  java.io.InputStream is)
Converts a binary value to a hex value.


chop

public static StringValue chop(Env env,
                               StringValue str,
                               java.lang.String charset)
Alias of rtrim. Removes trailing whitespace.

Parameters:
env - the quercus environment
str - the string to be trimmed
charset - optional set of characters to trim
Returns:
the trimmed string

chr

public static StringValue chr(Env env,
                              long value)
converts a number to its character equivalent

Parameters:
value - the integer value
Returns:
the string equivalent

chunk_split

public static java.lang.String chunk_split(java.lang.String body,
                                           int chunkLen,
                                           java.lang.String end)
Splits a string into chunks

Parameters:
body - the body string
chunkLen - the optional chunk length, defaults to 76
end - the optional end value, defaults to "\r\n"

convert_cyr_string

public 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. This implementation does nothing, because quercus stores strings as 16 bit unicode.


convert_uudecode

public static Value convert_uudecode(Env env,
                                     StringValue source)

convert_uuencode

public static Value convert_uuencode(StringValue source)
uuencode a string.


count_chars

public static Value count_chars(StringValue data,
                                int mode)
Returns an array of information about the characters.


crc32

public static long crc32(StringValue str)
Calculates the crc32 value for a string

Parameters:
str - the string value
Returns:
the crc32 hash

crypt

public static java.lang.String crypt(java.lang.String string,
                                     java.lang.String salt)

explode

public static Value explode(Env env,
                            StringValue separator,
                            StringValue string,
                            long limit)
Explodes a string into an array

Parameters:
separator - the separator string
string - the string to be exploded
limit - the max number of elements
Returns:
an array of exploded values

fprintf

public static Value fprintf(Env env,
                            BinaryOutput os,
                            StringValue format,
                            Value[] args)
Use printf style formatting to write a string to a file.

Parameters:
fd - the file to write to
format - the format string
args - the valujes to apply to the format string

implode

public static Value implode(Env env,
                            Value glueV,
                            Value piecesV)
implodes an array into a string

Parameters:
glueV - the separator string
piecesV - the array to be imploded
Returns:
a string of imploded values

join

public static Value join(Env env,
                         Value glueV,
                         Value piecesV)
implodes an array into a string

Parameters:
glueV - the separator string
piecesV - the array to be imploded
Returns:
a string of imploded values

localeconv

public static ArrayValue localeconv(Env env)
Gets locale-specific symbols. XXX: locale charset


ltrim

public static StringValue ltrim(Env env,
                                StringValue string,
                                java.lang.String characters)
Removes leading whitespace.

Parameters:
string - the string to be trimmed
characters - optional set of characters to trim
Returns:
the trimmed string

md5

public static Value md5(Env env,
                        java.io.InputStream is,
                        boolean rawOutput)
returns the md5 hash

Parameters:
source - the string
rawOutput - if true, return the raw binary
Returns:
a string of imploded values

md5_file

public static Value md5_file(Env env,
                             Path source,
                             boolean rawOutput)
returns the md5 hash

Parameters:
source - the string
rawOutput - if true, return the raw binary
Returns:
a string of imploded values

metaphone

public static java.lang.String metaphone(java.lang.String string)
Returns the metaphone of a string. This implementation produces identical results to the php version, which does contain some bugs.


money_format

public static java.lang.String money_format(Env env,
                                            java.lang.String format,
                                            double value)
Returns a formatted money value. XXX: locale charset

Parameters:
format - the format
value - the value
Returns:
a string of formatted values

number_format

public static java.lang.String number_format(Env env,
                                             double value,
                                             int decimals,
                                             Value pointValue,
                                             Value groupValue)
Returns a formatted number.

Parameters:
value - the value
decimals - the number of decimals
pointValue - the decimal point string
groupValue - the thousands separator
Returns:
a string of the formatted number

ord

public static long ord(StringValue string)
Converts the first character to an integer.

Parameters:
string - the string to be converted
Returns:
the integer value

parse_str

public static Value parse_str(Env env,
                              StringValue str,
                              Value ref)
Parses the string as a query string.

Parameters:
env - the calling environment
str - the query string
array - the optional result array

print

public static long print(Env env,
                         Value value)
Prints the string.

Parameters:
env - the quercus environment
value - the string to print

printf

public static int printf(Env env,
                         StringValue format,
                         Value[] args)
print to the output with a formatter

Parameters:
env - the quercus environment
format - the format string
args - the format arguments
Returns:
the formatted string

quoted_printable_decode

public static java.lang.String quoted_printable_decode(java.lang.String str)
Converts a RFC2045 quoted printable string to a string.


quotemeta

public static Value quotemeta(StringValue string)
Escapes meta characters.

Parameters:
string - the string to be quoted
Returns:
the quoted

rtrim

public static StringValue rtrim(Env env,
                                StringValue string,
                                java.lang.String characters)
Removes trailing whitespace.

Parameters:
env - the quercus environment
string - the string to be trimmed
characters - optional set of characters to trim
Returns:
the trimmed string

setlocale

public static Value setlocale(Env env,
                              int category,
                              Value localeArg,
                              Value[] fallback)
Sets locale configuration.


sha1

public static Value sha1(Env env,
                         java.lang.String source,
                         boolean rawOutput)
returns the md5 hash

Parameters:
source - the string
rawOutput - if true, return the raw binary
Returns:
a string of imploded values

sha1_file

public static Value sha1_file(Env env,
                              Path source,
                              boolean rawOutput)
returns the md5 hash

Parameters:
source - the string
rawOutput - if true, return the raw binary
Returns:
a string of imploded values

soundex

public static Value soundex(StringValue string)

sprintf

public static Value sprintf(Env env,
                            StringValue format,
                            Value[] args)
Print to a string with a formatter

Parameters:
format - the format string
args - the format arguments
Returns:
the formatted string

sscanf

public static Value sscanf(Env env,
                           StringValue string,
                           StringValue format,
                           Value[] args)
scans a string

Parameters:
format - the format string
args - the format arguments
Returns:
the formatted string

sscanfOld

public static Value sscanfOld(Env env,
                              StringValue string,
                              StringValue format,
                              Value[] args)
scans a string

Parameters:
format - the format string
args - the format arguments
Returns:
the formatted string

str_ireplace

public static Value str_ireplace(Env env,
                                 Value search,
                                 Value replace,
                                 Value subject,
                                 Value count)
replaces substrings.

Parameters:
search - search string
replace - replacement string
subject - replacement
count - return value

str_pad

public static StringValue str_pad(StringValue string,
                                  int length,
                                  java.lang.String pad,
                                  int type)
Pads strings

Parameters:
string - string
length - length
pad - padding string
type - padding type

str_repeat

public static Value str_repeat(StringValue string,
                               int count)
repeats a string

Parameters:
string - string to repeat
count - number of times to repeat

str_replace

public static Value str_replace(Env env,
                                Value search,
                                Value replace,
                                Value subject,
                                Value count)
replaces substrings.

Parameters:
search - search string
replace - replacement string
subject - replacement
count - return value

str_rot13

public static Value str_rot13(StringValue string)
rot13 conversion

Parameters:
string - string to convert

str_shuffle

public static java.lang.String str_shuffle(java.lang.String string)
shuffles a string


str_split

public static Value str_split(StringValue string,
                              int chunk)
split into an array

Parameters:
string - string to split
chunk - chunk size

str_word_count

public static Value str_word_count(StringValue string,
                                   int format,
                                   java.lang.String additionalWordCharacters)

strcasecmp

public static int strcasecmp(StringValue a,
                             StringValue b)
Case-insensitive comparison

Parameters:
a - left value
b - right value
Returns:
-1, 0, or 1

strchr

public static Value strchr(Env env,
                           StringValue haystack,
                           Value needle)
Finds the index of a substring

Parameters:
env - the calling environment

strcmp

public static int strcmp(StringValue a,
                         StringValue b)
Case-sensitive comparison

Parameters:
a - left value
b - right value
Returns:
-1, 0, or 1

strcoll

public static Value strcoll(java.lang.String a,
                            java.lang.String b)
Locale-based comparison XXX: i18n

Parameters:
a - left value
b - right value
Returns:
-1, 0, or 1

strcspn

public 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

Parameters:
string - the string to search in
characters - the character set
offset - the starting offset
length - the length
Returns:
the length of the match or FALSE if the offset or length are invalid

strip_tags

public static StringValue strip_tags(StringValue string,
                                     Value allowTags)
Removes tags from a string.

Parameters:
string - the string to remove
allowTags - the allowable tags

stripcslashes

public static java.lang.String stripcslashes(java.lang.String source)
Strip out the backslashes, recognizing the escape sequences, octal, and hexadecimal representations.

Parameters:
source - the string to clean
See Also:
addcslashes(com.caucho.quercus.env.Env, com.caucho.quercus.env.StringValue, java.lang.String)

stripos

public static Value stripos(Env env,
                            StringValue haystack,
                            Value needleV,
                            int offset)
Returns the position of a substring, testing case insensitive.

Parameters:
haystack - the full argument to check
needleV - the substring argument to check
offsetV - optional starting position

stripslashes

public static StringValue stripslashes(StringValue string)
Strips out the backslashes.

Parameters:
string - the string to clean

stristr

public static Value stristr(StringValue haystack,
                            Value needleV)
Finds the first instance of a substring, testing case insensitively

Parameters:
haystack - the string to search in
needleV - the string to search for
Returns:
the trailing match or FALSE

strlen

public static Value strlen(Value value)
Returns the length of a string.

Parameters:
value - the argument value

strnatcasecmp

public static int strnatcasecmp(StringValue a,
                                StringValue b)
Case-insensitive comparison

Parameters:
a - left value
b - right value
Returns:
-1, 0, or 1

strnatcmp

public static int strnatcmp(StringValue a,
                            StringValue b)
Case-sensitive comparison

Parameters:
a - left value
b - right value
Returns:
-1, 0, or 1

strncasecmp

public static Value strncasecmp(Env env,
                                StringValue a,
                                StringValue b,
                                int length)
Case-insensitive comparison

Parameters:
a - left value
b - right value
Returns:
-1, 0, or 1

strncmp

public static Value strncmp(Env env,
                            StringValue a,
                            StringValue b,
                            int length)
Case-sensitive comparison

Parameters:
a - left value
b - right value
Returns:
-1, 0, or 1

strpbrk

public static Value strpbrk(StringValue haystack,
                            StringValue charList)
Returns a substring of haystack starting from the earliest occurence of any char in charList

Parameters:
haystack - the string to search in
charList - list of chars that would trigger match
Returns:
substring, else FALSE

strpos

public static Value strpos(Env env,
                           StringValue haystack,
                           Value needleV,
                           int offset)
Returns the position of a substring.

Parameters:
haystack - the string to search in
needleV - the string to search for

strrchr

public static Value strrchr(StringValue haystack,
                            Value needleV)
Finds the last instance of a substring

Parameters:
haystack - the string to search in
needleV - the string to search for
Returns:
the trailing match or FALSE

strrev

public static Value strrev(StringValue string)
Reverses a string.


strripos

public static Value strripos(Env env,
                             java.lang.String haystack,
                             Value needleV,
                             Value offsetV)
Returns the position of a substring, testing case-insensitive.

Parameters:
haystack - the full string to test
needleV - the substring string to test
offsetV - the optional offset to start searching

strrpos

public static Value strrpos(Env env,
                            StringValue haystack,
                            Value needleV,
                            Value offsetV)
Returns the position of a substring.

Parameters:
haystack - the string to search in
needleV - the string to search for

strspn

public 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

Parameters:
string - the string to search in
characters - the character set
offset - the starting offset
length - the length
Returns:
the length of the match or FALSE if the offset or length are invalid

strstr

public 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.

Parameters:
env - the calling environment
haystackV - the string to search in
needleV - the string to search for, or the original value of a character
Returns:
the trailing match or FALSE if needle is not found

strtok

public static Value strtok(Env env,
                           StringValue string1,
                           Value string2)
Split a string into tokens using any character in another string as a delimiter. The first call establishes the string to search and the characters to use as tokens, the first token is returned:
   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(", ")
     => false
 
Calls that pass two arguments reset the search string:
   strtok("hello, world", ", ")
     => "hello"
   strtok("goodbye, world", ", ")
     => "goodbye"
   strtok("world")
     => false
   strtok(", ")
     => false
 


strtolower

public static StringValue strtolower(StringValue string)
Converts to lower case.

Parameters:
string - the input string

strtoupper

public static StringValue strtoupper(StringValue string)
Converts to upper case.

Parameters:
string - the input string

strtr

public static StringValue strtr(Env env,
                                StringValue string,
                                Value fromV,
                                StringValue to)
Translates characters in a string to target values.

Parameters:
string - the source string
fromV - the from characters
to - the to character map

substr

public static Value substr(Env env,
                           StringValue string,
                           int start,
                           Value lenV)
Returns a substring

Parameters:
env - the calling environment
string - the string
start - the start offset
lenV - the optional length

substr_compare

public static Value substr_compare(Env env,
                                   StringValue mainStr,
                                   StringValue str,
                                   int offset,
                                   Value lenV,
                                   boolean isCaseInsensitive)

substr_count

public static Value substr_count(Env env,
                                 StringValue haystackV,
                                 StringValue needleV,
                                 int offset,
                                 int length)

substr_replace

public static Value substr_replace(Value subjectV,
                                   StringValue replacement,
                                   Value startV,
                                   Value lengthV)
Replaces a substring with a replacement

Parameters:
subjectV - a string to modify, or an array of strings to modify
replacement - the replacement string
startV - the start offset
lengthV - the optional length

trim

public static Value trim(Env env,
                         StringValue string,
                         java.lang.String characters)
Removes leading and trailing whitespace.

Parameters:
string - the string to be trimmed
characters - optional set of characters to trim
Returns:
the trimmed string

ucfirst

public static StringValue ucfirst(Env env,
                                  StringValue string)
Uppercases the first character

Parameters:
string - the input string

ucwords

public static java.lang.String ucwords(java.lang.String string)
Uppercases the first character of each word

Parameters:
string - the input string

vprintf

public static int vprintf(Env env,
                          StringValue format,
                          ArrayValue array)
Formatted strings with array arguments

Parameters:
format - the format string
array - the arguments to apply to the format string

vsprintf

public static Value vsprintf(Env env,
                             StringValue format,
                             ArrayValue array)
Formatted strings with array arguments

Parameters:
format - the format string
array - the arguments to apply to the format string

wordwrap

public static Value wordwrap(Env env,
                             Value value,
                             Value widthV,
                             Value breakV,
                             Value cutV)
Wraps a string to the given number of characters.

Parameters:
string - the input string
width - the width
breakString - the break string
cut - if true, break on exact match

isWhitespace

protected static boolean isWhitespace(char ch)
Returns true if the character is a whitespace character.


toUpperCase

protected static char toUpperCase(char ch)
Returns the uppercase equivalent of the caharacter


toUUChar

protected static char toUUChar(int d)
Converts an integer digit to a uuencoded char.


toHexChar

protected static char toHexChar(int d)

toUpperHexChar

protected static char toUpperHexChar(int d)

hexToDigit

protected static int hexToDigit(char ch)

octToDigit

protected static int octToDigit(char ch)