zig

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

commit 9fec608b3bbe3c00528e01bd09aa29f9b9f97415 (tree)
parent abd250bb9c94923cc27ce1b09e6113845b7021fa
Author: Ryan Liptak <squeek502@hotmail.com>
Date:   Wed, 14 Feb 2024 14:56:36 -0800

Add std.fs.path.fmtAsUtf8Lossy/fmtWtf16LeAsUtf8Lossy

Diffstat:
Mlib/std/fs/path.zig | 15+++++++++++++++
1 file changed, 15 insertions(+), 0 deletions(-)

diff --git a/lib/std/fs/path.zig b/lib/std/fs/path.zig @@ -1939,3 +1939,18 @@ test "ComponentIterator roots" { try std.testing.expectEqualStrings("//a/b//", it.root().?); } } + +/// Format a path encoded as bytes for display as UTF-8. +/// Returns a Formatter for the given path. The path will be converted to valid UTF-8 +/// during formatting. This is a lossy conversion if the path contains any ill-formed UTF-8. +/// Ill-formed UTF-8 byte sequences are replaced by the replacement character (U+FFFD) +/// according to "U+FFFD Substitution of Maximal Subparts" from Chapter 3 of +/// the Unicode standard, and as specified by https://encoding.spec.whatwg.org/#utf-8-decoder +pub const fmtAsUtf8Lossy = std.unicode.fmtUtf8; + +/// Format a path encoded as WTF-16 LE for display as UTF-8. +/// Return a Formatter for a (potentially ill-formed) UTF-16 LE path. +/// The path will be converted to valid UTF-8 during formatting. This is +/// a lossy conversion if the path contains any unpaired surrogates. +/// Unpaired surrogates are replaced by the replacement character (U+FFFD). +pub const fmtWtf16LeAsUtf8Lossy = std.unicode.fmtUtf16Le;