---
product: Chilkat
product_version: 11.7.0
language: xbase
language_label: Xbase++
class: CkString
license: free
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/xbase_CkStringRef.html
---
# Chilkat CkString — Xbase++ — v11.7.0

> Chilkat 11.7.0 · language=xbase · class=CkString
> Other versions: replace `11.7.0` in this URL. Other languages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/<lang>/classes/CkString.md`.
> Language-wide rules (install, unlock, error model, strings/bytes): `https://www.chilkatsoft.com/ai-docs/v/11.7.0/xbase/guide.md`.

## Purpose

The Chilkat string class.

## Object creation, unlocking and error handling

**Object Creation**

```xbase
LOCAL oCkString
oCkString := CreateObject("Chilkat.CkString")

// ... use oCkString ...

oCkString:destroy()
```

Xbase++ uses the Chilkat ActiveX through the automation object returned by `CreateObject()`; properties and methods are accessed with the send operator (`oHttp:ConnectTimeout := 30`, `oHttp:Download(cUrl, cPath)`), and `:destroy()` releases the object. Register the Chilkat ActiveX matching the bitness of your Xbase++ application. To bind to a specific major version of Chilkat, append the major version number to the ProgID, such as `CreateObject("Chilkat.CkString.11")` for Chilkat v11.\*.\*.

Boolean properties, arguments and return values are integers in the ActiveX: pass `1` or `0`, and test a method's success with `== 1`. A method that fails to return an object returns `NIL`. Objects returned by methods (such as an `HttpResponse` or `JsonObject`) are automation objects too and should likewise be released with `:destroy()`. Methods and properties that pass or return raw byte arrays are not shown on this page; use the `BinData`-based alternatives (methods ending in *Bd*) or the base64 / hex string-encoded variants instead.

Call `Global.UnlockBundle` once at the start of the program, before using this or any other Chilkat class. Any string unlocks a fully functional 30-day trial; a purchased unlock code is used in production. See `guide.md` for the exact code in Xbase++.

How failure is reported depends on the method's return type and is stated in the note under each method below. In every case the diagnostic text is in the `LastErrorText` property of the object whose method was called.

## Member index

| Member | Kind | Signature |
|---|---|---|
| `NumArabic` | property, read-only | `oCkString:NumArabic // Numeric (read-only)` |
| `NumAscii` | property, read-only | `oCkString:NumAscii // Numeric (read-only)` |
| `NumCentralEuro` | property, read-only | `oCkString:NumCentralEuro // Numeric (read-only)` |
| `NumChars` | property, read-only | `oCkString:NumChars // Numeric (read-only)` |
| `NumChinese` | property, read-only | `oCkString:NumChinese // Numeric (read-only)` |
| `NumCyrillic` | property, read-only | `oCkString:NumCyrillic // Numeric (read-only)` |
| `NumGreek` | property, read-only | `oCkString:NumGreek // Numeric (read-only)` |
| `NumHebrew` | property, read-only | `oCkString:NumHebrew // Numeric (read-only)` |
| `NumJapanese` | property, read-only | `oCkString:NumJapanese // Numeric (read-only)` |
| `NumKorean` | property, read-only | `oCkString:NumKorean // Numeric (read-only)` |
| `NumLatin` | property, read-only | `oCkString:NumLatin // Numeric (read-only)` |
| `NumThai` | property, read-only | `oCkString:NumThai // Numeric (read-only)` |
| `SizeAnsi` | property, read-only | `oCkString:SizeAnsi // Numeric (read-only)` |
| `SizeUtf8` | property, read-only | `oCkString:SizeUtf8 // Numeric (read-only)` |
| `Str` | property, read/write | `oCkString:Str // Character` |
| `AnsiCharAt` | method | `nResult := oCkString:AnsiCharAt(nIndex) // returns Numeric` |
| `Append` | method | `oCkString:Append(cStr)` |
| `AppendDateRfc3339` | method | `oCkString:AppendDateRfc3339(dDt)` |
| `AppendDateRfc822` | method | `oCkString:AppendDateRfc822(dDt)` |
| `AppendEncoded` | method | `oCkString:AppendEncoded(cStr, cEncoding, cCharset)` |
| `AppendToFile` | method | `nSuccess := oCkString:AppendToFile(cPath, cCharsetEncoding) // returns Numeric (1/0)` |
| `BeginsWith` | method | `nSuccess := oCkString:BeginsWith(cStr) // returns Numeric (1/0)` |
| `ChopAfter` | method | `oCkString:ChopAfter(cFindStr)` |
| `ChopBefore` | method | `oCkString:ChopBefore(cFindStr)` |
| `Clear` | method | `oCkString:Clear()` |
| `Contains` | method | `nSuccess := oCkString:Contains(cSubstr) // returns Numeric (1/0)` |
| `EndsWith` | method | `nSuccess := oCkString:EndsWith(cSubstr) // returns Numeric (1/0)` |
| `GetEncoded` | method | `cResult := oCkString:GetEncoded(cBinaryEncoding, cCharsetEncoding) // returns Character` |
| `HtmlEntityDecode` | method | `oCkString:HtmlEntityDecode()` |
| `HtmlEntityEncode` | method | `oCkString:HtmlEntityEncode()` |
| `LastAnsiChar` | method | `nResult := oCkString:LastAnsiChar() // returns Numeric` |
| `Left` | method | `cResult := oCkString:Left(nNumChars) // returns Character` |
| `Length` | method | `nResult := oCkString:Length() // returns Numeric` |
| `LoadFile` | method | `nSuccess := oCkString:LoadFile(cPath, cCharsetEncoding) // returns Numeric (1/0)` |
| `Matches` | method | `nSuccess := oCkString:Matches(cStrPattern, lCaseSensitive) // returns Numeric (1/0)` |
| `Mid` | method | `cResult := oCkString:Mid(nIndex, nNumChars) // returns Character` |
| `ParseDateRfc3339` | method | `dResult := oCkString:ParseDateRfc3339() // returns Date` |
| `ParseDateRfc822` | method | `dResult := oCkString:ParseDateRfc822() // returns Date` |
| `Pluralize` | method | `oCkString:Pluralize()` |
| `Prepend` | method | `oCkString:Prepend(cStr)` |
| `PunyDecode` | method | `oCkString:PunyDecode()` |
| `PunyEncode` | method | `oCkString:PunyEncode()` |
| `RemoveAnsiChar` | method | `oCkString:RemoveAnsiChar(nCh)` |
| `ReplaceAll` | method | `oCkString:ReplaceAll(cFindStr, cReplaceStr)` |
| `ReplaceAnsiChar` | method | `oCkString:ReplaceAnsiChar(nFindCh, nReplaceCh)` |
| `ReplaceFirst` | method | `oCkString:ReplaceFirst(cFindStr, cReplaceStr)` |
| `Right` | method | `cResult := oCkString:Right(nNumChars) // returns Character` |
| `SaveToFile` | method | `nSuccess := oCkString:SaveToFile(cPath, cCharsetEncoding) // returns Numeric (1/0)` |
| `Shorten` | method | `oCkString:Shorten(nNumChars)` |
| `StrComp` | method | `nResult := oCkString:StrComp(cStr, lCaseSensitive) // returns Numeric` |
| `StripHtml` | method | `oCkString:StripHtml()` |
| `ToCRLF` | method | `oCkString:ToCRLF()` |
| `ToLF` | method | `oCkString:ToLF()` |
| `Trim` | method | `oCkString:Trim()` |
| `Trim2` | method | `oCkString:Trim2()` |
| `TrimInside` | method | `oCkString:TrimInside()` |
| `Unpluralize` | method | `oCkString:Unpluralize()` |

## Properties

### CkString.NumArabic

`Chilkat 11.7.0 · xbase · CkString · NumArabic · property · read-only · since 9.5.0.25`

```xbase
oCkString:NumArabic  // Numeric (read-only)
```

The number of Arabic characters contained in this string.

### CkString.NumAscii

`Chilkat 11.7.0 · xbase · CkString · NumAscii · property · read-only · since 9.5.0.25`

```xbase
oCkString:NumAscii  // Numeric (read-only)
```

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

### CkString.NumCentralEuro

`Chilkat 11.7.0 · xbase · CkString · NumCentralEuro · property · read-only · since 9.5.0.25`

```xbase
oCkString:NumCentralEuro  // Numeric (read-only)
```

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.

### CkString.NumChars

`Chilkat 11.7.0 · xbase · CkString · NumChars · property · read-only`

```xbase
oCkString:NumChars  // Numeric (read-only)
```

The number of characters in the string.

### CkString.NumChinese

`Chilkat 11.7.0 · xbase · CkString · NumChinese · property · read-only · since 9.5.0.25`

```xbase
oCkString:NumChinese  // Numeric (read-only)
```

The number of Chinese characters contained in this string.

### CkString.NumCyrillic

`Chilkat 11.7.0 · xbase · CkString · NumCyrillic · property · read-only · since 9.5.0.25`

```xbase
oCkString:NumCyrillic  // Numeric (read-only)
```

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.

### CkString.NumGreek

`Chilkat 11.7.0 · xbase · CkString · NumGreek · property · read-only · since 9.5.0.25`

```xbase
oCkString:NumGreek  // Numeric (read-only)
```

The number of Greek characters contained in this string.

### CkString.NumHebrew

`Chilkat 11.7.0 · xbase · CkString · NumHebrew · property · read-only · since 9.5.0.25`

```xbase
oCkString:NumHebrew  // Numeric (read-only)
```

The number of Hebrew characters contained in this string.

### CkString.NumJapanese

`Chilkat 11.7.0 · xbase · CkString · NumJapanese · property · read-only · since 9.5.0.25`

```xbase
oCkString:NumJapanese  // Numeric (read-only)
```

The number of Japanese characters contained in this string.

### CkString.NumKorean

`Chilkat 11.7.0 · xbase · CkString · NumKorean · property · read-only · since 9.5.0.25`

```xbase
oCkString:NumKorean  // Numeric (read-only)
```

The number of Korean characters contained in this string.

### CkString.NumLatin

`Chilkat 11.7.0 · xbase · CkString · NumLatin · property · read-only · since 9.5.0.25`

```xbase
oCkString:NumLatin  // Numeric (read-only)
```

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.

### CkString.NumThai

`Chilkat 11.7.0 · xbase · CkString · NumThai · property · read-only · since 9.5.0.25`

```xbase
oCkString:NumThai  // Numeric (read-only)
```

The number of Thai characters contained in this string.

### CkString.SizeAnsi

`Chilkat 11.7.0 · xbase · CkString · SizeAnsi · property · read-only`

```xbase
oCkString:SizeAnsi  // Numeric (read-only)
```

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

### CkString.SizeUtf8

`Chilkat 11.7.0 · xbase · CkString · SizeUtf8 · property · read-only`

```xbase
oCkString:SizeUtf8  // Numeric (read-only)
```

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

### CkString.Str

`Chilkat 11.7.0 · xbase · CkString · Str · property · read/write`

```xbase
oCkString:Str  // Character
```

The string value of this object.

## Methods

### CkString.AnsiCharAt

`Chilkat 11.7.0 · xbase · CkString · AnsiCharAt · method`

```xbase
nResult := oCkString:AnsiCharAt(nIndex)  // returns Numeric
```

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

### CkString.Append

`Chilkat 11.7.0 · xbase · CkString · Append · method`

```xbase
oCkString:Append(cStr)
```

The `str` is appended to end of this instance.

### CkString.AppendDateRfc3339

`Chilkat 11.7.0 · xbase · CkString · AppendDateRfc3339 · method`

```xbase
oCkString:AppendDateRfc3339(dDt)
```

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

### CkString.AppendDateRfc822

`Chilkat 11.7.0 · xbase · CkString · AppendDateRfc822 · method`

```xbase
oCkString:AppendDateRfc822(dDt)
```

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

### CkString.AppendEncoded

`Chilkat 11.7.0 · xbase · CkString · AppendEncoded · method`

```xbase
oCkString:AppendEncoded(cStr, cEncoding, cCharset)
```

**Full documentation for this method (same in every language):** [Supported Character Encodings](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/charsets_supported_by_chilkat.md)

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)
```

### CkString.AppendToFile

`Chilkat 11.7.0 · xbase · CkString · AppendToFile · method`

```xbase
nSuccess := oCkString:AppendToFile(cPath, cCharsetEncoding)  // returns Numeric (1/0)
```

**Full documentation for this method (same in every language):** [Supported Character Encodings](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/charsets_supported_by_chilkat.md)

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.

### CkString.BeginsWith

`Chilkat 11.7.0 · xbase · CkString · BeginsWith · method`

```xbase
nSuccess := oCkString:BeginsWith(cStr)  // returns Numeric (1/0)
```

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

### CkString.ChopAfter

`Chilkat 11.7.0 · xbase · CkString · ChopAfter · method`

```xbase
oCkString:ChopAfter(cFindStr)
```

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

### CkString.ChopBefore

`Chilkat 11.7.0 · xbase · CkString · ChopBefore · method`

```xbase
oCkString:ChopBefore(cFindStr)
```

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

### CkString.Clear

`Chilkat 11.7.0 · xbase · CkString · Clear · method`

```xbase
oCkString:Clear()
```

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

### CkString.Contains

`Chilkat 11.7.0 · xbase · CkString · Contains · method`

```xbase
nSuccess := oCkString:Contains(cSubstr)  // returns Numeric (1/0)
```

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

### CkString.EndsWith

`Chilkat 11.7.0 · xbase · CkString · EndsWith · method`

```xbase
nSuccess := oCkString:EndsWith(cSubstr)  // returns Numeric (1/0)
```

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

### CkString.GetEncoded

`Chilkat 11.7.0 · xbase · CkString · GetEncoded · method`

```xbase
cResult := oCkString:GetEncoded(cBinaryEncoding, cCharsetEncoding)  // returns Character
```

**Full documentation for this method (same in every language):** [Supported Character Encodings](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/charsets_supported_by_chilkat.md)

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 `NIL` on failure

### CkString.HtmlEntityDecode

`Chilkat 11.7.0 · xbase · CkString · HtmlEntityDecode · method`

```xbase
oCkString:HtmlEntityDecode()
```

Decodes any HTML entities found in the string.

### CkString.HtmlEntityEncode

`Chilkat 11.7.0 · xbase · CkString · HtmlEntityEncode · method`

```xbase
oCkString:HtmlEntityEncode()
```

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

### CkString.LastAnsiChar

`Chilkat 11.7.0 · xbase · CkString · LastAnsiChar · method`

```xbase
nResult := oCkString:LastAnsiChar()  // returns Numeric
```

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

### CkString.Left

`Chilkat 11.7.0 · xbase · CkString · Left · method`

```xbase
cResult := oCkString:Left(nNumChars)  // returns Character
```

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

Returns `NIL` on failure

### CkString.Length

`Chilkat 11.7.0 · xbase · CkString · Length · method`

```xbase
nResult := oCkString:Length()  // returns Numeric
```

Returns the length, in characters, of the string.

### CkString.LoadFile

`Chilkat 11.7.0 · xbase · CkString · LoadFile · method`

```xbase
nSuccess := oCkString:LoadFile(cPath, cCharsetEncoding)  // returns Numeric (1/0)
```

**Full documentation for this method (same in every language):** [Supported Character Encodings](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/charsets_supported_by_chilkat.md)

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.

### CkString.Matches

`Chilkat 11.7.0 · xbase · CkString · Matches · method`

```xbase
nSuccess := oCkString:Matches(cStrPattern, lCaseSensitive)  // returns Numeric (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.

### CkString.Mid

`Chilkat 11.7.0 · xbase · CkString · Mid · method`

```xbase
cResult := oCkString:Mid(nIndex, nNumChars)  // returns Character
```

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 `NIL` on failure

### CkString.ParseDateRfc3339

`Chilkat 11.7.0 · xbase · CkString · ParseDateRfc3339 · method`

```xbase
dResult := oCkString:ParseDateRfc3339()  // returns Date
```

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

### CkString.ParseDateRfc822

`Chilkat 11.7.0 · xbase · CkString · ParseDateRfc822 · method`

```xbase
dResult := oCkString:ParseDateRfc822()  // returns Date
```

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

### CkString.Pluralize

`Chilkat 11.7.0 · xbase · CkString · Pluralize · method`

```xbase
oCkString:Pluralize()
```

Pluralizes an English word.

### CkString.Prepend

`Chilkat 11.7.0 · xbase · CkString · Prepend · method`

```xbase
oCkString:Prepend(cStr)
```

Prepends `str` to this instance.

### CkString.PunyDecode

`Chilkat 11.7.0 · xbase · CkString · PunyDecode · method · since 9.5.0.52`

```xbase
oCkString:PunyDecode()
```

In-place decodes the string from punycode.

### CkString.PunyEncode

`Chilkat 11.7.0 · xbase · CkString · PunyEncode · method · since 9.5.0.52`

```xbase
oCkString:PunyEncode()
```

In-place encodes the string to punycode.

### CkString.RemoveAnsiChar

`Chilkat 11.7.0 · xbase · CkString · RemoveAnsiChar · method`

```xbase
oCkString:RemoveAnsiChar(nCh)
```

Removes all occurrences of `ch` from the string.

### CkString.ReplaceAll

`Chilkat 11.7.0 · xbase · CkString · ReplaceAll · method`

```xbase
oCkString:ReplaceAll(cFindStr, cReplaceStr)
```

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

### CkString.ReplaceAnsiChar

`Chilkat 11.7.0 · xbase · CkString · ReplaceAnsiChar · method`

```xbase
oCkString:ReplaceAnsiChar(nFindCh, nReplaceCh)
```

Replaces all occurrences of `findCh` with `replaceCh`.

### CkString.ReplaceFirst

`Chilkat 11.7.0 · xbase · CkString · ReplaceFirst · method`

```xbase
oCkString:ReplaceFirst(cFindStr, cReplaceStr)
```

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

### CkString.Right

`Chilkat 11.7.0 · xbase · CkString · Right · method`

```xbase
cResult := oCkString:Right(nNumChars)  // returns Character
```

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

Returns `NIL` on failure

### CkString.SaveToFile

`Chilkat 11.7.0 · xbase · CkString · SaveToFile · method`

```xbase
nSuccess := oCkString:SaveToFile(cPath, cCharsetEncoding)  // returns Numeric (1/0)
```

**Full documentation for this method (same in every language):** [Supported Character Encodings](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/charsets_supported_by_chilkat.md)

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.

### CkString.Shorten

`Chilkat 11.7.0 · xbase · CkString · Shorten · method`

```xbase
oCkString:Shorten(nNumChars)
```

Removes the final `numChars` from the string.

### CkString.StrComp

`Chilkat 11.7.0 · xbase · CkString · StrComp · method`

```xbase
nResult := oCkString:StrComp(cStr, lCaseSensitive)  // returns Numeric
```

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.

### CkString.StripHtml

`Chilkat 11.7.0 · xbase · CkString · StripHtml · method`

```xbase
oCkString:StripHtml()
```

Strips HTML tags from a string.

### CkString.ToCRLF

`Chilkat 11.7.0 · xbase · CkString · ToCRLF · method`

```xbase
oCkString:ToCRLF()
```

Converts all line endings to CRLF.

### CkString.ToLF

`Chilkat 11.7.0 · xbase · CkString · ToLF · method`

```xbase
oCkString:ToLF()
```

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

### CkString.Trim

`Chilkat 11.7.0 · xbase · CkString · Trim · method`

```xbase
oCkString:Trim()
```

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

### CkString.Trim2

`Chilkat 11.7.0 · xbase · CkString · Trim2 · method`

```xbase
oCkString:Trim2()
```

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

### CkString.TrimInside

`Chilkat 11.7.0 · xbase · CkString · TrimInside · method`

```xbase
oCkString: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.

### CkString.Unpluralize

`Chilkat 11.7.0 · xbase · CkString · Unpluralize · method`

```xbase
oCkString:Unpluralize()
```

Unpluralizes an English word.

