Source File
ascii.go
Belonging Package
golang.org/x/net/internal/httpcommon
// Copyright 2025 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 httpcommonimport// 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 asciiEqualFold(, 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 lower( 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 isASCIIPrint( 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 asciiToLower( string) ( string, bool) {if !isASCIIPrint() {return "", false}return strings.ToLower(), true}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |