Sign in Join
FPDoc Onlineexperiment

TEncoding.GetBufferEncoding function

Member of TEncodingpublicIn unit sysutils

Attempt to guess the encoding of a buffer.

Declaration

pascal
class function GetBufferEncoding(const Buffer: TBytes; 
 var AEncoding: TEncoding): Integer
 ; overload; static
class function GetBufferEncoding(const Buffer: TBytes; 
 var AEncoding: TEncoding; 
 ADefaultEncoding: TEncoding): Integer
 ; overload; static

Description

GetBufferEncoding checks the BOM marker of an array of bytes Buffer, and returns the found encoding in AEncoding. Only the BigEndianUnicode Unicode and 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

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.