aboutsummaryrefslogtreecommitdiff
path: root/ttt.jai
diff options
context:
space:
mode:
authordam <dam@gudinoff>2023-03-16 23:55:54 +0000
committerdam <dam@gudinoff>2023-03-16 23:55:54 +0000
commitefb6c8606d7e39a6ac9776bb1e4e28340aba2e29 (patch)
tree21520007a0e741b50e45f4865e35c40cfcd9c249 /ttt.jai
parenta6726bbe9a0217a25dd3007c2b28d1a3ceb30672 (diff)
downloadtask-time-tracker-efb6c8606d7e39a6ac9776bb1e4e28340aba2e29.tar.zst
task-time-tracker-efb6c8606d7e39a6ac9776bb1e4e28340aba2e29.zip
Fixed truncate_string_utf8.
Diffstat (limited to 'ttt.jai')
-rw-r--r--ttt.jai12
1 files changed, 8 insertions, 4 deletions
diff --git a/ttt.jai b/ttt.jai
index e24419d..8a75568 100644
--- a/ttt.jai
+++ b/ttt.jai
@@ -183,6 +183,8 @@ truncate_string_utf8 :: (str: string, length: s64) -> length: s64 {
data := str.data;
count := str.count;
+
+ // WIP simplify this if/else and try to use only idx or length
// Find index of first continuation byte.
idx := length;
@@ -206,8 +208,7 @@ truncate_string_utf8 :: (str: string, length: s64) -> length: s64 {
length -= (continuation_bytes + 1); // Remove '+ 1' start byte.
}
- ptr := data + length;
- memset(ptr, 0, str.count - length);
+ memset(data + length, 0, count - length);
return length;
}
/*
@@ -1297,9 +1298,12 @@ main :: () {
format(xx vb);
print("--- --- ---\n");
- xpto: string = "ç€dam";
- truncate_string_utf8(xpto, 3);
+ xpto: string = copy_string("ç€dam");
+ memcpy(vb.data, xpto.data, xpto.count);
+ truncate_string_utf8(xx vb, 5);
+ // memset(xpto.data, 0, 5);
print(">'%'\n", xpto);
+ print(">'%'\n", cast(string)vb);
return;