1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
|
func ToUpper(s []byte) []byte func ToLower(s []byte) []byte func ToTitle(s []byte) []byte
func ToUpperSpecial(_case unicode.SpecialCase, s []byte) []byte func ToLowerSpecial(_case unicode.SpecialCase, s []byte) []byte func ToTitleSpecial(_case unicode.SpecialCase, s []byte) []byte
func Title(s []byte) []byte
------------------------------
func Compare(a, b []byte) int
func Equal(a, b []byte) bool
func EqualFold(s, t []byte) bool
------------------------------
func main() { s1 := "Φφϕ kKK" s2 := "ϕΦφ KkK"
for _, c := range s1 { fmt.Printf("%-5x", c) } fmt.Println() for _, c := range s2 { fmt.Printf("%-5x", c) } fmt.Println() fmt.Println(bytes.EqualFold([]byte(s1), []byte(s2))) }
------------------------------
func Trim(s []byte, cutset string) []byte func TrimLeft(s []byte, cutset string) []byte func TrimRight(s []byte, cutset string) []byte
func TrimFunc(s []byte, f func(r rune) bool) []byte func TrimLeftFunc(s []byte, f func(r rune) bool) []byte func TrimRightFunc(s []byte, f func(r rune) bool) []byte
func TrimSpace(s []byte) []byte
func TrimPrefix(s, prefix []byte) []byte func TrimSuffix(s, suffix []byte) []byte
------------------------------
func main() { bs := [][]byte{ []byte("Hello World !"), []byte("Hello 世界!"), []byte("hello golang ."), } f := func(r rune) bool { return bytes.ContainsRune([]byte("!!. "), r) } for _, b := range bs { fmt.Printf("%q\n", bytes.TrimFunc(b, f)) } for _, b := range bs { fmt.Printf("%q\n", bytes.TrimPrefix(b, []byte("Hello "))) } }
------------------------------
func Split(s, sep []byte) [][]byte func SplitN(s, sep []byte, n int) [][]byte
func SplitAfter(s, sep []byte) [][]byte func SplitAfterN(s, sep []byte, n int) [][]byte
func Fields(s []byte) [][]byte
func FieldsFunc(s []byte, f func(rune) bool) [][]byte
func Join(s [][]byte, sep []byte) []byte
func Repeat(b []byte, count int) []byte
------------------------------
func main() { b := []byte(" Hello World ! ") fmt.Printf("%q\n", bytes.Split(b, []byte{' '})) fmt.Printf("%q\n", bytes.Fields(b)) f := func(r rune) bool { return bytes.ContainsRune([]byte(" !"), r) } fmt.Printf("%q\n", bytes.FieldsFunc(b, f)) }
------------------------------
func HasPrefix(s, prefix []byte) bool func HasSuffix(s, suffix []byte) bool
func Contains(b, subslice []byte) bool func ContainsRune(b []byte, r rune) bool
func ContainsAny(b []byte, chars string) bool
func Index(s, sep []byte) int func IndexByte(s []byte, c byte) int func IndexRune(s []byte, r rune) int
func IndexAny(s []byte, chars string) int
func IndexFunc(s []byte, f func(r rune) bool) int
func LastIndex(s, sep []byte) int func LastIndexByte(s []byte, c byte) int func LastIndexAny(s []byte, chars string) int func LastIndexFunc(s []byte, f func(r rune) bool) int
func Count(s, sep []byte) int
------------------------------
func Replace(s, old, new []byte, n int) []byte
func Map(mapping func(r rune) rune, s []byte) []byte
func Runes(s []byte) []rune
------------------------------------------------------------
type Reader struct { ... }
func NewReader(b []byte) *Reader
func (r *Reader) Len() int
func (r *Reader) Size() int64
func (r *Reader) Reset(b []byte)
------------------------------
func main() { b1 := []byte("Hello World!") b2 := []byte("Hello 世界!") buf := make([]byte, 6) rd := bytes.NewReader(b1) rd.Read(buf) fmt.Printf("%q\n", buf) rd.Read(buf) fmt.Printf("%q\n", buf)
rd.Reset(b2) rd.Read(buf) fmt.Printf("%q\n", buf) fmt.Printf("Size:%d, Len:%d\n", rd.Size(), rd.Len()) }
------------------------------------------------------------
type Buffer struct { ... }
func NewBuffer(buf []byte) *Buffer
func NewBufferString(s string) *Buffer
func (b *Buffer) Len() int
func (b *Buffer) Cap() int
func (b *Buffer) Next(n int) []byte
func (b *Buffer) ReadBytes(delim byte) (line []byte, err error) func (b *Buffer) ReadString(delim byte) (line string, err error)
func (b *Buffer) WriteRune(r rune) (n int, err error)
func (b *Buffer) WriteString(s string) (n int, err error)
func (b *Buffer) Bytes() []byte
func (b *Buffer) String() string
func (b *Buffer) Grow(n int)
func (b *Buffer) Truncate(n int)
func (b *Buffer) Reset()
------------------------------
func main() { rd := bytes.NewBufferString("Hello World!") buf := make([]byte, 6) b := rd.Bytes() rd.Read(buf) fmt.Printf("%s\n", rd.String()) fmt.Printf("%s\n\n", b)
rd.Write([]byte("abcdefg")) fmt.Printf("%s\n", rd.String()) fmt.Printf("%s\n\n", b)
rd.Read(buf) fmt.Printf("%s\n", rd.String()) fmt.Printf("%s\n", b) }
|