Browse Source

Add core/strings.odin

Ginger Bill 8 years ago
parent
commit
4cc4d604bc
1 changed files with 15 additions and 0 deletions
  1. 15 0
      core/strings.odin

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