X-Git-Url: http://www.git.stargrave.org/?p=tofuproxy.git;a=blobdiff_plain;f=tls%2Ftolower.go;fp=tls%2Ftolower.go;h=321441edd7ace0866f951f19c438340b0ad5c03a;hp=0000000000000000000000000000000000000000;hb=b11ace4832d2318235cdb1f836bb3677f6e52a20;hpb=00a1f9bafbb9a03c3753c2e3aee185b0a5fbb344 diff --git a/tls/tolower.go b/tls/tolower.go new file mode 100644 index 0000000..321441e --- /dev/null +++ b/tls/tolower.go @@ -0,0 +1,28 @@ +package tofuproxy + +import "unicode/utf8" + +// Copy-pasted from crypto/x509, as it is not public. +func toLowerCaseASCII(in string) string { + isAlreadyLowerCase := true + for _, c := range in { + if c == utf8.RuneError { + isAlreadyLowerCase = false + break + } + if 'A' <= c && c <= 'Z' { + isAlreadyLowerCase = false + break + } + } + if isAlreadyLowerCase { + return in + } + out := []byte(in) + for i, c := range out { + if 'A' <= c && c <= 'Z' { + out[i] += 'a' - 'A' + } + } + return string(out) +}