u8xml

package module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2024 License: MIT Imports: 6 Imported by: 1

README

Go Report Card GitHub Tag GitHub License

u8xml Go package

The u8xml package NewDecoder can be used to parse XML files with IANA character encodings instead of Go Standard Library xml package Decoder.

u8hex CLI utility

The cmd folder contains the source code of the u8hex command-line interface utility, which may be used to get the hex representation of a string with a given character set. It may be useful for debugging.

Credits

u8hex is inspired by cpd

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

func DetectEncoding(buf []byte) (string, int)

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

func NewDecoder(r io.Reader) *xml.Decoder

NewDecoder creates a new XML parser reading from r. Decoder converts source bytes to UTF-8

r - input io.Reader Returns *xml.Decoder

func NewReader added in v0.1.3

func NewReader(r io.Reader) (io.Reader, error)

NewReader implements an io reader that converts source bytes to UTF-8.

r - input io.Reader Returns io.Reader, error

Types

This section is empty.

Directories

Path Synopsis
cmd
u8hex
With u8hex CLI utility they can get the hex representation of a string with a given character set.
With u8hex CLI utility they can get the hex representation of a string with a given character set.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL