iso5426

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package iso5426 transcodes between the ISO 5426 character set — the extended Latin character set used by UNIMARC records — and UTF-8.

Like MARC-8, ISO 5426 stores a combining diacritic BEFORE the base character it modifies (the reverse of Unicode). The decoder reorders the mark after the base and composes the pair to a precomposed (NFC) code point when ISO 5426 defines one; otherwise it emits the base followed by the standalone combining mark.

The graphic and precomposition tables are generated from the ISO 5426 ICU character map (see gen); the standalone combining marks are hand-maintained here, verified against the marc4j ISO 5426 converter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(data []byte) string

Decode decodes an ISO 5426 byte sequence to a UTF-8 string. Combining marks precede their base in ISO 5426; the decoder buffers them and emits them after the base, composing the base with the innermost (first-buffered) mark to a precomposed (NFC) code point when one exists. Stacked marks are preserved in Unicode order.

func DecodeLossy added in v0.6.0

func DecodeLossy(data []byte) (string, bool)

DecodeLossy decodes like Decode and additionally reports whether any byte fell through the best-effort Latin-1 passthrough (an undefined high byte with no ISO 5426 mapping). A caller that must not silently corrupt data can check the flag, mirroring the marc8 decoder's Lossy signal.

func Encode

func Encode(s string) ([]byte, error)

Encode encodes a UTF-8 string to ISO 5426. It is the inverse of Decode: a base followed by a combining mark is first composed to its precomposed form, then emitted either as a single graphic byte or as ISO 5426's combining-mark-then- base byte pair. It returns an error on the first code point ISO 5426 cannot represent.

Types

This section is empty.

Directories

Path Synopsis
Command gen produces tables_gen.go from the ISO 5426 .ucm mapping (the ICU Unicode character map for ISO 5426, the UNIMARC extended-Latin character set).
Command gen produces tables_gen.go from the ISO 5426 .ucm mapping (the ICU Unicode character map for ISO 5426, the UNIMARC extended-Latin character set).

Jump to

Keyboard shortcuts

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