BomSniffer

Handle byte-order-mark prefixes

Members

Functions

setup
void setup(Encoding encoding, bool found)

Configure this instance with unicode converters

Properties

encoded
bool encoded [@property getter]

Was an encoding located in the text (configured via setup)

encoding
Encoding encoding [@property getter]

Return the current encoding. This is either the originally specified encoding, or a derived one obtained by inspecting the content for a BOM. The latter is performed as part of the decode() method

signature
const(void)[] signature [@property getter]

Return the signature (BOM) of the current encoding

Static functions

test
const(Info)* test(void[] content)

Scan the BOM signatures looking for a match. We scan in reverse order to get the longest match first

Examples

void[] INPUT2 = "abc\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86".dup;
void[] INPUT = x"efbbbf" ~ INPUT2;
auto bom = new UnicodeBom!(char)(Encoding.Unknown);
size_t ate;
char[256] buf;

auto temp = bom.decode (INPUT, buf, &ate);
assert (ate == INPUT.length);
assert (bom.encoding == Encoding.UTF_8);

temp = bom.decode (INPUT2, buf, &ate);
assert (ate == INPUT2.length);
assert (bom.encoding == Encoding.UTF_8);

Meta