diff options
| author | dam <dam@gudinoff> | 2023-03-16 23:55:54 +0000 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2023-03-16 23:55:54 +0000 |
| commit | efb6c8606d7e39a6ac9776bb1e4e28340aba2e29 (patch) | |
| tree | 21520007a0e741b50e45f4865e35c40cfcd9c249 /ttt.jai | |
| parent | a6726bbe9a0217a25dd3007c2b28d1a3ceb30672 (diff) | |
| download | task-time-tracker-efb6c8606d7e39a6ac9776bb1e4e28340aba2e29.tar.zst task-time-tracker-efb6c8606d7e39a6ac9776bb1e4e28340aba2e29.zip | |
Fixed truncate_string_utf8.
Diffstat (limited to 'ttt.jai')
| -rw-r--r-- | ttt.jai | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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; |
