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; +}