From 4cc4d604bcfb34a23272e8c467c16be2fc17d523 Mon Sep 17 00:00:00 2001 From: Ginger Bill Date: Fri, 24 Feb 2017 21:11:05 +0000 Subject: [PATCH] Add core/strings.odin --- core/strings.odin | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 core/strings.odin diff --git a/core/strings.odin b/core/strings.odin new file mode 100644 index 000000000..bfc16a184 --- /dev/null +++ b/core/strings.odin @@ -0,0 +1,15 @@ +new_c_string :: proc(s: string) -> ^byte { + c := new_c_string(byte, s.count+1); + copy(c, cast([]byte)s); + c[s.count] = 0; + return c; +} + +to_odin_string :: proc(c: ^byte) -> string { + s: string; + s.data = c; + for (c+s.count)^ != 0 { + s.count += 1; + } + return s; +}