CkString Classic ASP Reference Documentation

CkString

Current Version: 11.6.0

The Chilkat string class.

Object Creation

set ckString = Server.CreateObject("Chilkat.CkString")

' ... use ckString ...

set ckString = Nothing

Classic ASP creates Chilkat objects with Server.CreateObject. The registered Chilkat ActiveX must match the bitness of the IIS application pool: a pool with Enable 32-Bit Applications set to True needs the 32-bit ActiveX, otherwise the 64-bit ActiveX. To bind to a specific major version of Chilkat, append the major version number to the ProgID, such as Server.CreateObject("Chilkat.CkString.11") for Chilkat v11.*.*.

VBScript requires set when assigning an object, so the signatures on this page show set x = obj.Method(...) for methods that return a Chilkat object; test the result with Is Nothing, since a method that fails to return an object returns Nothing. A method with no return value is called as a statement without parentheses (obj.Method arg1, arg2). Boolean properties, arguments and return values are integers in the ActiveX: pass 1 or 0, and test success with = 1. Byte arrays are Variant arrays and can be sent with Response.BinaryWrite. Asynchronous (*Async) methods and event callbacks are not used from Classic ASP.

Properties

NumArabic
ckString.NumArabic ' Long (read-only)
Introduced in version 9.5.0.25

The number of Arabic characters contained in this string.

top
NumAscii
ckString.NumAscii ' Long (read-only)
Introduced in version 9.5.0.25

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

top
NumCentralEuro
ckString.NumCentralEuro ' 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.

top
NumChars
ckString.NumChars ' Long (read-only)

To be documented soon...

top
NumChinese
ckString.NumChinese ' Long (read-only)
Introduced in version 9.5.0.25

The number of Chinese characters contained in this string.

top
NumCyrillic
ckString.NumCyrillic ' 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.

top
NumGreek
ckString.NumGreek ' Long (read-only)
Introduced in version 9.5.0.25

The number of Greek characters contained in this string.

top
NumHebrew
ckString.NumHebrew ' Long (read-only)
Introduced in version 9.5.0.25

The number of Hebrew characters contained in this string.

top
NumJapanese
ckString.NumJapanese ' Long (read-only)
Introduced in version 9.5.0.25

The number of Japanese characters contained in this string.

top
NumKorean
ckString.NumKorean ' Long (read-only)
Introduced in version 9.5.0.25

The number of Korean characters contained in this string.

top
NumLatin
ckString.NumLatin ' 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.

Note: This is the number of chars that are Latin characters that do not fall in the us-ascii range. In other words, the 8bit Latin chars.

top
NumThai
ckString.NumThai ' Long (read-only)
Introduced in version 9.5.0.25

The number of Thai characters contained in this string.

top
SizeAnsi
ckString.SizeAnsi ' Long (read-only)

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

top
SizeUtf8
ckString.SizeUtf8 ' Long (read-only)

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

top
Str
ckString.Str ' String

The string value of this object.

top

Methods

AnsiCharAt
n = ckString.AnsiCharAt(index) ' Long

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

top
Append
ckString.Append str

The str is appended to end of this instance.

top
AppendDateRfc3339
ckString.AppendDateRfc3339 dt

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

top
AppendDateRfc822
ckString.AppendDateRfc822 dateTime

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

top
AppendEncoded
ckString.AppendEncoded str, encoding, charset

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)

More Information and Examples
top
AppendMultibyte
ckString.AppendMultibyte mbtext, charsetEncoding

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

More Information and Examples
top
AppendToFile
success = ckString.AppendToFile(path, charsetEncoding) ' Long (1/0)

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.

More Information and Examples
top
BeginsWith
success = ckString.BeginsWith(str) ' Long (1/0)

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

top
ChopAfter
ckString.ChopAfter findStr

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

top
ChopBefore
ckString.ChopBefore findStr

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

top
Clear
ckString.Clear

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

top
Contains
success = ckString.Contains(substr) ' Long (1/0)

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

top
EmitMultibyte
bytes = ckString.EmitMultibyte(charsetEncoding) ' 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.

top
EndsWith
success = ckString.EndsWith(substr) ' Long (1/0)

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

top
GetEncoded
str = ckString.GetEncoded(binaryEncoding, charsetEncoding) ' 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

More Information and Examples
top
HtmlEntityDecode
ckString.HtmlEntityDecode

Decodes any HTML entities found in the string.

More Information and Examples
top
HtmlEntityEncode
ckString.HtmlEntityEncode

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

More Information and Examples
top
LastAnsiChar
n = ckString.LastAnsiChar() ' Long

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

top
Left
str = ckString.Left(numChars) ' String

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

Returns Nothing on failure

top
Length
n = ckString.Length() ' Long

Returns the length, in characters, of the string.

top
LoadFile
success = ckString.LoadFile(path, charsetEncoding) ' Long (1/0)

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.

More Information and Examples
top
LoadXmlDoc
ckString.LoadXmlDoc xmlDocumentBytes

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.

top
Matches
success = ckString.Matches(strPattern, caseSensitive) ' Long (1/0)

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.

More Information and Examples
top
Mid
str = ckString.Mid(index, numChars) ' 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

top
ParseDateRfc3339
dt = ckString.ParseDateRfc3339() ' Date

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

More Information and Examples
top
ParseDateRfc822
dt = ckString.ParseDateRfc822() ' Date

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

More Information and Examples
top
Pluralize
ckString.Pluralize

Pluralizes an English word.

More Information and Examples
top
Prepend
ckString.Prepend str

Prepends str to this instance.

top
PunyDecode
ckString.PunyDecode
Introduced in version 9.5.0.52

In-place decodes the string from punycode.

top
PunyEncode
ckString.PunyEncode
Introduced in version 9.5.0.52

In-place encodes the string to punycode.

top
RemoveAnsiChar
ckString.RemoveAnsiChar ch

Removes all occurrences of ch from the string.

top
ReplaceAll
ckString.ReplaceAll findStr, replaceStr

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

top
ReplaceAnsiChar
ckString.ReplaceAnsiChar findCh, replaceCh

Replaces all occurrences of findCh with replaceCh.

top
ReplaceFirst
ckString.ReplaceFirst findStr, replaceStr

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

top
Right
str = ckString.Right(numChars) ' String

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

Returns Nothing on failure

top
SaveToFile
success = ckString.SaveToFile(path, charsetEncoding) ' Long (1/0)

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.

More Information and Examples
top
Shorten
ckString.Shorten numChars

Removes the final numChars from the string.

top
StrComp
n = ckString.StrComp(str, caseSensitive) ' 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.

top
StripHtml
ckString.StripHtml

Strips HTML tags from a string.

More Information and Examples
top
ToCRLF
ckString.ToCRLF

Converts all line endings to CRLF.

top
ToLF
ckString.ToLF

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

top
Trim
ckString.Trim

Trim SPACE and Tab characters from both ends of the string.

top
Trim2
ckString.Trim2

Trim SPACE, Tab, CR, and LF characters from both ends of the string.

top
TrimInside
ckString.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.

More Information and Examples
top
Unpluralize
ckString.Unpluralize

Unpluralizes an English word.

More Information and Examples
top