CkString ActiveX Reference Documentation

CkString

The Chilkat string class.

Object Creation

(Visual Basic 6.0)
Dim obj As New CkString

(ASP)
set obj = Server.CreateObject("Chilkat_9_5_0.CkString")

(VBScript)
set obj = CreateObject("Chilkat_9_5_0.CkString")

(Delphi)
obj := TCkString.Create(Self);

(FoxPro)
loObject = CreateObject('Chilkat_9_5_0.CkString')

(PowerBuilder)
lole_object = create oleobject
li_rc = lole_object.ConnectToNewObject("Chilkat_9_5_0.CkString")

(SQL Server)
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.CkString', @obj OUT

(Javascript)
var obj = new ActiveXObject("Chilkat_9_5_0.CkString");

Properties

NumArabic As Long (read-only)

Introduced in version 9.5.0.25

The number of Arabic characters contained in this string.

NumAscii As Long (read-only)

Introduced in version 9.5.0.25

The number of us-ascii characters contained in this string.

NumCentralEuro As Long (read-only)

Introduced in version 9.5.0.25

The number of Central European and Eastern European characters found in this string. These are characters specific to Polish, Czech, Slovak, Hungarian, Slovene, Croatian, Serbian (Latin script), Romanian and Albanian.

NumChars As Long (read-only)

To be documented soon...

NumChinese As Long (read-only)

Introduced in version 9.5.0.25

The number of Chinese characters contained in this string.

NumCyrillic As Long (read-only)

Introduced in version 9.5.0.25

The number of Cyrillic characters contained in this string. The Cyrillic alphabet also called azbuka, from the old name of the first two letters) is actually a family of alphabets, subsets of which are used by certain East and South Slavic languages "” Belarusian, Bulgarian, Macedonian, Russian, Rusyn, Serbian and Ukrainian"”as well as many other languages of the former Soviet Union, Asia and Eastern Europe.

NumGreek As Long (read-only)

Introduced in version 9.5.0.25

The number of Greek characters contained in this string.

NumHebrew As Long (read-only)

Introduced in version 9.5.0.25

The number of Hebrew characters contained in this string.

NumJapanese As Long (read-only)

Introduced in version 9.5.0.25

The number of Japanese characters contained in this string.

NumKorean As Long (read-only)

Introduced in version 9.5.0.25

The number of Korean characters contained in this string.

NumLatin As Long (read-only)

Introduced in version 9.5.0.25

The number of Latin characters contained in this string. Latin characters include all major Western European languages, such as German, Spanish, French, Italian, Nordic languages, etc.

NumThai As Long (read-only)

Introduced in version 9.5.0.25

The number of Thai characters contained in this string.

SizeAnsi As Long (read-only)

The size, in bytes, of the ANSI encoding of the string.

SizeUtf8 As Long (read-only)

The size, in bytes, of the utf-8 encoding of the string.

Str As String

The string value of this object.

Methods

AnsiCharAt(ByVal index As Long) As Long

Returns the ASCII value of the Nth char in the string. The 1st char is at index 0.

Append(str As String)

The str is appended to end of this instance.

AppendDateRfc3339(ByVal dt As Date)

Appends a date/time string in RFC 3339 format to the end of this instance.

AppendDateRfc822(ByVal dateTime As Date)

The dateTime is appended in RFC 822 format to the end of this instance.

AppendEncoded(str As String, encoding As String, charset As String)

Appends characters from an encoded string. The encoding may be "base64", "hex", "url", or "quoted-printable". For example, to append "ABC 123" from a URL-encoded string, call:

strObj.AppendEncoded("ABC+123","url","iso-8859-1")

Supported Character Encodings

AppendMultibyte(mbtext As Variant, charsetEncoding As String)

Appends characters from a byte array. mbtext contains the character data. The input bytes are interpreted according to the character encoding specified by charsetEncoding.

Supported Character Encodings

AppendToFile(path As String, charsetEncoding As String) As Long

Appends the contents of the string to a file. The string is first converted to the character encoding specified by charsetEncoding before being appended to the file.

Supported Character Encodings

BeginsWith(str As String) As Long

Returns 1 if the string begins with str. Otherwise returns 0. This method is case sensitive.

ChopAfter(findStr As String)

Truncates the string after the 1st occurrence of findStr. If findStr is not present, nothing is truncated.

ChopBefore(findStr As String)

Truncates the string before the 1st occurrence of findStr. If findStr is not present, nothing is truncated.

Clear()

Clears the string. After calling this method, the string contains 0 characters.

Contains(substr As String) As Long

Returns 1 if substr is present in the string (case sensitive), otherwise returns 0.

EmitMultibyte(charsetEncoding As String) As Variant

Converts the string to a byte array using the character encoding specified by charsetEncoding.

Returns a zero-length byte array (as a Variant) on failure.
An empty array will have a UBound of -1 meaning 0 elements.

Demystifying ASP Code Pages, Response.Write, Response.BinaryWrite, Strings, and Charsets

Supported Character Encodings

EndsWith(substr As String) As Long

Returns 1 if the string ends with substr (case-sensitive). Otherwise returns 0.

GetEncoded(binaryEncoding As String, charsetEncoding As String) As String

Returns the character string in an encoding use the charsetEncoding specified. The binaryEncoding may be "base64", "hex", "url", or "quoted-printable". For example:

(Visual Basic 6.0)

Dim s As New CkString

s.Str = "èèè"
Text1.Text = s.GetEncoded("hex", "iso-8859-1") & vbCrLf
Text1.Text = Text.Text & s.GetEncoded("hex", "utf-8") & vbCrLf
Text1.Text = Text1.Text & s.GetEncoded("hex", "unicode")

'Output:
'E8E8E8
'C3A8C3A8C3A8
'E800E800E800

Returns Nothing on failure

Supported Character Encodings

HtmlEntityDecode()

Decodes any HTML entities found in the string.

HTML Entity Decode ASP Example

HtmlEntityEncode()

HTML entity encodes all special characters. (Those characters that might require HTML entity encoding.)

ASP HTML Entity Encode Example

LastAnsiChar() As Long

Returns the ASCII value of the last character in the string.

Left(ByVal numChars As Long) As String

Returns a string that is the leftmost numChars of this instance.

Returns Nothing on failure

Length() As Long

Returns the length, in characters, of the string.

LoadFile(path As String, charsetEncoding As String) As Long

Loads an entire text file into the string object. The character encoding of the text file is specified by charsetEncoding. This method allows for text files in any charset to be loaded: utf-8, Unicode, Shift_JIS, iso-8859-1, etc.

Supported Character Encodings

LoadXmlDoc(xmlDocumentBytes As Variant)

Loads an XML document into the CkString. The xmlDocumentBytes contains the raw bytes of the XML document. The reason for providing a separate method for loading an XML document is because the charset encoding is usually specified using a "charset" attribute at the beginning of the XML document. The LoadXmlDoc method reads just enough of the XML document to get the charset, and then it knows how to read and interpret the bytes of the entire XML document, so that the bytes of the characters are properly interpeted and loaded into the CkString object.

Matches(strPattern As String, ByVal caseSensitive As Long) As Long

Returns 1 if the string matches the strPattern, 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

Mid(ByVal index As Long, ByVal numChars As Long) As String

Same as the VB/VBScript "Mid" function, except that the 1st char is at index 0 (i.e. it is not 1-based). Returns a substring of length numChars starting at index.

Returns Nothing on failure

ParseDateRfc3339() As Date

Converts the date string (in RFC 3339 format) to a Date type.

Convert RFC 3339 Date to String and back

ParseDateRfc822() As Date

Converts the date string (in RFC 822 format) to a Date type.

Convert RFC 822 Date to String and back

Pluralize()

Pluralizes an English word.

Pluralize English Word

Prepend(str As String)

Prepends str to this instance.

PunyDecode()

Introduced in version 9.5.0.52

In-place decodes the string from punycode.

(Classic ASP) Punycode Encoding / Decoding

(Visual FoxPro) Punycode Encoding / Decoding

(PowerBuilder) Punycode Encoding / Decoding

(SQL Server) Punycode Encoding / Decoding

(Visual Basic 6.0) Punycode Encoding / Decoding

(VBScript) Punycode Encoding / Decoding

PunyEncode()

Introduced in version 9.5.0.52

In-place encodes the string to punycode.

(Classic ASP) Punycode Encoding / Decoding

(Visual FoxPro) Punycode Encoding / Decoding

(PowerBuilder) Punycode Encoding / Decoding

(SQL Server) Punycode Encoding / Decoding

(Visual Basic 6.0) Punycode Encoding / Decoding

(VBScript) Punycode Encoding / Decoding

RemoveAnsiChar(ByVal ch As Long)

Removes all occurrences of ch from the string.

ReplaceAll(findStr As String, replaceStr As String)

Replaces all occurrences of findStr with replaceStr. (case sensitive)

ReplaceAnsiChar(ByVal findCh As Long, ByVal replaceCh As Long)

Replaces all occurrences of findCh with replaceCh.

ReplaceFirst(findStr As String, replaceStr As String)

Replaces the first occurrence of findStr with replaceStr. (case sensitive)

Right(ByVal numChars As Long) As String

Returns a string that is the rightmost numChars of this instance.

Returns Nothing on failure

SaveToFile(path As String, charsetEncoding As String) As Long

Saves the string to a file, using the character encoding specified by charsetEncoding. This method allows for the string to be saved using character encodings such as "utf-8", "Unicode", "Shift-JIS", or anything else...

Returns 1 for success, 0 for failure.

Supported Character Encodings

Shorten(ByVal numChars As Long)

Removes the final numChars from the string.

StrComp(str As String, ByVal caseSensitive As Long) As Long

Lexicographically compares two strings. Returns 0 if both strings are equal. A value greater than zero indicates that the first character that does not match has a greater value in the caller's string than in str; And a value less than zero indicates the opposite.

StripHtml()

Strips HTML tags from a string.

Strip HTML from a String

ToCRLF()

Converts all line endings to CRLF.

ToLF()

Converts all line endings to bare-LF (Unix/Linux style).

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.

TrimInside()

Replaces all tabs, CR's, and LF's, with SPACE chars, and removes extra SPACE's so there are no occurrences of more than one SPACE char in a row.

Trim Inside SPACE/TAB Characters

Unpluralize()

Unpluralizes an English word.

Unpluralize English Word