Header lexy/dsl/bom.hpp
Literal rule lexy::dsl::bom
lexy/dsl/bom.hppnamespace lexy::dsl
{
template <typename Encoding, lexy::encoding_endianness Endianness>
constexpr literal-rule auto bom;
}bom is a literal rule that matches the byte order mark (BOM) of the given encoding in the given lexy::encoding_endianness.
It is equivalent to the lexy::dsl::lit_b rule given in the table above.
If the combination of Encoding and Endianness is not listed, it succeeds without matching anything.
The possible BOMs
| Encoding | Endianness | BOM |
|---|---|---|
UTF-8 | ignored |
|
UTF-16 | little |
|
UTF-16 | big |
|
UTF-32 | little |
|
UTF-32 | big |
|
Example 1. Skip an optional UTF-8 BOM
Caution | As a token rule, it matches whitespace immediately following the BOM. As such, the rule is best used in contexts where automatic whitespace skipping is disabled. |
Note | When using lexy::read_file() as input, BOM has been taken care of by default. |