Add core/strings.odin

This commit is contained in:
Ginger Bill
2017-02-24 21:11:05 +00:00
parent eec709c545
commit 4cc4d604bc

15
core/strings.odin Normal file
View File

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