unistring

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package unistring contains an implementation of a hybrid ASCII/UTF-16 string. For ASCII strings the underlying representation is equivalent to a normal Go string. For unicode strings the underlying representation is UTF-16 as []uint16 with 0th element set to 0xFEFF. unicode.String allows representing malformed UTF-16 values (e.g. stand-alone parts of surrogate pairs) which cannot be represented in UTF-8. At the same time it is possible to use unicode.String as property keys just as efficiently as simple strings, (the leading 0xFEFF ensures there is no clash with ASCII string), and it is possible to convert it to valueString without extra allocations.

Index

Constants

View Source
const (
	BOM = 0xFEFF
)

Variables

This section is empty.

Functions

func Scan

func Scan(s string) []uint16

Scan checks if the string contains any unicode characters. If it does, converts to an array suitable for creating a String using FromUtf16, otherwise returns nil.

Types

type String

type String string

func FromUtf16

func FromUtf16(b []uint16) String

func NewFromRunes

func NewFromRunes(s []rune) String

func NewFromString

func NewFromString(s string) String

func (String) AsUtf16

func (s String) AsUtf16() []uint16

func (String) String

func (s String) String() string

Jump to

Keyboard shortcuts

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