diff options
author | rsiddharth <s@ricketyspace.net> | 2020-11-22 12:42:37 -0500 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2020-11-22 12:42:37 -0500 |
commit | 02fabe8ee0d05fc22a669b3ba9314aa7ee42b83c (patch) | |
tree | 244cfb98783e87e609c6622bcd50f465bdb4b0a8 /lib/str.go | |
parent | bd9acac9a2cbfd82accdf7378240f965c61cb9bb (diff) |
lib: str: add StrToBytes
Diffstat (limited to 'lib/str.go')
-rw-r--r-- | lib/str.go | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -25,6 +25,14 @@ func FillBytes(c byte, l int) []byte { return bs } +func StrToBytes(s string) []byte { + bs := make([]byte, len(s)) + for i := 0; i < len(s); i++ { + bs[i] = byte(s[i]) + } + return bs +} + // Strip space and newline characters from string. func stripSpaceChars(s string) string { ss := "" |