TCkString Delphi ActiveX Reference Documentation

TCkString

Current Version: 10.0.0

The Chilkat string class.

Importing the Chilkat ActiveX into Delphi

Important: When upgrading to a new version of Chilkat, make sure to re-imported ActiveX DLL into Delphi to regenerate the files described below.


Chilkat v9.5.*: If using Chilkat v9.5.*, then use "Chilkat_v9_5_0_TLB" instead of "Chilkat_TLB", and the DLLs are named ChilkatAx-9.5.0-win32.dll (or ChilkatAx-9.5.0-x64.dll).


Two things are required to use an ActiveX in Delphi:

  1. The ActiveX DLL needs to be registered via regsvr32 on the system where the Delphi application runs. See How To Register ActiveX DLLs for detailed information.
  2. See also: ActiveX Registration Tutorial
  3. The ActiveX component needs to be "imported". Use the Delphi Import Component Wizard to import the Chilkat type library. This creates the following files: Chilkat_TLB.pas and Chilkat_TLB.dcr. The Chilkat_TLB.pas should be added to your project.

To import the Chilkat type library, do the following:

  1. In the Delphi RAD Studio, select the menu item "Component" --> "Import a Type Library".
  2. Find "Chilkat ActiveX" in the list and select it. This will only appear in the list if the ChilkatAx-win32.dll (or ChilkatAx-x64.dll) has been registered w/ regsvr32.
  3. Check the "Generate Component Wrappers" checkbox.
  4. Select a directory where the unit files (.pas and .dcr) should be generated.
  5. Select "Create Unit" and then "Finish".
  6. Add the .pas to your Delphi project.

To use a Chilkat ActiveX object in your Delphi code, add "Chilkat_TLB" to the "uses" statement. For example:

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;

Object Creation

var
obj: TCkString;
...
begin
obj := TCkString.Create(Self);
...
// When finished, free the object instance.
obj.Free();

Properties

NumArabic
property NumArabic: Integer readonly
Introduced in version 9.5.0.25

The number of Arabic characters contained in this string.

top
NumAscii
property NumAscii: Integer readonly
Introduced in version 9.5.0.25

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

top
NumCentralEuro
property NumCentralEuro: Integer readonly
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
property NumChars: Integer readonly

To be documented soon...

top
NumChinese
property NumChinese: Integer readonly
Introduced in version 9.5.0.25

The number of Chinese characters contained in this string.

top
NumCyrillic
property NumCyrillic: Integer readonly
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
property NumGreek: Integer readonly
Introduced in version 9.5.0.25

The number of Greek characters contained in this string.

top
NumHebrew
property NumHebrew: Integer readonly
Introduced in version 9.5.0.25

The number of Hebrew characters contained in this string.

top
NumJapanese
property NumJapanese: Integer readonly
Introduced in version 9.5.0.25

The number of Japanese characters contained in this string.

top
NumKorean
property NumKorean: Integer readonly
Introduced in version 9.5.0.25

The number of Korean characters contained in this string.

top
NumLatin
property NumLatin: Integer readonly
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
property NumThai: Integer readonly
Introduced in version 9.5.0.25

The number of Thai characters contained in this string.

top
SizeAnsi
property SizeAnsi: Integer readonly

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

top
SizeUtf8
property SizeUtf8: Integer readonly

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

top
Str
property Str: WideString

The string value of this object.

top

Methods

AnsiCharAt
function AnsiCharAt(index: Integer): Integer;

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

top
Append
procedure Append(str: WideString);

The str is appended to end of this instance.

top
AppendDateRfc3339
procedure AppendDateRfc3339(dt: TDateTime);

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

top
AppendDateRfc822
procedure AppendDateRfc822(dateTime: TDateTime);

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

top
AppendEncoded
procedure AppendEncoded(str: WideString; encoding: WideString; charset: WideString);

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
procedure AppendMultibyte(mbtext: OleVariant; charsetEncoding: WideString);

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
function AppendToFile(path: WideString; charsetEncoding: WideString): Integer;

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
function BeginsWith(str: WideString): Integer;

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

top
ChopAfter
procedure ChopAfter(findStr: WideString);

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

top
ChopBefore
procedure ChopBefore(findStr: WideString);

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

top
Clear
procedure Clear();

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

top
Contains
function Contains(substr: WideString): Integer;

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

top
EmitMultibyte
function EmitMultibyte(charsetEncoding: WideString): OleVariant;

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

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

top
EndsWith
function EndsWith(substr: WideString): Integer;

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

top
GetEncoded
function GetEncoded(binaryEncoding: WideString; charsetEncoding: WideString): WideString;

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 a zero-length WideString on failure

More Information and Examples
top
HtmlEntityDecode
procedure HtmlEntityDecode();

Decodes any HTML entities found in the string.

More Information and Examples
top
HtmlEntityEncode
procedure HtmlEntityEncode();

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

More Information and Examples
top
LastAnsiChar
function LastAnsiChar(): Integer;

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

top
Left
function Left(numChars: Integer): WideString;

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

Returns a zero-length WideString on failure

top
Length
function Length(): Integer;

Returns the length, in characters, of the string.

top
LoadFile
function LoadFile(path: WideString; charsetEncoding: WideString): Integer;

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
procedure LoadXmlDoc(xmlDocumentBytes: OleVariant);

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
function Matches(strPattern: WideString; caseSensitive: Integer): Integer;

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
function Mid(index: Integer; numChars: Integer): WideString;

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 a zero-length WideString on failure

top
ParseDateRfc3339
function ParseDateRfc3339(): TDateTime;

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

More Information and Examples
top
ParseDateRfc822
function ParseDateRfc822(): TDateTime;

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

More Information and Examples
top
Pluralize
procedure Pluralize();

Pluralizes an English word.

More Information and Examples
top
Prepend
procedure Prepend(str: WideString);

Prepends str to this instance.

top
PunyDecode
procedure PunyDecode();
Introduced in version 9.5.0.52

In-place decodes the string from punycode.

top
PunyEncode
procedure PunyEncode();
Introduced in version 9.5.0.52

In-place encodes the string to punycode.

top
RemoveAnsiChar
procedure RemoveAnsiChar(ch: Integer);

Removes all occurrences of ch from the string.

top
ReplaceAll
procedure ReplaceAll(findStr: WideString; replaceStr: WideString);

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

top
ReplaceAnsiChar
procedure ReplaceAnsiChar(findCh: Integer; replaceCh: Integer);

Replaces all occurrences of findCh with replaceCh.

top
ReplaceFirst
procedure ReplaceFirst(findStr: WideString; replaceStr: WideString);

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

top
Right
function Right(numChars: Integer): WideString;

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

Returns a zero-length WideString on failure

top
SaveToFile
function SaveToFile(path: WideString; charsetEncoding: WideString): Integer;

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
procedure Shorten(numChars: Integer);

Removes the final numChars from the string.

top
StrComp
function StrComp(str: WideString; caseSensitive: Integer): Integer;

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
procedure StripHtml();

Strips HTML tags from a string.

More Information and Examples
top
ToCRLF
procedure ToCRLF();

Converts all line endings to CRLF.

top
ToLF
procedure ToLF();

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

top
Trim
procedure Trim();

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

top
Trim2
procedure Trim2();

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

top
TrimInside
procedure 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
procedure Unpluralize();

Unpluralizes an English word.

More Information and Examples
top