diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-02-24 21:11:05 +0000 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-02-24 21:11:05 +0000 |
| commit | 4cc4d604bcfb34a23272e8c467c16be2fc17d523 (patch) | |
| tree | 52de17b575838be2472f46c1337cd8ceacf83228 | |
| parent | eec709c545cb2f2c754db83e374d66f83c432ae9 (diff) | |
Add core/strings.odin
| -rw-r--r-- | core/strings.odin | 15 |
1 files changed, 15 insertions, 0 deletions
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; +} |