Skip to content

Commit 33d0c26

Browse files
committed
Add std.fs.path.fmtAsUtf8Lossy/fmtWtf16LeAsUtf8Lossy
1 parent 1f07850 commit 33d0c26

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/std/fs/path.zig

+15
Original file line numberDiff line numberDiff line change
@@ -1939,3 +1939,18 @@ test "ComponentIterator roots" {
19391939
try std.testing.expectEqualStrings("//a/b//", it.root().?);
19401940
}
19411941
}
1942+
1943+
/// Format a path encoded as bytes for display as UTF-8.
1944+
/// Returns a Formatter for the given path. The path will be converted to valid UTF-8
1945+
/// during formatting. This is a lossy conversion if the path contains any ill-formed UTF-8.
1946+
/// Ill-formed UTF-8 byte sequences are replaced by the replacement character (U+FFFD)
1947+
/// according to "U+FFFD Substitution of Maximal Subparts" from Chapter 3 of
1948+
/// the Unicode standard, and as specified by https://encoding.spec.whatwg.org/#utf-8-decoder
1949+
pub const fmtAsUtf8Lossy = std.unicode.fmtUtf8;
1950+
1951+
/// Format a path encoded as WTF-16 LE for display as UTF-8.
1952+
/// Return a Formatter for a (potentially ill-formed) UTF-16 LE path.
1953+
/// The path will be converted to valid UTF-8 during formatting. This is
1954+
/// a lossy conversion if the path contains any unpaired surrogates.
1955+
/// Unpaired surrogates are replaced by the replacement character (U+FFFD).
1956+
pub const fmtWtf16LeAsUtf8Lossy = std.unicode.fmtUtf16Le;

0 commit comments

Comments
 (0)