unimarc

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package unimarc reads UNIMARC bibliographic records and maps them to the MARC 21 model (the codex.Record), so a UNIMARC record flows through every libcodex exporter (mods, dublincore, citation, bibframe, schemaorg).

UNIMARC shares the ISO 2709 physical structure with MARC 21 but differs in two ways this package handles:

  • The data dictionary: different tag semantics (title is 200, ISBN is 010, authors are 700/701/710, …). Title, Authors and friends interpret the common UNIMARC fields, and ToMARC21 re-tags a record to MARC 21.
  • The character set is declared in field 100 positions 26-33 (up to four two-character graphic-set codes), not the leader. The reader triggers ISO 5426 transcoding when the extended-Latin code "03" appears in any slot, leaves UTF-8 ("50") and base Latin ("01") untouched, and best-effort decodes the unsupported Cyrillic/Greek sets while flagging them via Reader.Lossy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authors

func Authors(r *codex.Record) []string

Authors returns the personal and corporate names with intellectual responsibility (UNIMARC 700/701/702 personal, 710/711/712 corporate) in a single pass over the record's fields.

func Decode

func Decode(raw []byte) (*codex.Record, error)

Decode parses one UNIMARC record from its raw ISO 2709 bytes, transcoding values to UTF-8 according to the character set declared in field 100. Decode does not modify raw.

func Edition

func Edition(r *codex.Record) string

Edition returns the edition statement (UNIMARC 205 $a).

func ISBN

func ISBN(r *codex.Record) []string

ISBN returns the ISBNs (UNIMARC 010 $a).

func ISSN

func ISSN(r *codex.Record) []string

ISSN returns the ISSNs (UNIMARC 011 $a).

func Language

func Language(r *codex.Record) string

Language returns the language of the text (UNIMARC 101 $a), or "".

func PublicationDate

func PublicationDate(r *codex.Record) string

PublicationDate returns the date of publication (UNIMARC 210 $d, or 214 $d).

func Publisher

func Publisher(r *codex.Record) string

Publisher returns the publisher name (UNIMARC 210 $c, or the newer 214 $c).

func ReadFile

func ReadFile(path string) ([]*codex.Record, error)

ReadFile reads every UNIMARC record from the named file.

func Subjects

func Subjects(r *codex.Record) []string

Subjects returns the subject access points (UNIMARC 600/601 names used as subjects, 606 topical, 607 geographic, 608 form/genre) in a single pass over the record's fields.

func Title

func Title(r *codex.Record) string

Title returns the title proper and other title information (UNIMARC 200 $a $e).

func ToMARC21

func ToMARC21(r *codex.Record) *codex.Record

ToMARC21 re-tags a UNIMARC record to the MARC 21 model, mapping the common fields so the record can be fed to any libcodex exporter. The mapping covers title, statement of responsibility, edition, publication, physical description, series, notes, subjects, names and identifiers; UNIMARC fields outside that set are dropped. Values are cleaned of UNIMARC's non-sort control characters.

Types

type Reader

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

Reader streams UNIMARC records from an ISO 2709 byte stream.

func NewReader

func NewReader(r io.Reader) *Reader

NewReader returns a Reader over an ISO 2709 UNIMARC stream.

func (*Reader) All

func (rd *Reader) All() iter.Seq2[*codex.Record, error]

All returns an iterator over the records in the stream, stopping at the first error.

func (*Reader) Lossy added in v0.7.0

func (rd *Reader) Lossy() bool

Lossy reports whether the record returned by the most recent successful Read required best-effort transcoding that may have dropped characters (an undefined ISO 5426 byte, or a declared Cyrillic/Greek set with no decoder). Mirrors iso2709.Reader.Lossy.

func (*Reader) Read

func (rd *Reader) Read() (*codex.Record, error)

Read returns the next record, or io.EOF at the end of the stream.

Jump to

Keyboard shortcuts

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