Documentation ¶
Overview ¶
Copyright 2024 Serguei Vine. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.
The u8xml package implements NewDecoder which can be used to parse XML files with IANA character encodings such as Windows-1252, ISO-8859-1, unicode,etc. It can be used to decode XML files/strings with Go Standard Library xml package Decoder type methods like Decode(), Token(), etc.
XML files must contain a BOM at the beginning in the case of unicode characters or an XML declaration with an encoding attribute otherwise.
XML files with UTF-8 content may be detected either by BOM or XML declaration. XML files with no BOM or XML declaration will be treated as UTF-8.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectEncoding ¶ added in v0.1.3
DetectEncoding detects the encoding of a byte slice.
Parameters: - buf: a byte slice to detect the encoding of.
Returns: - string: the detected encoding, or default "UTF-8" if no BOM or XML declaration encoding attribute is found. - int: the length of the BOM if a BOM is found, or 0 otherwise.
func NewDecoder ¶
NewDecoder creates a new XML parser reading from r. Decoder converts source bytes to UTF-8
r - input io.Reader Returns *xml.Decoder
Types ¶
This section is empty.