@@ 34623,4 34623,4 @@ E01EF;VARIATION SELECTOR-256;Mn;0;NSM;;;;;N;;;;;
F0000;<Plane 15 Private Use, First>;Co;0;L;;;;;N;;;;;
FFFFD;<Plane 15 Private Use, Last>;Co;0;L;;;;;N;;;;;
100000;<Plane 16 Private Use, First>;Co;0;L;;;;;N;;;;;
-10FFFD;<Plane 16 Private Use, Last>;Co;0;L;;;;;N;;;;;
+10FFFD;<Plane 16 Private Use, Last>;Co;0;L;;;;;N;;;;;<
\ No newline at end of file
@@ 22,24 22,29 @@ pub fn main() anyerror!void {
fn writeMatches(writer: anytype, needle: []const u8) !void {
var split_it = std.mem.split(u8, UNICODE_DATA, "\n");
- while (split_it.next()) |line| {
- if (std.mem.indexOf(u8, line, needle)) |_| {
- try writeMatch(writer, line);
- }
- }
+ while (split_it.next()) |line|
+ try writeMatch(writer, line, needle);
}
-fn writeMatch(writer: anytype, line: []const u8) !void {
+fn writeMatch(writer: anytype, line: []const u8, needle: []const u8) !void {
var utf8_char: [8]u8 = undefined;
var col_it = std.mem.split(u8, line, ";");
- const cp = try std.fmt.parseInt(u21, col_it.next() orelse return error.BongosData, 16);
- const len = try std.unicode.utf8Encode(cp, &utf8_char);
- try writer.print("{s} code: 0x{x:<6} name: {s:<14} category: {s}\n", .{
- utf8_char[0..len],
- cp,
- col_it.next() orelse return error.BongosData,
- col_it.next() orelse return error.BongosData,
- });
+ const code = col_it.next() orelse return error.MissingCode;
+ const name = col_it.next() orelse return error.MissingName;
+
+ if (std.mem.indexOf(u8, name, needle)) |idx| {
+ const category = col_it.next() orelse return error.MissingCategory;
+ const cp = try std.fmt.parseInt(u21, code, 16);
+ const len = try std.unicode.utf8Encode(cp, &utf8_char);
+ try writer.print("{s} code: 0x{x:<6} name: {s}\x1b[1m{s}\x1b[0m{s} category: {s}\n", .{
+ utf8_char[0..len],
+ cp,
+ name[0..idx],
+ name[idx .. idx + needle.len],
+ name[idx + needle.len ..],
+ category,
+ });
+ }
}
fn badToUpper(c: u8) u8 {