Source File
ascii.go
Belonging Package
golang.org/x/net/http2
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package http2
import
// The HTTP protocols are defined in terms of ASCII, not Unicode. This file
// contains helper functions which may use Unicode-aware functions which would
// otherwise be unsafe and could introduce vulnerabilities if used improperly.
// asciiEqualFold is strings.EqualFold, ASCII only. It reports whether s and t
// are equal, ASCII-case-insensitively.
func (, string) bool {
if len() != len() {
return false
}
for := 0; < len(); ++ {
if lower([]) != lower([]) {
return false
}
}
return true
}
// lower returns the ASCII lowercase version of b.
func ( byte) byte {
if 'A' <= && <= 'Z' {
return + ('a' - 'A')
}
return
}
// isASCIIPrint returns whether s is ASCII and printable according to
// https://tools.ietf.org/html/rfc20#section-4.2.
func ( string) bool {
for := 0; < len(); ++ {
if [] < ' ' || [] > '~' {
return false
}
}
return true
}
// asciiToLower returns the lowercase version of s if s is ASCII and printable,
// and whether or not it was.
func ( string) ( string, bool) {
if !isASCIIPrint() {
return "", false
}
return strings.ToLower(), true
}
The pages are generated with Golds v0.4.9. (GOOS=linux GOARCH=amd64)