getBOM

Returns a BOMSeq for a given input. If no BOM is present the BOMSeq for BOM.none is returned. The BOM sequence at the beginning of the range will not be comsumed from the passed range. If you pass a reference type range make sure that save creates a deep copy.

immutable(BOMSeq)
getBOM
(
Range
)
(
Range input
)
if (
isForwardRange!Range &&
is(immutable ElementType!Range == immutable ubyte)
)

Parameters

input Range

The sequence to check for the BOM

Return Value

Type: immutable(BOMSeq)

the found BOMSeq corresponding to the passed input.

Examples

import std.format : format;

auto ts = dchar(0x0000FEFF) ~ "Hello World"d;

auto entry = getBOM(cast(ubyte[]) ts);
version (BigEndian)
{
    assert(entry.schema == BOM.utf32be, format("%s", entry.schema));
}
else
{
    assert(entry.schema == BOM.utf32le, format("%s", entry.schema));
}

Meta