diff options
author | 2023-06-11 05:26:37 -0700 | |
---|---|---|
committer | 2023-06-11 05:26:37 -0700 | |
commit | ef65f3c305e989bd7d7fe6f0e73822bdbe0e91dd (patch) | |
tree | 208a5f55d885c95afe40366bbe7b0e6d4c5f7859 /src/string_immutable.zig | |
parent | 02eafd5019150357012ebb7a39f1c264ba73599e (diff) | |
download | bun-ef65f3c305e989bd7d7fe6f0e73822bdbe0e91dd.tar.gz bun-ef65f3c305e989bd7d7fe6f0e73822bdbe0e91dd.tar.zst bun-ef65f3c305e989bd7d7fe6f0e73822bdbe0e91dd.zip |
Support using `WTF::StringImpl` from Zig (#3279)
* Fix `make headers`
* [JS parser] Fix bug with printing non-ascii import paths in ascii mode
* Introduce `bun.String`
* Add test for non-ascii imports & entry points
* Add comment
* Fix build issue
* Support HTTP server
* Make it print the same
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to '')
-rw-r--r-- | src/string_immutable.zig | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/string_immutable.zig b/src/string_immutable.zig index 3d1724d4e..8aaa6f8e8 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -1467,6 +1467,17 @@ pub fn toUTF8ListWithType(list_: std.ArrayList(u8), comptime Type: type, utf16: return toUTF8ListWithTypeBun(list_, Type, utf16); } +pub fn toUTF8FromLatin1(allocator: std.mem.Allocator, latin1: []const u8) !?std.ArrayList(u8) { + if (bun.JSC.is_bindgen) + unreachable; + + if (isAllASCII(latin1)) + return null; + + var list = try std.ArrayList(u8).initCapacity(allocator, latin1.len); + return try allocateLatin1IntoUTF8WithList(list, 0, []const u8, latin1); +} + pub fn toUTF8ListWithTypeBun(list_: std.ArrayList(u8), comptime Type: type, utf16: Type) !std.ArrayList(u8) { var list = list_; var utf16_remaining = utf16; |