Adding upstream version 2.52.6.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
a960158181
commit
6d002e9543
441 changed files with 95392 additions and 0 deletions
69
utils/bytes.go
Normal file
69
utils/bytes.go
Normal file
|
@ -0,0 +1,69 @@
|
|||
// ⚡️ Fiber is an Express inspired web framework written in Go with ☕️
|
||||
// 🤖 Github Repository: https://github.com/gofiber/fiber
|
||||
// 📌 API Documentation: https://docs.gofiber.io
|
||||
|
||||
package utils
|
||||
|
||||
// ToLowerBytes converts ascii slice to lower-case in-place.
|
||||
func ToLowerBytes(b []byte) []byte {
|
||||
for i := 0; i < len(b); i++ {
|
||||
b[i] = toLowerTable[b[i]]
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// ToUpperBytes converts ascii slice to upper-case in-place.
|
||||
func ToUpperBytes(b []byte) []byte {
|
||||
for i := 0; i < len(b); i++ {
|
||||
b[i] = toUpperTable[b[i]]
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// TrimRightBytes is the equivalent of bytes.TrimRight
|
||||
func TrimRightBytes(b []byte, cutset byte) []byte {
|
||||
lenStr := len(b)
|
||||
for lenStr > 0 && b[lenStr-1] == cutset {
|
||||
lenStr--
|
||||
}
|
||||
return b[:lenStr]
|
||||
}
|
||||
|
||||
// TrimLeftBytes is the equivalent of bytes.TrimLeft
|
||||
func TrimLeftBytes(b []byte, cutset byte) []byte {
|
||||
lenStr, start := len(b), 0
|
||||
for start < lenStr && b[start] == cutset {
|
||||
start++
|
||||
}
|
||||
return b[start:]
|
||||
}
|
||||
|
||||
// TrimBytes is the equivalent of bytes.Trim
|
||||
func TrimBytes(b []byte, cutset byte) []byte {
|
||||
i, j := 0, len(b)-1
|
||||
for ; i <= j; i++ {
|
||||
if b[i] != cutset {
|
||||
break
|
||||
}
|
||||
}
|
||||
for ; i < j; j-- {
|
||||
if b[j] != cutset {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return b[i : j+1]
|
||||
}
|
||||
|
||||
// EqualFoldBytes tests ascii slices for equality case-insensitively
|
||||
func EqualFoldBytes(b, s []byte) bool {
|
||||
if len(b) != len(s) {
|
||||
return false
|
||||
}
|
||||
for i := len(b) - 1; i >= 0; i-- {
|
||||
if toUpperTable[b[i]] != toUpperTable[s[i]] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue