mirror of
https://github.com/odin-lang/Odin.git
synced 2026-03-03 07:08:20 +00:00
Add core/strings.odin
This commit is contained in:
15
core/strings.odin
Normal file
15
core/strings.odin
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user