summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2020-11-22 12:42:37 -0500
committerrsiddharth <s@ricketyspace.net>2020-11-22 12:42:37 -0500
commit02fabe8ee0d05fc22a669b3ba9314aa7ee42b83c (patch)
tree244cfb98783e87e609c6622bcd50f465bdb4b0a8 /lib
parentbd9acac9a2cbfd82accdf7378240f965c61cb9bb (diff)
lib: str: add StrToBytes
Diffstat (limited to 'lib')
-rw-r--r--lib/str.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/str.go b/lib/str.go
index 9112a14..c71762c 100644
--- a/lib/str.go
+++ b/lib/str.go
@@ -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 := ""