bcd

package
v0.8.11 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

* This package provides functions for encoding and decoding between strings and Binary-Coded Decimal (BCD) format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(bytes []byte) (string, error)

* Decode takes a BCD encoded slice of bytes and decodes it to a numeric string, returning an error if the input * contains invalid BCD values. * * The function returns the numeric string or an empty string and an error.

func Encode

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

* Encode takes a string `s` containing only numeric characters ('0' to '9') and encodes it to BCD, prepending a * leading zero if necessary. Returns an error if the input string contains any non-numeric characters. * * The function returns a pointer to a newly allocated slice containing the BCD encoded bytes or a `nil` result * and an error if the input string cannot be encoded.

Types

This section is empty.

Jump to

Keyboard shortcuts

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