diff options
| author | Shulhan <ms@kilabit.info> | 2018-08-29 22:05:29 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2018-08-29 23:18:48 +0700 |
| commit | f334b04f5006071aa055fd842064b326c3b22011 (patch) | |
| tree | d33340603d28914feb90c5fca9b4117d15c38467 /lib/bytes/bytes.go | |
| parent | 428e2764213dbb08169b1e7b607c56a027dac131 (diff) | |
| download | pakakeh.go-f334b04f5006071aa055fd842064b326c3b22011.tar.xz | |
lib/dns: HostsLoad: convert hostname to lower case
Diffstat (limited to 'lib/bytes/bytes.go')
| -rw-r--r-- | lib/bytes/bytes.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/bytes/bytes.go b/lib/bytes/bytes.go index 23257ee9..549d82db 100644 --- a/lib/bytes/bytes.go +++ b/lib/bytes/bytes.go @@ -100,3 +100,27 @@ func AppendUint32(data *[]byte, v uint32) { *data = append(*data, byte(v>>8)) *data = append(*data, byte(v)) } + +// +// ToLower convert slice of bytes to lower cases, in places. +// +func ToLower(data *[]byte) { + for x := 0; x < len(*data); x++ { + if (*data)[x] < 'A' || (*data)[x] > 'Z' { + continue + } + (*data)[x] = (*data)[x] + 32 + } +} + +// +// ToUpper convert slice of bytes to upper cases, in places. +// +func ToUpper(data *[]byte) { + for x := 0; x < len(*data); x++ { + if (*data)[x] < 'a' || (*data)[x] > 'z' { + continue + } + (*data)[x] = (*data)[x] - 32 + } +} |
