diff options
author | v1gnesh <v1gnesh@users.noreply.github.com> | 2024-08-04 15:18:38 +0530 |
---|---|---|
committer | v1gnesh <v1gnesh@users.noreply.github.com> | 2024-08-04 15:18:38 +0530 |
commit | 120cf29adf23d453cc5adee2788d283a5e9f2ea5 (patch) | |
tree | b5c9eff1374cc33da27423536915829be470cee0 | |
parent | d2cc025c6fac021f54529774d31c2f109d910fba (diff) |
Add codepage 1047 for EBCDIC
-rw-r--r-- | src/colors.rs | 34 | ||||
-rw-r--r-- | src/lib.rs | 5 | ||||
-rw-r--r-- | tests/integration_tests.rs | 54 |
3 files changed, 93 insertions, 0 deletions
diff --git a/src/colors.rs b/src/colors.rs index 748e6fb..b76e641 100644 --- a/src/colors.rs +++ b/src/colors.rs @@ -46,3 +46,37 @@ pub const CP437: [char; 256] = [ 'α','ß','Γ','π','Σ','σ','µ','τ','Φ','Θ','Ω','δ','∞','φ','ε','∩', '≡','±','≥','≤','⌠','⌡','÷','≈','°','∙','·','√','ⁿ','²','■','ff', ]; + +#[rustfmt::skip] +pub const CP1047: [char; 256] = [ + // + // Copyright (c) 2016,2024 IBM Corporation and other Contributors. + // + // All rights reserved. This program and the accompanying materials + // are made available under the terms of the Eclipse Public License v1.0 + // which accompanies this distribution, and is available at + // http://www.eclipse.org/legal/epl-v10.html + // + // Contributors: + // Mark Taylor - Initial Contribution + // + + // ref1 https://github.com/ibm-messaging/mq-smf-csv/blob/master/src/smfConv.c + // ref2 https://web.archive.org/web/20150607033635/http://www-01.ibm.com/software/globalization/cp/cp01047.html + '.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.', + '.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.', + '.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.', + '.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.', + ' ','.','.','.','.','.','.','.','.','.','$','.','<','(','+','|', + '&','.','.','.','.','.','.','.','.','.','!','$','*',')',';','.', + '-','/','.','.','.','.','.','.','.','.','.',',','%','_','>','?', + '.','.','.','.','.','.','.','.','.','.',':','#','@','\'','=','.', + '.','a','b','c','d','e','f','g','h','i','.','{','.','(','+','.', + '.','j','k','l','m','n','o','p','q','r','.','}','.',')','.','.', + '.','~','s','t','u','v','w','x','y','z','.','.','.','.','.','.', + '.','.','.','.','.','.','.','.','.','.','[',']','.','.','.','-', + '{','A','B','C','D','E','F','G','H','I','.','.','.','.','.','.', + '}','J','K','L','M','N','O','P','Q','R','.','.','.','.','.','.', + '.','.','S','T','U','V','W','X','Y','Z','.','.','.','.','.','.', + '0','1','2','3','4','5','6','7','8','9','.','.','.','.','.','.' +]; @@ -36,6 +36,10 @@ pub enum CharacterTable { /// Show printable ASCII as-is, ' ' for space, '.' for everything else. Ascii, + /// Show printable EBCDIC as-is, ' ' for space, '.' for everything else. + #[value(name = "codepage-1047")] + CP1047, + /// Uses code page 437 (for non-ASCII bytes). #[value(name = "codepage-437")] CP437, @@ -107,6 +111,7 @@ impl Byte { AsciiOther => '.', NonAscii => '.', }, + CharacterTable::CP1047 => CP1047[self.0 as usize], CharacterTable::CP437 => CP437[self.0 as usize], } } diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 1115528..a586319 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -730,4 +730,58 @@ mod character_table { ", ); } + + #[test] + fn codepage_1047() { + hexyl() + .arg("hello_world_elf64") + .arg("--color=never") + .arg("--character-table=codepage-1047") + .assert() + .success() + .pretty_stdout( + "┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐ +│00000000│ 7f 45 4c 46 02 01 01 00 ┊ 00 00 00 00 00 00 00 00 │..<.....┊........│ +│00000010│ 02 00 3e 00 01 00 00 00 ┊ 00 10 40 00 00 00 00 00 │........┊.. .....│ +│00000020│ 40 00 00 00 00 00 00 00 ┊ 28 20 00 00 00 00 00 00 │ .......┊........│ +│00000030│ 00 00 00 00 40 00 38 00 ┊ 03 00 40 00 04 00 03 00 │.... ...┊.. .....│ +│00000040│ 01 00 00 00 04 00 00 00 ┊ 00 00 00 00 00 00 00 00 │........┊........│ +│00000050│ 00 00 40 00 00 00 00 00 ┊ 00 00 40 00 00 00 00 00 │.. .....┊.. .....│ +│00000060│ e8 00 00 00 00 00 00 00 ┊ e8 00 00 00 00 00 00 00 │Y.......┊Y.......│ +│00000070│ 00 10 00 00 00 00 00 00 ┊ 01 00 00 00 05 00 00 00 │........┊........│ +│00000080│ 00 10 00 00 00 00 00 00 ┊ 00 10 40 00 00 00 00 00 │........┊.. .....│ +│00000090│ 00 10 40 00 00 00 00 00 ┊ 1d 00 00 00 00 00 00 00 │.. .....┊........│ +│000000a0│ 1d 00 00 00 00 00 00 00 ┊ 00 10 00 00 00 00 00 00 │........┊........│ +│000000b0│ 01 00 00 00 06 00 00 00 ┊ 00 20 00 00 00 00 00 00 │........┊........│ +│000000c0│ 00 20 40 00 00 00 00 00 ┊ 00 20 40 00 00 00 00 00 │.. .....┊.. .....│ +│000000d0│ 0e 00 00 00 00 00 00 00 ┊ 0e 00 00 00 00 00 00 00 │........┊........│ +│000000e0│ 00 10 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 │........┊........│ +│000000f0│ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 │........┊........│ +│* │ ┊ │ ┊ │ +│00001000│ ba 0e 00 00 00 b9 00 20 ┊ 40 00 bb 01 00 00 00 b8 │[.......┊ .].....│ +│00001010│ 04 00 00 00 cd 80 b8 01 ┊ 00 00 00 cd 80 00 00 00 │........┊........│ +│00001020│ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 │........┊........│ +│* │ ┊ │ ┊ │ +│00002000│ 48 65 6c 6c 6f 2c 20 77 ┊ 6f 72 6c 64 21 0a 00 2e │..%%?...┊?.%.....│ +│00002010│ 73 68 73 74 72 74 61 62 ┊ 00 2e 74 65 78 74 00 2e │....../.┊........│ +│00002020│ 64 61 74 61 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 │././....┊........│ +│00002030│ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 │........┊........│ +│* │ ┊ │ ┊ │ +│00002060│ 00 00 00 00 00 00 00 00 ┊ 0b 00 00 00 01 00 00 00 │........┊........│ +│00002070│ 06 00 00 00 00 00 00 00 ┊ 00 10 40 00 00 00 00 00 │........┊.. .....│ +│00002080│ 00 10 00 00 00 00 00 00 ┊ 1d 00 00 00 00 00 00 00 │........┊........│ +│00002090│ 00 00 00 00 00 00 00 00 ┊ 10 00 00 00 00 00 00 00 │........┊........│ +│000020a0│ 00 00 00 00 00 00 00 00 ┊ 11 00 00 00 01 00 00 00 │........┊........│ +│000020b0│ 03 00 00 00 00 00 00 00 ┊ 00 20 40 00 00 00 00 00 │........┊.. .....│ +│000020c0│ 00 20 00 00 00 00 00 00 ┊ 0e 00 00 00 00 00 00 00 │........┊........│ +│000020d0│ 00 00 00 00 00 00 00 00 ┊ 04 00 00 00 00 00 00 00 │........┊........│ +│000020e0│ 00 00 00 00 00 00 00 00 ┊ 01 00 00 00 03 00 00 00 │........┊........│ +│000020f0│ 00 00 00 00 00 00 00 00 ┊ 00 00 00 00 00 00 00 00 │........┊........│ +│00002100│ 0e 20 00 00 00 00 00 00 ┊ 17 00 00 00 00 00 00 00 │........┊........│ +│00002110│ 00 00 00 00 00 00 00 00 ┊ 01 00 00 00 00 00 00 00 │........┊........│ +│00002120│ 00 00 00 00 00 00 00 00 ┊ │........┊ │ +└────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘ +", + ); + } } |