aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/config/string.zig
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-09-10 21:51:57 +0300
committerGitHub <noreply@github.com>2026-09-10 21:51:57 +0300
commit425c86179791cd32e2d4ce0ae7f269940b4b0663 (patch)
treee52c4383a6d69216cbe2a32638bf90841d7e2189 /vendor/libghostty-vt/src/config/string.zig
parent90e947a6e26e02f10ec7f1694c4eb5b78a86406b (diff)
chore: upgrade libghostty and preserve terminal behavior (#3906)
Diffstat (limited to 'vendor/libghostty-vt/src/config/string.zig')
-rw-r--r--vendor/libghostty-vt/src/config/string.zig24
1 files changed, 20 insertions, 4 deletions
diff --git a/vendor/libghostty-vt/src/config/string.zig b/vendor/libghostty-vt/src/config/string.zig
index 45079937..8d4fc7b4 100644
--- a/vendor/libghostty-vt/src/config/string.zig
+++ b/vendor/libghostty-vt/src/config/string.zig
@@ -20,16 +20,23 @@ pub fn parse(out: []u8, bytes: []const u8) ![]u8 {
continue;
}
+ // Zig's \xNN syntax represents a single byte, while the other
+ // escape sequences represent Unicode codepoints.
+ const is_byte_escape = src_i + 1 < bytes.len and
+ bytes[src_i + 1] == 'x';
+
// Parse the escape sequence
switch (std.zig.string_literal.parseEscapeSequence(
bytes,
&src_i,
)) {
.failure => return error.InvalidString,
- .success => |cp| dst_i += try std.unicode.utf8Encode(
- cp,
- out[dst_i..],
- ),
+ .success => |cp| if (is_byte_escape) {
+ out[dst_i] = @intCast(cp);
+ dst_i += 1;
+ } else {
+ dst_i += try std.unicode.utf8Encode(cp, out[dst_i..]);
+ },
}
}
@@ -100,6 +107,15 @@ test "parse: escapes" {
}
}
+test "parse: hex escapes are bytes" {
+ var buf: [128]u8 = undefined;
+ const result = try parse(
+ &buf,
+ "\\xe6\\x97\\xa5\\xe6\\x9c\\xac\\xe8\\xaa\\x9e",
+ );
+ try std.testing.expectEqualStrings("日本語", result);
+}
+
test "codepointIterator: empty" {
var it = codepointIterator("");
try std.testing.expectEqual(null, try it.next());