BOM remover
Byte Order Mark (BOM) is a character encoded in a Unicode file or stream. The main purpose of BOM is to signal the text's stream encoding and the byte order of 16-bit and 32-bit encodings.
In some cases, it is necessary to remove BOM from the response body. For example, in the UTF-8 encoding, the presence of BOM is optional, and it may cause problems when it's read by software that does not know how to handle the BOM.
The Ktor client provides the BOMRemover plugin that removes BOM from the response body in the UTF-8, UTF-16 (BE), UTF-16 (LE), UTF-32 (BE) and UTF-32 (LE) encodings.
Add dependencies
To use BOMRemover
, you need to include the ktor-client-bom-remover
artifact in the build script:
You can learn more about artifacts required by the Ktor client from Adding client dependencies.
Install BOMRemover
To install BOMRemover
, pass it to the install
function inside a client configuration block: