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

# TEncoding.GetBufferEncoding

Attempt to guess the encoding of a buffer

## Declaration

Source position: sysencodingh.inc line 64

`public class function TEncoding.GetBufferEncoding(`
`const Buffer: TBytes;`
`var AEncoding: TEncoding`
`):Integer; overload; class function TEncoding.GetBufferEncoding(`
`const Buffer: TBytes;`
`var AEncoding: TEncoding;`
`ADefaultEncoding: TEncoding`
`):Integer; overload;`

## Description

GetBufferEncoding checks the BOM marker of an array of bytes Buffer, and returns the found encoding in AEncoding. Only the TEncoding.BigEndianUnicode TEncoding.Unicode and TEncoding.UTF8 encodings will be tried.

If AEncoding is non-Nil on entry, it will be used to check the BOM marker with. No other encoding will be tried in that case.

If ADefaultEncoding is specified, it will be returned in case no match was found.

The function returns the number of bytes in the BOM Marker.

## See also

TEncoding.BigEndianUnicode |  | Big-endian Unicode (UTF16BE) encoding instance
TEncoding.Unicode |  | UTF16 encoding instance
TEncoding.UTF8 |  | UTF8 encoding instance
TEncoding.GetPreamble |  | Return the BOM Marker used by the encoding

Documentation generated on: May 14 2021