Module: stdgo.bytes
Overview
Index
-
function indexBytePortable(:stdgo.Slice<stdgo.GoUInt8>, :stdgo.GoUInt8):stdgo.GoInt
-
function contains(_b:Array<UInt>, _subslice:Array<UInt>):Bool
-
function cut(_s:Array<UInt>, _sep:Array<UInt>):stdgo.Tuple3<Array<UInt>, Array<UInt>, Bool>
-
function cutPrefix(_s:Array<UInt>, _prefix:Array<UInt>):stdgo.Tuple<Array<UInt>, Bool>
-
function cutSuffix(_s:Array<UInt>, _suffix:Array<UInt>):stdgo.Tuple<Array<UInt>, Bool>
-
function fieldsFunc(_s:Array<UInt>, _f:()):Array<Array<UInt>>
-
function hasPrefix(_s:Array<UInt>, _prefix:Array<UInt>):Bool
-
function hasSuffix(_s:Array<UInt>, _suffix:Array<UInt>):Bool
-
function join(_s:Array<Array<UInt>>, _sep:Array<UInt>):Array<UInt>
-
function replace(_s:Array<UInt>, _old:Array<UInt>, _new:Array<UInt>, _n:Int):Array<UInt>
-
function replaceAll(_s:Array<UInt>, _old:Array<UInt>, _new:Array<UInt>):Array<UInt>
-
function split(_s:Array<UInt>, _sep:Array<UInt>):Array<Array<UInt>>
-
function splitAfter(_s:Array<UInt>, _sep:Array<UInt>):Array<Array<UInt>>
-
function splitAfterN(_s:Array<UInt>, _sep:Array<UInt>, _n:Int):Array<Array<UInt>>
-
function splitN(_s:Array<UInt>, _sep:Array<UInt>, _n:Int):Array<Array<UInt>>
-
function toLowerSpecial(_c:stdgo._internal.unicode.SpecialCase, _s:Array<UInt>):Array<UInt>
-
function toTitleSpecial(_c:stdgo._internal.unicode.SpecialCase, _s:Array<UInt>):Array<UInt>
-
function toUpperSpecial(_c:stdgo._internal.unicode.SpecialCase, _s:Array<UInt>):Array<UInt>
-
function toValidUTF8(_s:Array<UInt>, _replacement:Array<UInt>):Array<UInt>
-
function trimLeft(_s:Array<UInt>, _cutset:String):Array<UInt>
-
function trimPrefix(_s:Array<UInt>, _prefix:Array<UInt>):Array<UInt>
-
function trimRight(_s:Array<UInt>, _cutset:String):Array<UInt>
-
function trimSuffix(_s:Array<UInt>, _suffix:Array<UInt>):Array<UInt>
Constants
import stdgo.bytes.Bytes
final minRead:haxe.UInt64 = stdgo._internal.bytes.Bytes_minRead.minRead
Variables
import stdgo.bytes.Bytes
var errTooLarge:stdgo.Error
Functions
import stdgo.bytes.Bytes
function indexBytePortable
function indexBytePortable(:stdgo.Slice<stdgo.GoUInt8>, :stdgo.GoUInt8):stdgo.GoInt
Classes
import stdgo.bytes.*
class Bytes
{
i_2871789 = 0
_ = 0
gotoNext = 2871797
_ = gotoNext == 2871797
if i_2871789 < len(s) && i_2871789 < len(t) {
gotoNext = 2871833
_ = gotoNext == 2871833
sr_2871837 = s[i_2871789]
tr_2871850 = t[i_2871789]
if sr_2871837|tr_2871850 >= 128 {
gotoNext = 2871889
_ = gotoNext == 2871889
gotoNext = 2872247
gotoNext = 2871933
} else {
gotoNext = 2871933
}
_ = gotoNext == 2871933
if tr_2871850 == sr_2871837 {
gotoNext = 2871945
_ = gotoNext == 2871945
i_2871789++
gotoNext = 2871797
gotoNext = 2872010
} else {
gotoNext = 2872010
}
_ = gotoNext == 2872010
if tr_2871850 < sr_2871837 {
gotoNext = 2872021
_ = gotoNext == 2872021
tr_2871850, sr_2871837 = sr_2871837, tr_2871850
gotoNext = 2872096
} else {
gotoNext = 2872096
}
_ = gotoNext == 2872096
if 65 <= sr_2871837 && sr_2871837 <= 90 && tr_2871850 == sr_2871837+97-65 {
gotoNext = 2872142
_ = gotoNext == 2872142
i_2871789++
gotoNext = 2871797
gotoNext = 2872162
} else {
gotoNext = 2872162
}
_ = gotoNext == 2872162
return false
i_2871789++
gotoNext = 2871797
} else {
gotoNext = 2872222
}
_ = gotoNext == 2872222
return len(s) == len(t)
gotoNext = 2872247
_ = gotoNext == 2872247
s = s[i_2871789:]
t = t[i_2871789:]
_ = 0
gotoNext = 2872282
_ = gotoNext == 2872282
if len(s) != 0 && len(t) != 0 {
gotoNext = 2872313
_ = gotoNext == 2872313
if s[0] < 128 {
gotoNext = 2872394
_ = gotoNext == 2872394
sr_2872356, s = rune(s[0]), s[1:]
gotoNext = 2872498
} else {
gotoNext = 2872434
_ = gotoNext == 2872434
r_2872439, size_2872442 = utf8.DecodeRune(s)
sr_2872356, s = r_2872439, s[size_2872442:]
gotoNext = 2872498
}
_ = gotoNext == 2872498
if t[0] < 128 {
gotoNext = 2872522
_ = gotoNext == 2872522
tr_2872360, t = rune(t[0]), t[1:]
gotoNext = 2872698
} else {
gotoNext = 2872562
_ = gotoNext == 2872562
r_2872567, size_2872570 = utf8.DecodeRune(t)
tr_2872360, t = r_2872567, t[size_2872570:]
gotoNext = 2872698
}
_ = gotoNext == 2872698
if tr_2872360 == sr_2872356 {
gotoNext = 2872710
_ = gotoNext == 2872710
_ = 0
gotoNext = 2872282
gotoNext = 2872775
} else {
gotoNext = 2872775
}
_ = gotoNext == 2872775
if tr_2872360 < sr_2872356 {
gotoNext = 2872786
_ = gotoNext == 2872786
tr_2872360, sr_2872356 = sr_2872356, tr_2872360
gotoNext = 2872840
} else {
gotoNext = 2872840
}
_ = gotoNext == 2872840
if tr_2872360 < 128 {
gotoNext = 2872862
_ = gotoNext == 2872862
if 65 <= sr_2872356 && sr_2872356 <= 90 && tr_2872360 == sr_2872356+97-65 {
gotoNext = 2872962
_ = gotoNext == 2872962
_ = 0
gotoNext = 2872282
gotoNext = 2872985
} else {
gotoNext = 2872985
}
_ = gotoNext == 2872985
return false
gotoNext = 2873115
} else {
gotoNext = 2873115
}
_ = gotoNext == 2873115
r_2873115 = unicode.SimpleFold(sr_2872356)
_ = 0
gotoNext = 2873145
_ = gotoNext == 2873145
if r_2873115 != sr_2872356 && r_2873115 < tr_2872360 {
gotoNext = 2873167
_ = gotoNext == 2873167
r_2873115 = unicode.SimpleFold(r_2873115)
gotoNext = 2873145
} else {
gotoNext = 2873204
}
_ = gotoNext == 2873204
if r_2873115 == tr_2872360 {
gotoNext = 2873215
_ = gotoNext == 2873215
_ = 0
gotoNext = 2872282
gotoNext = 2873235
} else {
gotoNext = 2873235
}
_ = gotoNext == 2873235
return false
gotoNext = 2872282
} else {
gotoNext = 2873288
}
_ = gotoNext == 2873288
return len(s) == len(t)
gotoNext = -1
}
Bytes function clone
function clone(_b:Array<UInt>):Array<UInt>
Clone returns a copy of b[:len(b)].
The result may have additional unused capacity.
Clone(nil) returns nil.
Bytes function compare
function compare(_a:Array<UInt>, _b:Array<UInt>):Int
Compare returns an integer comparing two byte slices lexicographically.
The result will be 0 if a == b, -1 if a < b, and +1 if a > b.
A nil argument is equivalent to an empty slice.
Bytes function contains
function contains(_b:Array<UInt>, _subslice:Array<UInt>):Bool
Contains reports whether subslice is within b.
Bytes function containsAny
function containsAny(_b:Array<UInt>, _chars:String):Bool
ContainsAny reports whether any of the UTF-8-encoded code points in chars are within b.
Bytes function containsFunc
function containsFunc(_b:Array<UInt>, _f:()):Bool
ContainsFunc reports whether any of the UTF-8-encoded code points r within b satisfy f(r).
Bytes function containsRune
function containsRune(_b:Array<UInt>, _r:Int):Bool
ContainsRune reports whether the rune is contained in the UTF-8-encoded byte slice b.
Bytes function count
function count(_s:Array<UInt>, _sep:Array<UInt>):Int
Count counts the number of non-overlapping instances of sep in s.
If sep is an empty slice, Count returns 1 + the number of UTF-8-encoded code points in s.
Bytes function cut
function cut(_s:Array<UInt>, _sep:Array<UInt>):stdgo.Tuple3<Array<UInt>, Array<UInt>, Bool>
Cut slices s around the first instance of sep,
returning the text before and after sep.
The found result reports whether sep appears in s.
If sep does not appear in s, cut returns s, nil, false.
Cut returns slices of the original slice s, not copies.
Bytes function cutPrefix
function cutPrefix(_s:Array<UInt>, _prefix:Array<UInt>):stdgo.Tuple<Array<UInt>, Bool>
CutPrefix returns s without the provided leading prefix byte slice
and reports whether it found the prefix.
If s doesn't start with prefix, CutPrefix returns s, false.
If prefix is the empty byte slice, CutPrefix returns s, true.
CutPrefix returns slices of the original slice s, not copies.
Bytes function cutSuffix
function cutSuffix(_s:Array<UInt>, _suffix:Array<UInt>):stdgo.Tuple<Array<UInt>, Bool>
CutSuffix returns s without the provided ending suffix byte slice
and reports whether it found the suffix.
If s doesn't end with suffix, CutSuffix returns s, false.
If suffix is the empty byte slice, CutSuffix returns s, true.
CutSuffix returns slices of the original slice s, not copies.
Bytes function equal
function equal(_a:Array<UInt>, _b:Array<UInt>):Bool
Equal reports whether a and b
are the same length and contain the same bytes.
A nil argument is equivalent to an empty slice.
Bytes function equalFold
function equalFold(_s:Array<UInt>, _t:Array<UInt>):Bool
EqualFold reports whether s and t, interpreted as UTF-8 strings,
are equal under simple Unicode case-folding, which is a more general
form of case-insensitivity.
Bytes function fields
function fields(_s:Array<UInt>):Array<Array<UInt>>
Fields interprets s as a sequence of UTF-8-encoded code points.
It splits the slice s around each instance of one or more consecutive white space
characters, as defined by unicode.IsSpace, returning a slice of subslices of s or an
empty slice if s contains only white space.
Bytes function fieldsFunc
function fieldsFunc(_s:Array<UInt>, _f:()):Array<Array<UInt>>
FieldsFunc interprets s as a sequence of UTF-8-encoded code points.
It splits the slice s at each run of code points c satisfying f(c) and
returns a slice of subslices of s. If all code points in s satisfy f(c), or
len(s) == 0, an empty slice is returned.
FieldsFunc makes no guarantees about the order in which it calls f(c) and assumes that f always returns the same value for a given c.
Bytes function hasPrefix
function hasPrefix(_s:Array<UInt>, _prefix:Array<UInt>):Bool
HasPrefix tests whether the byte slice s begins with prefix.
Bytes function hasSuffix
function hasSuffix(_s:Array<UInt>, _suffix:Array<UInt>):Bool
HasSuffix tests whether the byte slice s ends with suffix.
Bytes function index
function index(_s:Array<UInt>, _sep:Array<UInt>):Int
Index returns the index of the first instance of sep in s, or -1 if sep is not present in s.
Bytes function indexAny
function indexAny(_s:Array<UInt>, _chars:String):Int
IndexAny interprets s as a sequence of UTF-8-encoded Unicode code points.
It returns the byte index of the first occurrence in s of any of the Unicode
code points in chars. It returns -1 if chars is empty or if there is no code
point in common.
Bytes function indexByte
function indexByte(_b:Array<UInt>, _c:UInt):Int
IndexByte returns the index of the first instance of c in b, or -1 if c is not present in b.
Bytes function indexFunc
function indexFunc(_s:Array<UInt>, _f:()):Int
IndexFunc interprets s as a sequence of UTF-8-encoded code points.
It returns the byte index in s of the first Unicode
code point satisfying f(c), or -1 if none do.
Bytes function indexRune
function indexRune(_s:Array<UInt>, _r:Int):Int
IndexRune interprets s as a sequence of UTF-8-encoded code points.
It returns the byte index of the first occurrence in s of the given rune.
It returns -1 if rune is not present in s.
If r is utf8.RuneError, it returns the first instance of any
invalid UTF-8 byte sequence.
Bytes function join
function join(_s:Array<Array<UInt>>, _sep:Array<UInt>):Array<UInt>
Join concatenates the elements of s to create a new byte slice. The separator
sep is placed between elements in the resulting slice.
Bytes function lastIndex
function lastIndex(_s:Array<UInt>, _sep:Array<UInt>):Int
LastIndex returns the index of the last instance of sep in s, or -1 if sep is not present in s.
Bytes function lastIndexAny
function lastIndexAny(_s:Array<UInt>, _chars:String):Int
LastIndexAny interprets s as a sequence of UTF-8-encoded Unicode code
points. It returns the byte index of the last occurrence in s of any of
the Unicode code points in chars. It returns -1 if chars is empty or if
there is no code point in common.
Bytes function lastIndexByte
function lastIndexByte(_s:Array<UInt>, _c:UInt):Int
LastIndexByte returns the index of the last instance of c in s, or -1 if c is not present in s.
Bytes function lastIndexFunc
function lastIndexFunc(_s:Array<UInt>, _f:()):Int
LastIndexFunc interprets s as a sequence of UTF-8-encoded code points.
It returns the byte index in s of the last Unicode
code point satisfying f(c), or -1 if none do.
Bytes function map_
function map_(_mapping:(), _s:Array<UInt>):Array<UInt>
Map returns a copy of the byte slice s with all its characters modified
according to the mapping function. If mapping returns a negative value, the character is
dropped from the byte slice with no replacement. The characters in s and the
output are interpreted as UTF-8-encoded code points.
Bytes function newBuffer
function newBuffer(_buf:Array<UInt>):stdgo.bytes.Buffer
NewBuffer creates and initializes a new Buffer using buf as its
initial contents. The new Buffer takes ownership of buf, and the
caller should not use buf after this call. NewBuffer is intended to
prepare a Buffer to read existing data. It can also be used to set
the initial size of the internal buffer for writing. To do that,
buf should have the desired capacity but a length of zero.
In most cases, new(Buffer) (or just declaring a Buffer variable) is sufficient to initialize a Buffer.
Bytes function newBufferString
function newBufferString(_s:String):stdgo.bytes.Buffer
NewBufferString creates and initializes a new Buffer using string s as its
initial contents. It is intended to prepare a buffer to read an existing
string.
In most cases, new(Buffer) (or just declaring a Buffer variable) is sufficient to initialize a Buffer.
Bytes function newReader
function newReader(_b:Array<UInt>):stdgo.bytes.Reader
NewReader returns a new Reader reading from b.
Bytes function repeat
function repeat(_b:Array<UInt>, _count:Int):Array<UInt>
Repeat returns a new byte slice consisting of count copies of b.
It panics if count is negative or if the result of (len(b) * count) overflows.
Bytes function replace
function replace(_s:Array<UInt>, _old:Array<UInt>, _new:Array<UInt>, _n:Int):Array<UInt>
Replace returns a copy of the slice s with the first n
non-overlapping instances of old replaced by new.
If old is empty, it matches at the beginning of the slice
and after each UTF-8 sequence, yielding up to k+1 replacements
for a k-rune slice.
If n < 0, there is no limit on the number of replacements.
Bytes function replaceAll
function replaceAll(_s:Array<UInt>, _old:Array<UInt>, _new:Array<UInt>):Array<UInt>
ReplaceAll returns a copy of the slice s with all
non-overlapping instances of old replaced by new.
If old is empty, it matches at the beginning of the slice
and after each UTF-8 sequence, yielding up to k+1 replacements
for a k-rune slice.
Bytes function runes
function runes(_s:Array<UInt>):Array<Int>
Runes interprets s as a sequence of UTF-8-encoded code points.
It returns a slice of runes (Unicode code points) equivalent to s.
Bytes function split
function split(_s:Array<UInt>, _sep:Array<UInt>):Array<Array<UInt>>
Split slices s into all subslices separated by sep and returns a slice of
the subslices between those separators.
If sep is empty, Split splits after each UTF-8 sequence.
It is equivalent to SplitN with a count of -1.
To split around the first instance of a separator, see Cut.
Bytes function splitAfter
function splitAfter(_s:Array<UInt>, _sep:Array<UInt>):Array<Array<UInt>>
SplitAfter slices s into all subslices after each instance of sep and
returns a slice of those subslices.
If sep is empty, SplitAfter splits after each UTF-8 sequence.
It is equivalent to SplitAfterN with a count of -1.
Bytes function splitAfterN
function splitAfterN(_s:Array<UInt>, _sep:Array<UInt>, _n:Int):Array<Array<UInt>>
SplitAfterN slices s into subslices after each instance of sep and
returns a slice of those subslices.
If sep is empty, SplitAfterN splits after each UTF-8 sequence.
The count determines the number of subslices to return:
n > 0: at most n subslices; the last subslice will be the unsplit remainder.
n == 0: the result is nil (zero subslices)
n < 0: all subslices
Bytes function splitN
function splitN(_s:Array<UInt>, _sep:Array<UInt>, _n:Int):Array<Array<UInt>>
SplitN slices s into subslices separated by sep and returns a slice of
the subslices between those separators.
If sep is empty, SplitN splits after each UTF-8 sequence.
The count determines the number of subslices to return:
n > 0: at most n subslices; the last subslice will be the unsplit remainder.
n == 0: the result is nil (zero subslices)
n < 0: all subslices
To split around the first instance of a separator, see Cut.
Bytes function title
function title(_s:Array<UInt>):Array<UInt>
Title treats s as UTF-8-encoded bytes and returns a copy with all Unicode letters that begin
words mapped to their title case.
Deprecated: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead.
Bytes function toLower
function toLower(_s:Array<UInt>):Array<UInt>
ToLower returns a copy of the byte slice s with all Unicode letters mapped to
their lower case.
Bytes function toLowerSpecial
function toLowerSpecial(_c:stdgo._internal.unicode.SpecialCase, _s:Array<UInt>):Array<UInt>
ToLowerSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their
lower case, giving priority to the special casing rules.
Bytes function toTitle
function toTitle(_s:Array<UInt>):Array<UInt>
ToTitle treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their title case.
Bytes function toTitleSpecial
function toTitleSpecial(_c:stdgo._internal.unicode.SpecialCase, _s:Array<UInt>):Array<UInt>
ToTitleSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their
title case, giving priority to the special casing rules.
Bytes function toUpper
function toUpper(_s:Array<UInt>):Array<UInt>
ToUpper returns a copy of the byte slice s with all Unicode letters mapped to
their upper case.
Bytes function toUpperSpecial
function toUpperSpecial(_c:stdgo._internal.unicode.SpecialCase, _s:Array<UInt>):Array<UInt>
ToUpperSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their
upper case, giving priority to the special casing rules.
Bytes function toValidUTF8
function toValidUTF8(_s:Array<UInt>, _replacement:Array<UInt>):Array<UInt>
ToValidUTF8 treats s as UTF-8-encoded bytes and returns a copy with each run of bytes
representing invalid UTF-8 replaced with the bytes in replacement, which may be empty.
Bytes function trim
function trim(_s:Array<UInt>, _cutset:String):Array<UInt>
Trim returns a subslice of s by slicing off all leading and
trailing UTF-8-encoded code points contained in cutset.
Bytes function trimFunc
function trimFunc(_s:Array<UInt>, _f:()):Array<UInt>
TrimFunc returns a subslice of s by slicing off all leading and trailing
UTF-8-encoded code points c that satisfy f(c).
Bytes function trimLeft
function trimLeft(_s:Array<UInt>, _cutset:String):Array<UInt>
TrimLeft returns a subslice of s by slicing off all leading
UTF-8-encoded code points contained in cutset.
Bytes function trimLeftFunc
function trimLeftFunc(_s:Array<UInt>, _f:()):Array<UInt>
TrimLeftFunc treats s as UTF-8-encoded bytes and returns a subslice of s by slicing off
all leading UTF-8-encoded code points c that satisfy f(c).
Bytes function trimPrefix
function trimPrefix(_s:Array<UInt>, _prefix:Array<UInt>):Array<UInt>
TrimPrefix returns s without the provided leading prefix string.
If s doesn't start with prefix, s is returned unchanged.
Bytes function trimRight
function trimRight(_s:Array<UInt>, _cutset:String):Array<UInt>
TrimRight returns a subslice of s by slicing off all trailing
UTF-8-encoded code points that are contained in cutset.
Bytes function trimRightFunc
function trimRightFunc(_s:Array<UInt>, _f:()):Array<UInt>
TrimRightFunc returns a subslice of s by slicing off all trailing
UTF-8-encoded code points c that satisfy f(c).
Bytes function trimSpace
function trimSpace(_s:Array<UInt>):Array<UInt>
TrimSpace returns a subslice of s by slicing off all leading and
trailing white space, as defined by Unicode.
Bytes function trimSuffix
function trimSuffix(_s:Array<UInt>, _suffix:Array<UInt>):Array<UInt>
TrimSuffix returns s without the provided trailing suffix string.
If s doesn't end with suffix, s is returned unchanged.
Typedefs
import stdgo.bytes.*
typedef T_asciiSet
typedef T_asciiSet = stdgo._internal.bytes.T_asciiSet;
typedef T_readOp
typedef T_readOp = stdgo._internal.bytes.T_readOp;