zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 3a1f515e09902eeaafce0d1cd03c8472af6eacd0 (tree)
parent 1982e0c18a5d46a86ca411661a4d25039eb269e7
Author: LemonBoy <thatlemon@gmail.com>
Date:   Mon, 21 Sep 2020 21:36:17 +0200

Address review comments

Diffstat:
Mlib/std/fmt.zig | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

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