ucs2

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: MIT Imports: 4 Imported by: 3

Documentation

Overview

Package ucs2 provides conversions between UCS-2 and UTF-8.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidLength indicates the binary provided has an invalid (odd) length.
	ErrInvalidLength = errors.New("ucs2: length must be even")
)

Functions

func Decode

func Decode(src []byte) ([]rune, error)

Decode converts an array of UCS2 characters into an array of runes.

As the UCS2 characters are packed into a byte array, the length of the byte array provided must be even.

func Encode

func Encode(src []rune) []byte

Encode converts an array of UCS2 runes into an array of bytes, where pairs of bytes (in Big Endian) represent a UCS2 character.

Types

type ErrDanglingSurrogate

type ErrDanglingSurrogate []byte

ErrDanglingSurrogate indicates only half of a surrogate pair is provided at the end of the byte array being decoded.

func (ErrDanglingSurrogate) Error

func (e ErrDanglingSurrogate) Error() string

Jump to

Keyboard shortcuts

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