CkString Python Programming Reference Documentation
CkString
* This is a freeware class/component/library.
Properties
# Returns a boolean value get_Utf8( )
# b is a boolean (input) put_Utf8( b )
When set to true, all "const char *" arguments are expected to be utf-8 strings. If set to false, the "const char *" arguments are expected to be ANSI strings.
Methods
# s is a string (input) append( s )
The inStr is appended to this string (the caller).
# s is a string (input) appendAnsi( s )
Appends an ANSI string to the existing contents of the CkString object.
# c is a char (input) appendChar( c )
Appends a single ANSI character to the string.
appendCurrentDateRfc822( )
To be documented soon...
# s is a string (input) # encoding is a string (input) appendEnc( s, encoding )
Appends a string in any character encoding to the existing contents of the CkString object. Examples of character encodings are: Shift_JIS, windows-1255, iso-8859-2, gb2312, etc.
# n is an integer (input) appendInt( n )
Appends an integer to the string.
# s is a string (input) # numBytes is an integer (input) appendN( s, numBytes )
Appends N characters to the string.
# str is a CkString object (input) appendStr( str )
Appends the contents of another CkString.
# s is a string (input) appendUtf8( s )
Appends a UTF-8 string to the existing contents of the CkString object.
# charset is a string (input) base64Decode( charset )
In-place base64 decodes the string and inteprets the results according to the character encoding specified.
# charset is a string (input) base64Encode( charset )
In-place base64 encodes the string. Internally, the string is first converted to the character encoding specified and then base-64 encoded.
# sSubstr is a string (input) # Returns a boolean value beginsWith( sSubstr )
Returns 1 if the string begins with substr. Otherwise returns 0.
# s is a CkString object (output) # Returns a boolean value beginsWithStr( s )
Returns true if the string begins with the specified substring. Returns True for success, False for failure.
# idx is an integer (input) # Returns a char charAt( idx )
Returns the ANSI character at a specified index.The first character is at index 0.
# c1 is a char (input) chopAtFirstChar( c1 )
Replace the first occurance of a specified ANSI character with a null terminator.
# str is a CkString object (output) chopAtStr( str )
Finds the first occurance of a substring and chops it at that point. The result is that the substring and all subsequent characters are removed from the string. Returns True for success, False for failure.
clear( )
Clears the string. After calling this method, the string has 0 characters.
clone( )
Creates a copy of the string. Returns a null on failure
# str is a CkString object (output) # Returns an integer value compareStr( str )
Compare two strings. A return value = 0 means they are equal. Return value = 1 indicates that calling object is less than argument. Return value = -1 indicates that calling object is greater than argument. Returns True for success, False for failure.
# pattern is a string (input) # Returns a boolean value containsSubstring( pattern )
Returns true if the string contains the specified substring. The substring may be a wildcarded pattern containing the '*' character which matches 0 or more of any character. The matching is case-sensitive.
# pattern is a string (input) # Returns a boolean value containsSubstringNoCase( pattern )
Same as containsSubstring except the matching is case insensitive.
# ch is a char (input) # Returns an integer value countCharOccurances( ch )
To be documented soon.
decodeXMLSpecial( )
Decodes XML special characters.Example: < is converted to '<'
# Returns a floating point value doubleValue( )
Return the string converted to a double.
# ansiChar is a char (input) # startIndex is an integer (input) eliminateChar( ansiChar, startIndex )
Eliminate all occurances of a particular ANSI character.
encodeXMLSpecial( )
Encodes XML special characters.Example: '<' is converted to <
# s is a string (input) # Returns a boolean value endsWith( s )
Returns 1 if the string ends with subStr (case-sensitive). Otherwise returns 0.
# s is a CkString object (output) # Returns a boolean value endsWithStr( s )
Returns true if the string ends with the specified substring. Returns True for success, False for failure.
entityDecode( )
Decodes any HTML entities found within the string, replacing them with the characters represented.
entityEncode( )
HTML encodes any characters that are special to HTML or cannot be represented by 7-bit us-ascii.
# s is a string (input) # Returns a boolean value equals( s )
Returns true if the strings are equal. (case-sensitive)
# s is a string (input) # Returns a boolean value equalsIgnoreCase( s )
Returns true if the strings are equal. (case-insensitive)
# s is a CkString object (output) # Returns a boolean value equalsIgnoreCaseStr( s )
Returns true if the strings are equal. (case-insensitive) Returns True for success, False for failure.
# s is a CkString object (output) # Returns a boolean value equalsStr( s )
Returns true if the strings are equal. (case-sensitive) Returns True for success, False for failure.
# Returns a string getAnsi( )
Return a pointer to the memory containing the string in the ANSI character encoding.
# idx is an integer (input) getChar( idx )
Returns a new CkString object containing the Nth character. (Note, it does not contain the Nth byte, but the Nth character.) For languages such as Chinese, Japanese, etc. individual characters are represented by multiple or varying number of bytes. Returns a null on failure
# encoding is a string (input) # Returns a string getEnc( encoding )
Returns the string converted to any multi-byte character encoding. Examples of character encodings include Shift_JIS, iso-8859-7, windows-1256, etc.
# Returns an integer value getNumChars( )
Returns the number of characters in the string.
# Returns an integer value getSizeAnsi( )
Returns the size, in bytes, of the ANSI representation of the string.
# Returns an integer value getSizeUtf8( )
Returns the size, in bytes, of the utf-8 representation of the string.
# Returns a string getString( )
Returns a pointer to the memory containing the string. The caller should not delete this memory.
# Returns a string getUtf8( )
Return a pointer to memory containing the string in utf-8.
# charset is a string (input) hexDecode( charset )
Hex decodes a string and inteprets the bytes according to the character encoding specified.
# charset is a string (input) hexEncode( charset )
Converts the string to the character encoding specified and replaces the string contents with the hex encoding of the character data.
# s is a string (input) # Returns an integer value indexOf( s )
Returns the index of the first occurance of a substring. Returns -1 if not found.
# s is a CkString object (output) # Returns an integer value indexOfStr( s )
Returns the index of the first occurance of a substring. Returns -1 if not found. Returns True for success, False for failure.
# Returns an integer value intValue( )
Returns the string converted to an integer value.
# Returns a char lastChar( )
Returns the last ANSI character in the string.
# fileName is a string (input) # charset is a string (input) # Returns a boolean value loadFile( fileName, charset )
Loads an entire text file into the string object. The character encoding of the text file is specified by charset. This method allows for text files in any charset to be loaded: utf-8, Unicode, Shift_JIS, iso-8859-1, etc.
# s is a string (input) # Returns a boolean value matches( s )
Returns 1 if the string matches the pattern, which may contain one or more asterisk wildcard characters. Case-sensitivity is controlled by , where 1 = case sensitive, 0 = case insensitive. ASP String Patttern Matching
# str is a CkString object (output) # Returns a boolean value matchesStr( str )
Returns true if the string matches a pattern. The pattern may contain any number of wildcard '*' characters which represent 0 or more occurances of any character. Returns True for success, False for failure.
# s is a string (input) prepend( s )
Prepends inStr to the string (i.e. to the caller).
# charset is a string (input) qpDecode( charset )
Quoted-printable decodes the string and interprets the resulting character data according to the charset (character encoding) specified. The result is that the quoted-printable string is in-place decoded.
# charset is a string (input) qpEncode( charset )
Quoted-printable encodes the string. The string is first converted to the charset specified, and those bytes are QP-encoded. The contents of the string are replaced with the QP-encoded result.
# str is a CkString object (output) # Returns an integer value removeAll( str )
Removes all occurances of a substring. Returns True for success, False for failure.
# c is a char (input) removeCharOccurances( c )
Removes all occurances of a specific character from the string.
# charStartPos is an integer (input) # numChars is an integer (input) removeChunk( charStartPos, numChars )
Removes a chunk of characters specified by starting index and length.
# str is a CkString object (output) # Returns a boolean value removeFirst( str )
Removes the first occurance of a substring. Returns True for success, False for failure.
# str is a CkString object (output) # replacement is a CkString object (output) # Returns an integer value replaceAll( str, replacement )
Replaces all occurances of substr with replacement. (case sensitive) Returns True for success, False for failure.
# pattern is a string (input) # replacement is a string (input) # Returns an integer value replaceAllOccurances( pattern, replacement )
Replaces all occurances of a substring with another substring. If the replacement substring can be empty or differ in length.
# c1 is a char (input) # c2 is a char (input) replaceChar( c1, c2 )
Replaces all occurances of a specified ANSI character with another.
# str is a CkString object (output) # replacement is a CkString object (output) # Returns a boolean value replaceFirst( str, replacement )
Replaces the first occurance of substr with replacement. (case sensitive) Returns True for success, False for failure.
# pattern is a string (input) # replacement is a string (input) # Returns a boolean value replaceFirstOccurance( pattern, replacement )
Replaces the first occurance of a substring with another.
# filename is a string (input) # charset is a string (input) # Returns a boolean value saveToFile( filename, charset )
Saves the string to a file, using the character encoding specified by charset. This method allows for the string to be saved using character encodings such as "utf-8", "Unicode", "Shift-JIS", or anything else...
# s is a CkString object (output) setStr( s )
Replaces the contents of the string with another. Returns True for success, False for failure.
# s is a string (input) setString( s )
Same as clearing the string and appending.
# s is a string (input) setStringAnsi( s )
Set the CkString object from an ANSI string.
# s is a string (input) setStringUtf8( s )
Set the string object from a utf-8 string.
# n is an integer (input) shorten( n )
Removes the final numChars from the string.
# splitChar is a char (input) # exceptDoubleQuoted is a boolean (input) # exceptEscaped is a boolean (input) # keepEmpty is a boolean (input) split( splitChar, exceptDoubleQuoted, exceptEscaped, keepEmpty )
Splits a string into an array of strings using a delimiter character. If "exceptEscaped" is true, then escaped (with a backslash) delimiter chars are ignored. If "exceptDoubleQuoted" is true, then delimiter chars inside quotes are ignored. If keepEmpty is false, then empty strings are excluded from the array.
# splitCharSet is a string (input) # exceptDoubleQuoted is a boolean (input) # exceptEscaped is a boolean (input) # keepEmpty is a boolean (input) split2( splitCharSet, exceptDoubleQuoted, exceptEscaped, keepEmpty )
Same as "split", except a set of characters can be used for delimiters.
splitAtWS( )
Equivalent to split2(" \t\r\n",true,true,false)
# startCharIdx is an integer (input) # numChars is an integer (input) substring( startCharIdx, numChars )
Returns a substring specified by starting character position and number of characters. Returns a null on failure
toCRLF( )
Make all end of lines a CRLF ("\r\n")
toLF( )
Make all end of lines a "\n"
toLowerCase( )
Converts the string to lowercase.
toUpperCase( )
Converts the string to uppercase.
tokenize( punctuation )
Tokenizes a string. The string is split at whitespace characters, and any single punctuation character is returned as a separate token. For example, this string: CkStringArray *CkString::tokenize(char *punctuation) const
is tokenized to
CkStringArray * CkString : : tokenize ( * punctuation ) const
trim( )
Trim SPACE and Tab characters from both ends of the string.
trim2( )
Trim SPACE, Tab, CR, and LF characters from both ends of the string.
trimInsideSpaces( )
Finds and replaces all SPACE chracter runs to single SPACE characters.
# charset is a string (input) urlDecode( charset )
URL decodes the string and interprets the resulting byte data in the charset specified.
# charset is a string (input) urlEncode( charset )
URL encodes the string. The string is first converted to the charset specified, and those bytes are URL-encoded. The contents of the string are replaced with the URL-encoded result.
|