mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 04:18:58 +00:00
UDP support (#7271)
Co-authored-by: Georgijs Vilums <georgijs@bun.sh> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: gvilums <gvilums@users.noreply.github.com> Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> Co-authored-by: Jarred-Sumner <Jarred-Sumner@users.noreply.github.com> Co-authored-by: Georgijs <48869301+gvilums@users.noreply.github.com> Co-authored-by: Georgijs Vilums <=>
This commit is contained in:
@@ -158,6 +158,17 @@ pub const WTFStringImplStruct = extern struct {
|
||||
);
|
||||
}
|
||||
|
||||
pub fn toOwnedSliceZ(this: WTFStringImpl, allocator: std.mem.Allocator) [:0]u8 {
|
||||
if (this.is8Bit()) {
|
||||
if (bun.strings.toUTF8FromLatin1Z(allocator, this.latin1Slice()) catch bun.outOfMemory()) |utf8| {
|
||||
return utf8.items[0 .. utf8.items.len - 1 :0];
|
||||
}
|
||||
|
||||
return allocator.dupeZ(u8, this.latin1Slice()) catch bun.outOfMemory();
|
||||
}
|
||||
return bun.strings.toUTF8AllocZ(allocator, this.utf16Slice()) catch bun.outOfMemory();
|
||||
}
|
||||
|
||||
pub fn toUTF8IfNeeded(this: WTFStringImpl, allocator: std.mem.Allocator) ?ZigString.Slice {
|
||||
if (this.is8Bit()) {
|
||||
if (bun.strings.toUTF8FromLatin1(allocator, this.latin1Slice()) catch bun.outOfMemory()) |utf8| {
|
||||
|
||||
Reference in New Issue
Block a user