utf16

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package utf16 implements encoding and decoding of UTF-16 sequences.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendRunes

func AppendRunes(dst []uint16, src ...rune) []uint16

AppendRunes appends the UTF-16 encoding of the Unicode code point sequence src to dst.

func DecodeRune

func DecodeRune(r1, r2 rune) rune

DecodeRune returns the UTF-16 decoding of a surrogate pair. If the pair is not a valid UTF-16 surrogate pair, DecodeRune returns the Unicode replacement code point U+FFFD.

func EncodeRune

func EncodeRune(r rune) (r1, r2 rune)

EncodeRune returns the UTF-16 surrogate pair r1, r2 for the given rune.

If the rune is not a valid Unicode code point or does not need encoding, EncodeRune returns U+FFFD, U+FFFD.

func EncodeRunes

func EncodeRunes(dst []uint16, s ...rune) ([]uint16, int)

func EncodedSize

func EncodedSize(s string) int

EncodedSize returns the number of uint16s required to hold the UTF-16 encoding of unicode code points in s.

func IsSurrogate

func IsSurrogate(r rune) bool

IsSurrogate reports whether the specified Unicode code point can appear in a surrogate pair.

func RunesAppend

func RunesAppend(dst []rune, utf16 ...uint16) []rune

RunesAppend decodes all UTF-16 code points in src into the dst, returns the decoded runes.

func RunesDecode

func RunesDecode(d []rune, src ...uint16) (dst []rune, n int)

RunesDecode decodes UTF-16 code points in src into the dst, returns updated dst and count of consumed uint16s from src.

func UTF8Append

func UTF8Append(dst []byte, src ...uint16) []byte

func UTF8Decode

func UTF8Decode(dst []byte, utf16 ...uint16) ([]byte, int)

UTF8Decode transcodes UTF-16 encoding of unicode code points to UTF-8 bytes, returns updated dst and count of consumed uint16s from src.

func UTF8DecodedSize

func UTF8DecodedSize(utf16 ...uint16) (n int, canDecodeInPlace bool)

UTF8DecodedSize returns UTF-8 bytes required to store the decoded UTF-16 encoding of unicode code points.

Types

type String

type String string

A String represents a UTF-16 encoded string.

NOTE: DO NOT use as go string.

func AsString

func AsString(s []uint16) String

func (String) Slice

func (s String) Slice() []uint16

Jump to

Keyboard shortcuts

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