Skip to content

Commit ffd00be

Browse files
committed
Hardcode Ronin::Support::Binary::Unhexdump::Parser::VISIBLE_CHARS.
* This helps workaround a bug in `chars` on Ruby 4.0.0. * This has the added benefit of improving load times.
1 parent a1d0bba commit ffd00be

File tree

1 file changed

+96
-3
lines changed

1 file changed

+96
-3
lines changed

lib/ronin/support/binary/unhexdump/parser.rb

Lines changed: 96 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
require 'ronin/support/binary/ctypes'
2020

21-
require 'chars'
22-
2321
module Ronin
2422
module Support
2523
module Binary
@@ -46,7 +44,102 @@ class Parser
4644
)
4745

4846
# Visible characters
49-
VISIBLE_CHARS = Chars::VISIBLE.chars.sort.zip(Chars::VISIBLE.bytes.sort).to_h
47+
VISIBLE_CHARS = {
48+
"!" => 33,
49+
"\"" => 34,
50+
"#" => 35,
51+
"$" => 36,
52+
"%" => 37,
53+
"&" => 38,
54+
"'" => 39,
55+
"(" => 40,
56+
")" => 41,
57+
"*" => 42,
58+
"+" => 43,
59+
"," => 44,
60+
"-" => 45,
61+
"." => 46,
62+
"/" => 47,
63+
"0" => 48,
64+
"1" => 49,
65+
"2" => 50,
66+
"3" => 51,
67+
"4" => 52,
68+
"5" => 53,
69+
"6" => 54,
70+
"7" => 55,
71+
"8" => 56,
72+
"9" => 57,
73+
":" => 58,
74+
";" => 59,
75+
"<" => 60,
76+
"=" => 61,
77+
">" => 62,
78+
"?" => 63,
79+
"@" => 64,
80+
"A" => 65,
81+
"B" => 66,
82+
"C" => 67,
83+
"D" => 68,
84+
"E" => 69,
85+
"F" => 70,
86+
"G" => 71,
87+
"H" => 72,
88+
"I" => 73,
89+
"J" => 74,
90+
"K" => 75,
91+
"L" => 76,
92+
"M" => 77,
93+
"N" => 78,
94+
"O" => 79,
95+
"P" => 80,
96+
"Q" => 81,
97+
"R" => 82,
98+
"S" => 83,
99+
"T" => 84,
100+
"U" => 85,
101+
"V" => 86,
102+
"W" => 87,
103+
"X" => 88,
104+
"Y" => 89,
105+
"Z" => 90,
106+
"[" => 91,
107+
"\\" => 92,
108+
"]" => 93,
109+
"^" => 94,
110+
"_" => 95,
111+
"`" => 96,
112+
"a" => 97,
113+
"b" => 98,
114+
"c" => 99,
115+
"d" => 100,
116+
"e" => 101,
117+
"f" => 102,
118+
"g" => 103,
119+
"h" => 104,
120+
"i" => 105,
121+
"j" => 106,
122+
"k" => 107,
123+
"l" => 108,
124+
"m" => 109,
125+
"n" => 110,
126+
"o" => 111,
127+
"p" => 112,
128+
"q" => 113,
129+
"r" => 114,
130+
"s" => 115,
131+
"t" => 116,
132+
"u" => 117,
133+
"v" => 118,
134+
"w" => 119,
135+
"x" => 120,
136+
"y" => 121,
137+
"z" => 122,
138+
"{" => 123,
139+
"|" => 124,
140+
"}" => 125,
141+
"~" => 126
142+
}
50143

51144
# Escaped characters
52145
CHARS = {

0 commit comments

Comments
 (0)