[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'sysutils' (#rtl)

# TEncoding

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Encoding support

## Declaration

Source position: sysencodingh.inc line 21

`type TEncoding = class`
`public`
`function Clone; virtual;` |  | Clone a TEncoding instance
`class function Convert();` |  | Convert an array of bytes from one encoding to another
`class function IsStandardEncoding();` |  | Check if the encoding is one of the standard encodings
`class function GetBufferEncoding();` |  | Attempt to guess the encoding of a buffer
`class function GetEncoding();` |  | Get an encoding instance for a given codepage.
`function GetMaxByteCount(); virtual; abstract;` |  | Returns the maximum number of bytes needed to represent a string
`function GetMaxCharCount(); virtual; abstract;` |  | Return the maximum number of characters that can be represented in a number of bytes
`function GetPreamble; virtual; abstract;` |  | Return the BOM Marker used by the encoding
`function GetString();` |  | Return a string based on an array of bytes
`property CodePage: Cardinal; [r]` |  | Codepage for this encoding
`property EncodingName: UnicodeString; [r]` |  | Name of this encoding
`property IsSingleByte: Boolean; [r]` |  | Is the encoding a single-byte encoding or not ?
`property ANSI: TEncoding; [r]` |  | Ansi encoding instance
`property ASCII: TEncoding; [r]` |  | ASCII encoding instance
`property BigEndianUnicode: TEncoding; [r]` |  | Big-endian Unicode (UTF16BE) encoding instance
`property Default: TEncoding; [r]` |  | Default codepage
`property SystemEncoding: TEncoding; [r]`
`property Unicode: TEncoding; [r]` |  | UTF16 encoding instance
`property UTF7: TEncoding; [r]` |  | UTF7 encoding instance
`property UTF8: TEncoding; [r]` |  | UTF8 encoding instance
`end;`

## Inheritance

`TEncoding` |  | Encoding support
`TObject`

## Description

TEncoding is a mostly abstract class that contains various methods to deal with different encodings in single- and double-byte strings. In practice, one instance of a descendent of this class for each needed encoding can be instantiated and used. The class contains several class methods and properties to create such instances, and has several often-used instances available as class properties, in particular the default encoding.

When using encodings (and in particular TEncoding.Default or TEncoding.ANSI), if the DefaultSystemCodePage changes, you should call TEncoding.FreeEncodings to regenerate the encodings.

## See also

TEncoding.ANSI |  | Ansi encoding instance
TEncoding.ASCII |  | ASCII encoding instance
TEncoding.Default |  | Default codepage
TEncoding.BigEndianUnicode |  | Big-endian Unicode (UTF16BE) encoding instance
TEncoding.Unicode |  | UTF16 encoding instance
TEncoding.UTF7 |  | UTF7 encoding instance
TEncoding.UTF8 |  | UTF8 encoding instance