| 1 | const std = @import("std"); |
| 2 | const common = @import("./_common.zig"); |
| 3 | |
| 4 | pub usingnamespace common.Main(struct { |
| 5 | pub const source_file = "EquivalentUnifiedIdeograph"; |
| 6 | |
| 7 | pub const dest_file = "src/equivalent_unified_ideograph.zig"; |
| 8 | |
| 9 | pub const dest_header = |
| 10 | \\pub const data = [_][2]u21{ |
| 11 | \\ |
| 12 | ; |
| 13 | |
| 14 | pub const dest_footer = |
| 15 | \\}; |
| 16 | \\ |
| 17 | ; |
| 18 | |
| 19 | pub fn exec(alloc: std.mem.Allocator, line: []const u8, writer: anytype) !void { |
| 20 | _ = alloc; |
| 21 | var it = std.mem.tokenizeAny(u8, line, "; "); |
| 22 | |
| 23 | const first = it.next().?; |
| 24 | const next = it.next().?; |
| 25 | |
| 26 | if (std.mem.indexOf(u8, first, "..")) |index| { |
| 27 | const start = try std.fmt.parseInt(u21, first[0..index], 16); |
| 28 | const end = try std.fmt.parseInt(u21, first[index + 2 ..], 16); |
| 29 | var i = start; |
| 30 | while (i <= end) : (i += 1) { |
| 31 | try writer.print(" .{{ 0x{X}, 0x{s} }},\n", .{ i, next }); |
| 32 | } |
| 33 | } else { |
| 34 | try writer.print(" .{{ 0x{s}, 0x{s} }},\n", .{ first, next }); |
| 35 | } |
| 36 | } |
| 37 | }); |