encoding

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package encoding resolves legacy text charset names and decodes their bytes to UTF-8. It exists so the config loader can validate a declared charset at startup and the ingest pipeline can apply the same resolution at read time, without either package importing the other.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder converts a legacy-encoded byte slice to UTF-8.

func Lookup

func Lookup(name string) (Decoder, error)

Lookup resolves a charset name or alias (e.g. "windows-1250", "cp1252", "ISO-8859-2") through the IANA index. It returns an error for an empty, unknown, or unsupported name so a bad declaration is caught at config load rather than per-file mid-ingest. UTF-8 resolves to a Decoder whose Decode is an identity check, which keeps an explicit `charset = "utf-8"` rule legal.

func (Decoder) Decode

func (d Decoder) Decode(content []byte) ([]byte, error)

Decode converts content from the Decoder's charset to UTF-8. It returns an error when the bytes are not valid in that charset, so a mis-declared rule surfaces as a per-file skip rather than as silently mangled text. The result is guaranteed valid UTF-8.

func (Decoder) Name

func (d Decoder) Name() string

Name returns the charset name the Decoder was resolved from.

Jump to

Keyboard shortcuts

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