Namespace: go.std.unicode.utf8
v1.0Contents
Summary
Provides a low-level interface to the unicode/utf8 package.
Package utf8 implements functions and constants to support text encoded in
UTF-8. It includes functions to translate between runes and UTF-8 byte sequences.
See https://en.wikipedia.org/wiki/UTF-8
Index
- AppendRune
- DecodeLastRune
- DecodeLastRuneInString
- DecodeRune
- DecodeRuneInString
- EncodeRune
- FullRune
- FullRuneInString
- MaxRune
- RuneCount
- RuneCountInString
- RuneError
- RuneLen
- RuneSelf
- RuneStart
- UTFMax
- Valid
- ValidRune
- ValidString
Legend
-
Constant
Variable
Function
Macro
Special form
Type
GoVar
Receiver/Method
Constants
Constants are variables with :const true in their metadata. Joker currently does not recognize them as special; as such, it allows redefining them or their values.-
MaxRune
Char v1.0Maximum valid Unicode code point.
-
RuneError
Char v1.0the "error" Rune or "Unicode replacement character"
-
RuneSelf
Int v1.0characters below RuneSelf are represented as themselves in a single byte.
-
UTFMax
Int v1.0maximum number of bytes of a UTF-8 encoded Unicode character.
Variables
-
(None.)
Functions, Macros, and Special Forms
-
AppendRune
Function v1.0(AppendRune p r)
AppendRune appends the UTF-8 encoding of r to the end of p and
returns the extended buffer. If the rune is out of range,
it appends the encoding of RuneError.
Go input arguments: (p []byte, r rune)
Go returns: []byte
Joker input arguments: [^arrayOfByte p, ^Char r]
Joker returns: ^arrayOfByte -
DecodeLastRune
Function v1.0(DecodeLastRune p)
DecodeLastRune unpacks the last UTF-8 encoding in p and returns the rune and
its width in bytes. If p is empty it returns (RuneError, 0). Otherwise, if
the encoding is invalid, it returns (RuneError, 1). Both are impossible
results for correct, non-empty UTF-8.
An encoding is invalid if it is incorrect UTF-8, encodes a rune that is
out of range, or is not the shortest possible UTF-8 encoding for the
value. No other validation is performed.
Go input arguments: (p []byte)
Go returns: (r rune, size int)
Joker input arguments: [^arrayOfByte p]
Joker returns: [^Char r, ^Int size] -
DecodeLastRuneInString
Function v1.0(DecodeLastRuneInString s)
DecodeLastRuneInString is like DecodeLastRune but its input is a string. If
s is empty it returns (RuneError, 0). Otherwise, if the encoding is invalid,
it returns (RuneError, 1). Both are impossible results for correct,
non-empty UTF-8.
An encoding is invalid if it is incorrect UTF-8, encodes a rune that is
out of range, or is not the shortest possible UTF-8 encoding for the
value. No other validation is performed.
Go input arguments: (s string)
Go returns: (r rune, size int)
Joker input arguments: [^String s]
Joker returns: [^Char r, ^Int size] -
DecodeRune
Function v1.0(DecodeRune p)
DecodeRune unpacks the first UTF-8 encoding in p and returns the rune and
its width in bytes. If p is empty it returns (RuneError, 0). Otherwise, if
the encoding is invalid, it returns (RuneError, 1). Both are impossible
results for correct, non-empty UTF-8.
An encoding is invalid if it is incorrect UTF-8, encodes a rune that is
out of range, or is not the shortest possible UTF-8 encoding for the
value. No other validation is performed.
Go input arguments: (p []byte)
Go returns: (r rune, size int)
Joker input arguments: [^arrayOfByte p]
Joker returns: [^Char r, ^Int size] -
DecodeRuneInString
Function v1.0(DecodeRuneInString s)
DecodeRuneInString is like DecodeRune but its input is a string. If s is
empty it returns (RuneError, 0). Otherwise, if the encoding is invalid, it
returns (RuneError, 1). Both are impossible results for correct, non-empty
UTF-8.
An encoding is invalid if it is incorrect UTF-8, encodes a rune that is
out of range, or is not the shortest possible UTF-8 encoding for the
value. No other validation is performed.
Go input arguments: (s string)
Go returns: (r rune, size int)
Joker input arguments: [^String s]
Joker returns: [^Char r, ^Int size] -
EncodeRune
Function v1.0(EncodeRune p r)
EncodeRune writes into p (which must be large enough) the UTF-8 encoding of the rune.
If the rune is out of range, it writes the encoding of RuneError.
It returns the number of bytes written.
Go input arguments: (p []byte, r rune)
Go returns: int
Joker input arguments: [^arrayOfByte p, ^Char r]
Joker returns: ^Int -
FullRune
Function v1.0(FullRune p)
FullRune reports whether the bytes in p begin with a full UTF-8 encoding of a rune.
An invalid encoding is considered a full Rune since it will convert as a width-1 error rune.
Go input arguments: (p []byte)
Go returns: bool
Joker input arguments: [^arrayOfByte p]
Joker returns: ^Boolean -
FullRuneInString
Function v1.0(FullRuneInString s)
FullRuneInString is like FullRune but its input is a string.
Go input arguments: (s string)
Go returns: bool
Joker input arguments: [^String s]
Joker returns: ^Boolean -
RuneCount
Function v1.0(RuneCount p)
RuneCount returns the number of runes in p. Erroneous and short
encodings are treated as single runes of width 1 byte.
Go input arguments: (p []byte)
Go returns: int
Joker input arguments: [^arrayOfByte p]
Joker returns: ^Int -
RuneCountInString
Function v1.0(RuneCountInString s)
RuneCountInString is like RuneCount but its input is a string.
Go input arguments: (s string)
Go returns: int
Joker input arguments: [^String s]
Joker returns: ^Int n -
RuneLen
Function v1.0(RuneLen r)
RuneLen returns the number of bytes required to encode the rune.
It returns -1 if the rune is not a valid value to encode in UTF-8.
Go input arguments: (r rune)
Go returns: int
Joker input arguments: [^Char r]
Joker returns: ^Int -
RuneStart
Function v1.0(RuneStart b)
RuneStart reports whether the byte could be the first byte of an encoded,
possibly invalid rune. Second and subsequent bytes always have the top two
bits set to 10.
Go input arguments: (b byte)
Go returns: bool
Joker input arguments: [^Byte b]
Joker returns: ^Boolean -
Valid
Function v1.0(Valid p)
Valid reports whether p consists entirely of valid UTF-8-encoded runes.
Go input arguments: (p []byte)
Go returns: bool
Joker input arguments: [^arrayOfByte p]
Joker returns: ^Boolean -
ValidRune
Function v1.0(ValidRune r)
ValidRune reports whether r can be legally encoded as UTF-8.
Code points that are out of range or a surrogate half are illegal.
Go input arguments: (r rune)
Go returns: bool
Joker input arguments: [^Char r]
Joker returns: ^Boolean -
ValidString
Function v1.0(ValidString s)
ValidString reports whether s consists entirely of valid UTF-8-encoded runes.
Go input arguments: (s string)
Go returns: bool
Joker input arguments: [^String s]
Joker returns: ^Boolean
Types
-
(None.)