From ceb746e53721c660146377d77b244a407ee2193e Mon Sep 17 00:00:00 2001
From: Ed_ <edwardgz@gmail.com>
Date: Tue, 5 Mar 2024 10:19:27 -0500
Subject: [PATCH] Rolled my own string_to_runes

---
 code/grime_unicode.odin | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/code/grime_unicode.odin b/code/grime_unicode.odin
index 2098058..554d96b 100644
--- a/code/grime_unicode.odin
+++ b/code/grime_unicode.odin
@@ -1,12 +1,11 @@
 package sectr
 
-string_to_runes :: proc( content : string, allocator := context.allocator ) -> ( []rune, AllocatorError )
+string_to_runes_array :: proc( content : string, allocator := context.allocator ) -> ( []rune, AllocatorError )
 {
 	num := cast(u64) str_rune_count(content)
 
 	runes_array, alloc_error := array_init_reserve( rune, allocator, num )
 	if alloc_error != AllocatorError.None {
-		ensure( false, "Failed to allocate runes array" )
 		return nil, alloc_error
 	}
 
@@ -19,3 +18,19 @@ string_to_runes :: proc( content : string, allocator := context.allocator ) -> (
 	}
 	return runes, alloc_error
 }
+
+string_to_runes :: proc "odin" (s: string, allocator := context.allocator) -> (runes: []rune, alloc_error : AllocatorError) {
+	num := str_rune_count(s)
+
+	runes, alloc_error = make([]rune, num, allocator)
+	if alloc_error != AllocatorError.None {
+		return nil, alloc_error
+	}
+
+	idx := 0
+	for codepoint in s {
+		runes[idx] = codepoint
+		idx += 1
+	}
+	return
+}