2
0

strings.odin 262 B

123456789101112131415
  1. new_c_string :: proc(s: string) -> ^byte {
  2. c := new_slice(byte, s.count+1);
  3. copy(c, cast([]byte)s);
  4. c[s.count] = 0;
  5. return c.data;
  6. }
  7. to_odin_string :: proc(c: ^byte) -> string {
  8. s: string;
  9. s.data = c;
  10. for (c+s.count)^ != 0 {
  11. s.count++;
  12. }
  13. return s;
  14. }