Skip to content

std.fmt c specifier should print numbers as unicode codepoints #5564

@Vexu

Description

@Vexu

It makes no sense to have unicode character literals but no way to format them.

test "" {
    @import("std").debug.warn("{c}\n", .{'あ'});
    // error: Cannot print integer that is larger than 8 bits as a ascii
}

The c specifier should format integers as unicode codepoints and a new specifier should be added for formatting them as their literal bytes.

This is how the Go, Python, Odin and Java handle c.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breakingImplementing this issue could cause existing code to no longer compile or have different behavior.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.standard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions