Sign in Join
FPDoc Onlineexperiment

GuessPascalEncoding function

In unit LConvEncoding

Works like GuessEncoding but also supports {%encoding ...} directive.

Declaration

pascal
function GuessPascalEncoding(const s: string): string

Arguments

s

String with the content examined in the routine.

Function result

Encoding name detected, or a default value.

Description

GuessPascalEncoding is a String function which tries to determine the encoding used for Pascal source code specified in S. The return value is like in GuessEncoding.

First it checks S for various Byte Order Marks at the start, including UTF8BOM, UTF16LEBOM, and UTF16BEBOM. Then it checks for an explicit '{%encoding' marker at the start of the value. When present, the value after the marker (up to the closing '}' character) is normalized and used as the return value. Without a '{%encoding' marker the function continues like GuessEncoding.

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