logo

9utils

Collection of utilities inspired by Plan9
commit: b40273cf90ccc14b17377fb26ef75950cffebe19
parent d930ae6691d9ae8dec71150e5cad0e200471bf13
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sun, 17 Sep 2023 19:48:27 +0200

cmd/unicode: Format using upper-case hex

Diffstat:

Mcmd/unicode.ha6+++---
Mtest-cmd/unicode.t16++++++++--------
2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/cmd/unicode.ha b/cmd/unicode.ha @@ -51,10 +51,10 @@ fn table(args: []str) void = { const (cel_width, cel_fmt) = if(max < 0xFFFF) { // (1 char, non-break space, 4 hex, 2 space) = 8 chars - yield (8u16, "{} {:04x} "); + yield (8u16, "{} {:04X} "); } else { // (1 char, non-break space, 8 hex, 2 space) = 12 chars - yield (12u16, "{} {:08x} "); + yield (12u16, "{} {:08X} "); }; match(tsize) { @@ -85,7 +85,7 @@ fn decode(args: []str) void = { for(let ri = 0z; ri < len(runes); ri += 1) { const r = runes[ri]: u32; // Print as 4 characters min to match UnicodeData.txt formatting - fmt::printfln("{:04x}", r)!; + fmt::printfln("{:04X}", r)!; }; }; }; diff --git a/test-cmd/unicode.t b/test-cmd/unicode.t @@ -12,24 +12,24 @@ BA $ ./cmd/unicode 30-50 - 0 0030 1 0031 2 0032 3 0033 4 0034 5 0035 6 0036 7 0037 8 0038 9 0039 : 003a ; 003b < 003c = 003d > 003e ? 003f @ 0040 A 0041 B 0042 C 0043 D 0044 E 0045 F 0046 G 0047 H 0048 I 0049 J 004a K 004b L 004c M 004d N 004e O 004f P 0050 + 0 0030 1 0031 2 0032 3 0033 4 0034 5 0035 6 0036 7 0037 8 0038 9 0039 : 003A ; 003B < 003C = 003D > 003E ? 003F @ 0040 A 0041 B 0042 C 0043 D 0044 E 0045 F 0046 G 0047 H 0048 I 0049 J 004A K 004B L 004C M 004D N 004E O 004F P 0050 $ ./cmd/unicode -n foo 0066 - 006f - 006f + 006F + 006F $ ./cmd/unicode -t 03b3 03b5 03b9 03b1 γεια (no-eol) $ ./cmd/unicode 2200-22f1 - ∀ 2200 ∁ 2201 ∂ 2202 ∃ 2203 ∄ 2204 ∅ 2205 ∆ 2206 ∇ 2207 ∈ 2208 ∉ 2209 ∊ 220a ∋ 220b ∌ 220c ∍ 220d ∎ 220e ∏ 220f ∐ 2210 ∑ 2211 − 2212 ∓ 2213 ∔ 2214 ∕ 2215 ∖ 2216 ∗ 2217 ∘ 2218 ∙ 2219 √ 221a ∛ 221b ∜ 221c ∝ 221d ∞ 221e ∟ 221f ∠ 2220 ∡ 2221 ∢ 2222 ∣ 2223 ∤ 2224 ∥ 2225 ∦ 2226 ∧ 2227 ∨ 2228 ∩ 2229 ∪ 222a ∫ 222b ∬ 222c ∭ 222d ∮ 222e ∯ 222f ∰ 2230 ∱ 2231 ∲ 2232 ∳ 2233 ∴ 2234 ∵ 2235 ∶ 2236 ∷ 2237 ∸ 2238 ∹ 2239 ∺ 223a ∻ 223b ∼ 223c ∽ 223d ∾ 223e ∿ 223f ≀ 2240 ≁ 2241 ≂ 2242 ≃ 2243 ≄ 2244 ≅ 2245 ≆ 2246 ≇ 2247 ≈ 2248 ≉ 2249 ≊ 224a ≋ 224b ≌ 224c ≍ 224d ≎ 224e ≏ 224f ≐ 2250 ≑ 2251 ≒ 2252 ≓ 2253 ≔ 2254 ≕ 2255 ≖ 2256 ≗ 2257 ≘ 2258 ≙ 2259 ≚ 225a ≛ 225b ≜ 225c ≝ 225d ≞ 225e ≟ 225f ≠ 2260 ≡ 2261 ≢ 2262 ≣ 2263 ≤ 2264 ≥ 2265 ≦ 2266 ≧ 2267 ≨ 2268 ≩ 2269 ≪ 226a ≫ 226b ≬ 226c ≭ 226d ≮ 226e ≯ 226f ≰ 2270 ≱ 2271 ≲ 2272 ≳ 2273 ≴ 2274 ≵ 2275 ≶ 2276 ≷ 2277 ≸ 2278 ≹ 2279 ≺ 227a ≻ 227b ≼ 227c ≽ 227d ≾ 227e ≿ 227f ⊀ 2280 ⊁ 2281 ⊂ 2282 ⊃ 2283 ⊄ 2284 ⊅ 2285 ⊆ 2286 ⊇ 2287 ⊈ 2288 ⊉ 2289 ⊊ 228a ⊋ 228b ⊌ 228c ⊍ 228d ⊎ 228e ⊏ 228f ⊐ 2290 ⊑ 2291 ⊒ 2292 ⊓ 2293 ⊔ 2294 ⊕ 2295 ⊖ 2296 ⊗ 2297 ⊘ 2298 ⊙ 2299 ⊚ 229a ⊛ 229b ⊜ 229c ⊝ 229d ⊞ 229e ⊟ 229f ⊠ 22a0 ⊡ 22a1 ⊢ 22a2 ⊣ 22a3 ⊤ 22a4 ⊥ 22a5 ⊦ 22a6 ⊧ 22a7 ⊨ 22a8 ⊩ 22a9 ⊪ 22aa ⊫ 22ab ⊬ 22ac ⊭ 22ad ⊮ 22ae ⊯ 22af ⊰ 22b0 ⊱ 22b1 ⊲ 22b2 ⊳ 22b3 ⊴ 22b4 ⊵ 22b5 ⊶ 22b6 ⊷ 22b7 ⊸ 22b8 ⊹ 22b9 ⊺ 22ba ⊻ 22bb ⊼ 22bc ⊽ 22bd ⊾ 22be ⊿ 22bf ⋀ 22c0 ⋁ 22c1 ⋂ 22c2 ⋃ 22c3 ⋄ 22c4 ⋅ 22c5 ⋆ 22c6 ⋇ 22c7 ⋈ 22c8 ⋉ 22c9 ⋊ 22ca ⋋ 22cb ⋌ 22cc ⋍ 22cd ⋎ 22ce ⋏ 22cf ⋐ 22d0 ⋑ 22d1 ⋒ 22d2 ⋓ 22d3 ⋔ 22d4 ⋕ 22d5 ⋖ 22d6 ⋗ 22d7 ⋘ 22d8 ⋙ 22d9 ⋚ 22da ⋛ 22db ⋜ 22dc ⋝ 22dd ⋞ 22de ⋟ 22df ⋠ 22e0 ⋡ 22e1 ⋢ 22e2 ⋣ 22e3 ⋤ 22e4 ⋥ 22e5 ⋦ 22e6 ⋧ 22e7 ⋨ 22e8 ⋩ 22e9 ⋪ 22ea ⋫ 22eb ⋬ 22ec ⋭ 22ed ⋮ 22ee ⋯ 22ef ⋰ 22f0 ⋱ 22f1 + ∀ 2200 ∁ 2201 ∂ 2202 ∃ 2203 ∄ 2204 ∅ 2205 ∆ 2206 ∇ 2207 ∈ 2208 ∉ 2209 ∊ 220A ∋ 220B ∌ 220C ∍ 220D ∎ 220E ∏ 220F ∐ 2210 ∑ 2211 − 2212 ∓ 2213 ∔ 2214 ∕ 2215 ∖ 2216 ∗ 2217 ∘ 2218 ∙ 2219 √ 221A ∛ 221B ∜ 221C ∝ 221D ∞ 221E ∟ 221F ∠ 2220 ∡ 2221 ∢ 2222 ∣ 2223 ∤ 2224 ∥ 2225 ∦ 2226 ∧ 2227 ∨ 2228 ∩ 2229 ∪ 222A ∫ 222B ∬ 222C ∭ 222D ∮ 222E ∯ 222F ∰ 2230 ∱ 2231 ∲ 2232 ∳ 2233 ∴ 2234 ∵ 2235 ∶ 2236 ∷ 2237 ∸ 2238 ∹ 2239 ∺ 223A ∻ 223B ∼ 223C ∽ 223D ∾ 223E ∿ 223F ≀ 2240 ≁ 2241 ≂ 2242 ≃ 2243 ≄ 2244 ≅ 2245 ≆ 2246 ≇ 2247 ≈ 2248 ≉ 2249 ≊ 224A ≋ 224B ≌ 224C ≍ 224D ≎ 224E ≏ 224F ≐ 2250 ≑ 2251 ≒ 2252 ≓ 2253 ≔ 2254 ≕ 2255 ≖ 2256 ≗ 2257 ≘ 2258 ≙ 2259 ≚ 225A ≛ 225B ≜ 225C ≝ 225D ≞ 225E ≟ 225F ≠ 2260 ≡ 2261 ≢ 2262 ≣ 2263 ≤ 2264 ≥ 2265 ≦ 2266 ≧ 2267 ≨ 2268 ≩ 2269 ≪ 226A ≫ 226B ≬ 226C ≭ 226D ≮ 226E ≯ 226F ≰ 2270 ≱ 2271 ≲ 2272 ≳ 2273 ≴ 2274 ≵ 2275 ≶ 2276 ≷ 2277 ≸ 2278 ≹ 2279 ≺ 227A ≻ 227B ≼ 227C ≽ 227D ≾ 227E ≿ 227F ⊀ 2280 ⊁ 2281 ⊂ 2282 ⊃ 2283 ⊄ 2284 ⊅ 2285 ⊆ 2286 ⊇ 2287 ⊈ 2288 ⊉ 2289 ⊊ 228A ⊋ 228B ⊌ 228C ⊍ 228D ⊎ 228E ⊏ 228F ⊐ 2290 ⊑ 2291 ⊒ 2292 ⊓ 2293 ⊔ 2294 ⊕ 2295 ⊖ 2296 ⊗ 2297 ⊘ 2298 ⊙ 2299 ⊚ 229A ⊛ 229B ⊜ 229C ⊝ 229D ⊞ 229E ⊟ 229F ⊠ 22A0 ⊡ 22A1 ⊢ 22A2 ⊣ 22A3 ⊤ 22A4 ⊥ 22A5 ⊦ 22A6 ⊧ 22A7 ⊨ 22A8 ⊩ 22A9 ⊪ 22AA ⊫ 22AB ⊬ 22AC ⊭ 22AD ⊮ 22AE ⊯ 22AF ⊰ 22B0 ⊱ 22B1 ⊲ 22B2 ⊳ 22B3 ⊴ 22B4 ⊵ 22B5 ⊶ 22B6 ⊷ 22B7 ⊸ 22B8 ⊹ 22B9 ⊺ 22BA ⊻ 22BB ⊼ 22BC ⊽ 22BD ⊾ 22BE ⊿ 22BF ⋀ 22C0 ⋁ 22C1 ⋂ 22C2 ⋃ 22C3 ⋄ 22C4 ⋅ 22C5 ⋆ 22C6 ⋇ 22C7 ⋈ 22C8 ⋉ 22C9 ⋊ 22CA ⋋ 22CB ⋌ 22CC ⋍ 22CD ⋎ 22CE ⋏ 22CF ⋐ 22D0 ⋑ 22D1 ⋒ 22D2 ⋓ 22D3 ⋔ 22D4 ⋕ 22D5 ⋖ 22D6 ⋗ 22D7 ⋘ 22D8 ⋙ 22D9 ⋚ 22DA ⋛ 22DB ⋜ 22DC ⋝ 22DD ⋞ 22DE ⋟ 22DF ⋠ 22E0 ⋡ 22E1 ⋢ 22E2 ⋣ 22E3 ⋤ 22E4 ⋥ 22E5 ⋦ 22E6 ⋧ 22E7 ⋨ 22E8 ⋩ 22E9 ⋪ 22EA ⋫ 22EB ⋬ 22EC ⋭ 22ED ⋮ 22EE ⋯ 22EF ⋰ 22F0 ⋱ 22F1 $ ./cmd/unicode -n γεια - 03b3 - 03b5 - 03b9 - 03b1 + 03B3 + 03B5 + 03B9 + 03B1 $ ./cmd/unicode -n 𐀀 10000