Replace std.unicode.fmtUtf16le with bun.fmt.utf16 (#9127)

* Replace `std.unicode.fmtUtf16le` with `bun.fmt.utf16`

* Update fmt.zig

* Remove bun.fmt.fmtUTF16

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
This commit is contained in:
Jarred Sumner
2024-02-26 18:35:18 -08:00
committed by GitHub
parent 675dad2fe8
commit f1b8df29e8
11 changed files with 24 additions and 35 deletions

View File

@@ -1829,12 +1829,12 @@ pub fn assertIsValidWindowsPath(comptime T: type, path: []const T) void {
isWindowsAbsolutePathMissingDriveLetter(T, path))
{
std.debug.panic("Internal Error: Do not pass posix paths to Windows APIs, was given '{s}'" ++ if (Environment.isDebug) " (missing a root like 'C:\\', see PosixToWinNormalizer for why this is an assertion)" else ". Please open an issue on GitHub with a reproduction.", .{
if (T == u8) path else std.unicode.fmtUtf16le(path),
if (T == u8) path else bun.fmt.utf16(path),
});
}
if (hasPrefixComptimeType(T, path, ":/") and Environment.isDebug) {
std.debug.panic("Path passed to windows API '{s}' is almost certainly invalid. Where did the drive letter go?", .{
if (T == u8) path else std.unicode.fmtUtf16le(path),
if (T == u8) path else bun.fmt.utf16(path),
});
}
}
@@ -4510,13 +4510,6 @@ test "firstNonASCII16" {
}
}
test "print UTF16" {
var err = std.io.getStdErr();
const utf16 = comptime toUTF16Literal("❌ ✅ opkay ");
try bun.fmt.str.formatUTF16(utf16, err.writer());
// std.unicode.fmtUtf16le(utf16le: []const u16)
}
/// Convert potentially ill-formed UTF-8 or UTF-16 bytes to a Unicode Codepoint.
/// - Invalid codepoints are replaced with `zero` parameter
/// - Null bytes return 0