mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 11:29:02 +00:00
Convert os.environ to WTF-8 (#23885)
* Fixes #17773 * Fixes #13728 * Fixes #11041 * Fixes ENG-21082 * Fixes https://github.com/oven-sh/bun/issues/23482 * Fixes https://github.com/oven-sh/bun/issues/23734 * Fixes https://github.com/oven-sh/bun/issues/23488 * Fixes https://github.com/oven-sh/bun/issues/23485 --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -303,17 +303,9 @@ pub fn convertUTF16ToUTF8Append(list: *std.ArrayList(u8), utf16: []const u16) OO
|
||||
}
|
||||
|
||||
pub fn toUTF8AllocWithTypeWithoutInvalidSurrogatePairs(allocator: std.mem.Allocator, utf16: []const u16) OOM![]u8 {
|
||||
if (bun.FeatureFlags.use_simdutf) {
|
||||
const length = bun.simdutf.length.utf8.from.utf16.le(utf16);
|
||||
// add 16 bytes of padding for SIMDUTF
|
||||
var list = try std.ArrayList(u8).initCapacity(allocator, length + 16);
|
||||
list = try convertUTF16ToUTF8(list, utf16);
|
||||
return list.items;
|
||||
}
|
||||
|
||||
var list = try std.ArrayList(u8).initCapacity(allocator, utf16.len);
|
||||
list = try toUTF8ListWithType(list, utf16);
|
||||
return list.items;
|
||||
// previously, this function was an exact copy of `toUTF8AllocWithType`.
|
||||
// TODO: actually make this function behave differently?
|
||||
return toUTF8AllocWithType(allocator, utf16);
|
||||
}
|
||||
|
||||
pub fn toUTF8AllocWithType(allocator: std.mem.Allocator, utf16: []const u16) OOM![]u8 {
|
||||
@@ -322,12 +314,12 @@ pub fn toUTF8AllocWithType(allocator: std.mem.Allocator, utf16: []const u16) OOM
|
||||
// add 16 bytes of padding for SIMDUTF
|
||||
var list = try std.ArrayList(u8).initCapacity(allocator, length + 16);
|
||||
list = try convertUTF16ToUTF8(list, utf16);
|
||||
return list.items;
|
||||
return list.toOwnedSlice();
|
||||
}
|
||||
|
||||
var list = try std.ArrayList(u8).initCapacity(allocator, utf16.len);
|
||||
list = try toUTF8ListWithType(list, utf16);
|
||||
return list.items;
|
||||
return list.toOwnedSlice();
|
||||
}
|
||||
|
||||
pub fn toUTF8ListWithType(list_: std.ArrayList(u8), utf16: []const u16) OOM!std.ArrayList(u8) {
|
||||
|
||||
Reference in New Issue
Block a user