Unicode literal to C like character literal

This commit is contained in:
Krzosa Karol
2022-09-27 10:21:19 +02:00
parent 4f51749787
commit fef98220ba
5 changed files with 20 additions and 14 deletions

View File

@@ -142,11 +142,11 @@ test_unicode :: (arena: *Arena)
string_result := string_to_string16(arena, string)
print(string_result)
s32, s32_len := utf8_to_utf32(&"A"[0], 1)
assert(s32 == 'A, "Invalid decode") // '
s32, s32_len := utf8_to_utf32('A', 1)
assert(s32 == 'A', "Invalid decode")
s32_2, s32_len_2 := utf8_to_utf32(&"ć"[0], 2)
s32_2, s32_len_2 := utf8_to_utf32('ć', 2)
assert(s32_2 == 0x107, "Invalid decode")
s32_3, s32_len_3 := utf8_to_utf32(&"ó"[0], 2)
s32_3, s32_len_3 := utf8_to_utf32('ó', 2)
assert(s32_3 == 0xF3, "Invalid decode")

View File

@@ -85,7 +85,7 @@ itoa :: (value: S64, result: *U8, base: S64): *U8
// Apply negative sign
if tmp_value < 0
*ptr++ = '- // '
*ptr++ = '-'
*ptr-- = 0
for ptr1 < ptr
tmp_char = *ptr
@@ -100,7 +100,7 @@ print :: (string: String, args: ..)
arg_counter := 0
for i := 0, i < length_of(string), i+=1
if string[i] == '% // '
if string[i] == '%'
assert(arg_counter < length_of(args), "Passing too many [%] to a print lambda")
arg := args[arg_counter++]