You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

23 lines
401 B

package sip
import (
"bytes"
)
const (
hexChars = "0123456789abcdef"
)
// appendEscaped appends while URL encoding bytes that don't match the predicate..
func appendEscaped(b *bytes.Buffer, s []byte, p func(byte) bool) {
for i := 0; i < len(s); i++ {
c := s[i]
if p(c) {
b.WriteByte(c)
} else {
b.WriteByte('%')
b.WriteByte(hexChars[c>>4])
b.WriteByte(hexChars[c%16])
}
}
}