| ... | @@ -561,7 +561,7 @@ pub fn formatIntValue( | ... | @@ -561,7 +561,7 @@ pub fn formatIntValue( |
| 561 | if (@typeInfo(@TypeOf(int_value)).Int.bits <= 21) { | 561 | if (@typeInfo(@TypeOf(int_value)).Int.bits <= 21) { |
| 562 | return formatUnicodeCodepoint(@as(u21, int_value), options, writer); | 562 | return formatUnicodeCodepoint(@as(u21, int_value), options, writer); |
| 563 | } else { | 563 | } else { |
| 564 | @compileError("Cannot print integer that is larger than 32 bits as an UTF-8 sequence"); | 564 | @compileError("Cannot print integer that is larger than 21 bits as an UTF-8 sequence"); |
| 565 | } | 565 | } |
| 566 | } else if (comptime std.mem.eql(u8, fmt, "b")) { | 566 | } else if (comptime std.mem.eql(u8, fmt, "b")) { |
| 567 | radix = 2; | 567 | radix = 2; |
| ... | @@ -657,7 +657,7 @@ pub fn formatUnicodeCodepoint( | ... | @@ -657,7 +657,7 @@ pub fn formatUnicodeCodepoint( |
| 657 | if (unicode.utf8ValidCodepoint(c)) { | 657 | if (unicode.utf8ValidCodepoint(c)) { |
| 658 | var buf: [4]u8 = undefined; | 658 | var buf: [4]u8 = undefined; |
| 659 | // The codepoint is surely valid, hence the use of unreachable | 659 | // The codepoint is surely valid, hence the use of unreachable |
| 660 | const len = std.unicode.utf8Encode(@truncate(u21, c), &buf) catch |err| switch (err) { | 660 | const len = std.unicode.utf8Encode(c, &buf) catch |err| switch (err) { |
| 661 | error.Utf8CannotEncodeSurrogateHalf, error.CodepointTooLarge => unreachable, | 661 | error.Utf8CannotEncodeSurrogateHalf, error.CodepointTooLarge => unreachable, |
| 662 | }; | 662 | }; |
| 663 | return formatBuf(buf[0..len], options, writer); | 663 | return formatBuf(buf[0..len], options, writer); |