unibits 2.14.0 → 2.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +81 -48
- data/MIT-LICENSE.txt +1 -1
- data/README.md +1 -1
- data/lib/unibits/version.rb +2 -2
- data/lib/unibits.rb +12 -12
- data/spec/unibits_spec.rb +126 -126
- data/unibits.gemspec +4 -5
- metadata +13 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f13d6cebd3ec81dde3e3b51f626dba2646eba8ac45eb6745a1cca1bcf9304d0a
|
|
4
|
+
data.tar.gz: 1d6198da7f612a3b7d9e7647d1f3c10711dd56deabfb93fd5bc2023e14c8a88b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2b3b26ccb580637f9ad29396c60eec470a31e84714a5426743bf013e81a1fdb7b8052ef3e6db756b3eea976473354c734f7bd4c857415f0129b29a4ccd152f61
|
|
7
|
+
data.tar.gz: 2d37b405bba0143fa2e2d2920706ca986a3e6cea40bc805638a6ab9176edc15343953034829e2ea9e2a243181048b34893a6fd654b9279593fb5fe159e11cec5
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,83 +1,116 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
unibits (2.
|
|
5
|
-
characteristics (~> 1.
|
|
4
|
+
unibits (2.15.0)
|
|
5
|
+
characteristics (~> 1.9)
|
|
6
6
|
paint (>= 0.9, < 3.0)
|
|
7
7
|
rationalist (~> 2.0, >= 2.0.1)
|
|
8
8
|
symbolify (~> 1.4)
|
|
9
|
-
unicode-display_width (~>
|
|
9
|
+
unicode-display_width (~> 3.3)
|
|
10
10
|
|
|
11
11
|
GEM
|
|
12
12
|
remote: https://rubygems.org/
|
|
13
13
|
specs:
|
|
14
|
-
cd (1.0.
|
|
15
|
-
characteristics (1.
|
|
16
|
-
unicode-categories (~> 1.
|
|
17
|
-
clipboard (
|
|
18
|
-
code (0.9.
|
|
14
|
+
cd (1.0.2)
|
|
15
|
+
characteristics (1.9.0)
|
|
16
|
+
unicode-categories (~> 1.12)
|
|
17
|
+
clipboard (2.0.0)
|
|
18
|
+
code (0.9.5)
|
|
19
19
|
coderay (~> 1.1)
|
|
20
20
|
method_source (>= 0.9, < 2.0)
|
|
21
|
-
coderay (1.1.
|
|
22
|
-
core_docs (0.9.
|
|
21
|
+
coderay (1.1.3)
|
|
22
|
+
core_docs (0.9.13)
|
|
23
23
|
yard (~> 0.9.11)
|
|
24
|
-
debugging (2.1.
|
|
24
|
+
debugging (2.1.1)
|
|
25
25
|
paint (>= 0.9, < 3.0)
|
|
26
|
-
|
|
26
|
+
drb (2.2.3)
|
|
27
|
+
erb (6.0.7)
|
|
28
|
+
erb (6.0.7-java)
|
|
29
|
+
every_day_irb (2.3.0)
|
|
27
30
|
cd (~> 1.0)
|
|
28
|
-
|
|
31
|
+
irb
|
|
32
|
+
fancy_irb (2.1.3)
|
|
33
|
+
irb (>= 1.7, < 2.0)
|
|
29
34
|
paint (>= 0.9, < 3.0)
|
|
30
|
-
unicode-display_width (>=
|
|
31
|
-
ffi (1.
|
|
32
|
-
ffi (1.
|
|
35
|
+
unicode-display_width (>= 2.5)
|
|
36
|
+
ffi (1.17.4)
|
|
37
|
+
ffi (1.17.4-java)
|
|
33
38
|
hirb (0.7.3)
|
|
34
|
-
interactive_editor (0.0.
|
|
35
|
-
spoon (
|
|
36
|
-
io-console (0.
|
|
37
|
-
io-console (0.
|
|
38
|
-
irb (1.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
interactive_editor (0.0.12)
|
|
40
|
+
spoon (~> 0.0.6)
|
|
41
|
+
io-console (0.9.4)
|
|
42
|
+
io-console (0.9.4-java)
|
|
43
|
+
irb (1.18.0)
|
|
44
|
+
pp (>= 0.6.0)
|
|
45
|
+
prism (>= 1.3.0)
|
|
46
|
+
rdoc (>= 4.0.0)
|
|
47
|
+
reline (>= 0.4.2)
|
|
48
|
+
irbtools (4.2.0)
|
|
49
|
+
clipboard (>= 1.4, < 3.0)
|
|
50
|
+
code (>= 0.9.5, < 2.0)
|
|
43
51
|
coderay (~> 1.1)
|
|
44
|
-
core_docs (~> 0.9.
|
|
52
|
+
core_docs (~> 0.9.13)
|
|
45
53
|
debugging (~> 2.1)
|
|
46
|
-
every_day_irb (~> 2.
|
|
47
|
-
fancy_irb (~> 1
|
|
54
|
+
every_day_irb (~> 2.3)
|
|
55
|
+
fancy_irb (~> 2.1, >= 2.1.3)
|
|
48
56
|
hirb (~> 0.7, >= 0.7.3)
|
|
49
|
-
interactive_editor (~> 0.0, >= 0.0.
|
|
50
|
-
irb (~> 1.
|
|
51
|
-
looksee (
|
|
57
|
+
interactive_editor (~> 0.0, >= 0.0.12)
|
|
58
|
+
irb (~> 1.16)
|
|
59
|
+
looksee (>= 5.0, < 7.0)
|
|
52
60
|
methodfinder (~> 2.2, >= 2.2.5)
|
|
53
|
-
object_shadow (~> 1.1)
|
|
61
|
+
object_shadow (~> 1.1, >= 1.1.2)
|
|
54
62
|
os (~> 1.1, >= 1.1.4)
|
|
55
63
|
paint (>= 0.9, < 3.0)
|
|
56
64
|
ruby_engine (~> 2.0)
|
|
57
65
|
ruby_version (~> 1.0)
|
|
58
|
-
wirb (~>
|
|
59
|
-
|
|
66
|
+
wirb (~> 3.0)
|
|
67
|
+
jar-dependencies (0.6.0-java)
|
|
68
|
+
logger (1.7.0)
|
|
69
|
+
looksee (5.1.0)
|
|
60
70
|
method_source (1.1.0)
|
|
61
|
-
methodfinder (2.
|
|
62
|
-
minitest (
|
|
63
|
-
|
|
71
|
+
methodfinder (2.3.0)
|
|
72
|
+
minitest (6.0.6)
|
|
73
|
+
drb (~> 2.0)
|
|
74
|
+
prism (~> 1.5)
|
|
75
|
+
object_shadow (1.1.2)
|
|
64
76
|
os (1.1.4)
|
|
65
|
-
paint (2.
|
|
66
|
-
|
|
77
|
+
paint (2.3.0)
|
|
78
|
+
pp (0.6.4)
|
|
79
|
+
prettyprint
|
|
80
|
+
prettyprint (0.2.0)
|
|
81
|
+
prism (1.9.0)
|
|
82
|
+
rake (13.4.2)
|
|
67
83
|
rationalist (2.0.1)
|
|
68
|
-
|
|
84
|
+
rbs (4.2.0)
|
|
85
|
+
logger
|
|
86
|
+
prism (>= 1.6.0)
|
|
87
|
+
tsort
|
|
88
|
+
rbs (4.2.0-java)
|
|
89
|
+
jar-dependencies (>= 0.1.7)
|
|
90
|
+
logger
|
|
91
|
+
prism (>= 1.6.0)
|
|
92
|
+
tsort
|
|
93
|
+
rdoc (8.0.0)
|
|
94
|
+
erb
|
|
95
|
+
prism (>= 1.6.0)
|
|
96
|
+
rbs (>= 4.0.0)
|
|
97
|
+
tsort
|
|
98
|
+
reline (0.7.0)
|
|
69
99
|
io-console (~> 0.5)
|
|
70
100
|
ruby_engine (2.0.3)
|
|
71
|
-
ruby_version (1.0.
|
|
101
|
+
ruby_version (1.0.3)
|
|
72
102
|
spoon (0.0.6)
|
|
73
103
|
ffi
|
|
74
|
-
symbolify (1.4.
|
|
104
|
+
symbolify (1.4.2)
|
|
75
105
|
characteristics (>= 0.8, < 2.0)
|
|
76
|
-
|
|
77
|
-
unicode-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
106
|
+
tsort (0.2.0)
|
|
107
|
+
unicode-categories (1.12.0)
|
|
108
|
+
unicode-display_width (3.3.0)
|
|
109
|
+
unicode-emoji (~> 4.3)
|
|
110
|
+
unicode-emoji (4.3.0)
|
|
111
|
+
wirb (3.0.0)
|
|
112
|
+
paint (>= 0.9, < 4.0)
|
|
113
|
+
yard (0.9.45)
|
|
81
114
|
|
|
82
115
|
PLATFORMS
|
|
83
116
|
java
|
|
@@ -90,4 +123,4 @@ DEPENDENCIES
|
|
|
90
123
|
unibits!
|
|
91
124
|
|
|
92
125
|
BUNDLED WITH
|
|
93
|
-
|
|
126
|
+
4.1.0.beta1
|
data/MIT-LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -130,4 +130,4 @@ Related gems
|
|
|
130
130
|
|
|
131
131
|
Lots of thanks to @damienklinnert for the motivation and inspiration required to build this! 🎆
|
|
132
132
|
|
|
133
|
-
Copyright (C) 2017-
|
|
133
|
+
Copyright (C) 2017-2026 Jan Lelis <https://janlelis.com>. Released under the MIT license.
|
data/lib/unibits/version.rb
CHANGED
data/lib/unibits.rb
CHANGED
|
@@ -214,7 +214,7 @@ module Unibits
|
|
|
214
214
|
end
|
|
215
215
|
end
|
|
216
216
|
|
|
217
|
-
cp_buffer[-1]
|
|
217
|
+
cp_buffer[-1] += Paint[ codepoint.ljust(10), current_color, :bold ]
|
|
218
218
|
|
|
219
219
|
symbolified_char = Symbolify.symbolify(char, char_info)
|
|
220
220
|
|
|
@@ -224,17 +224,17 @@ module Unibits
|
|
|
224
224
|
padding = 10 - symbolified_char.size
|
|
225
225
|
end
|
|
226
226
|
|
|
227
|
-
enc_buffer[-1]
|
|
228
|
-
enc_buffer[-1]
|
|
227
|
+
enc_buffer[-1] += Paint[ symbolified_char, current_color ]
|
|
228
|
+
enc_buffer[-1] += " " * padding if padding > 0
|
|
229
229
|
else
|
|
230
|
-
cp_buffer[-1]
|
|
231
|
-
enc_buffer[-1]
|
|
230
|
+
cp_buffer[-1] += " " * 10
|
|
231
|
+
enc_buffer[-1] += " " * 10
|
|
232
232
|
end
|
|
233
233
|
|
|
234
|
-
hex_buffer[-1]
|
|
234
|
+
hex_buffer[-1] += Paint[ ("%02X" % byte).ljust(10, " "), current_color ]
|
|
235
235
|
|
|
236
|
-
bin_buffer[-1]
|
|
237
|
-
bin_buffer[-1]
|
|
236
|
+
bin_buffer[-1] += highlight_bits(byte, char, char_info, current_color, byteindex)
|
|
237
|
+
bin_buffer[-1] += " "
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
|
|
@@ -328,10 +328,10 @@ module Unibits
|
|
|
328
328
|
end
|
|
329
329
|
end
|
|
330
330
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
331
|
+
[
|
|
332
|
+
( Paint[ bin_byte_1, current_color ] unless !bin_byte_1 || bin_byte_1.empty? ),
|
|
333
|
+
( Paint[ bin_byte_2, current_color, :underline ] unless !bin_byte_2 || bin_byte_2.empty? ),
|
|
334
|
+
].compact.join
|
|
335
335
|
end
|
|
336
336
|
|
|
337
337
|
def self.double_check_utf32_validness!(char, char_info)
|
data/spec/unibits_spec.rb
CHANGED
|
@@ -3,9 +3,9 @@ require "minitest/autorun"
|
|
|
3
3
|
|
|
4
4
|
describe Unibits do
|
|
5
5
|
it "will not work for unsupported encodings" do
|
|
6
|
-
proc{
|
|
6
|
+
_(proc{
|
|
7
7
|
Unibits.of("string".encode("UTF-32"))
|
|
8
|
-
}.must_raise ArgumentError
|
|
8
|
+
}).must_raise ArgumentError
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
describe 'Encodings' do
|
|
@@ -13,202 +13,202 @@ describe Unibits do
|
|
|
13
13
|
|
|
14
14
|
it "works with UTF-8" do
|
|
15
15
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
16
|
-
result.must_match "ℜ"
|
|
17
|
-
result.must_match "U+211C"
|
|
18
|
-
result.must_match /E2.*84.*9C/m
|
|
19
|
-
result.must_match /11100010.*10000100.*10011100/m
|
|
16
|
+
_(result).must_match "ℜ"
|
|
17
|
+
_(result).must_match "U+211C"
|
|
18
|
+
_(result).must_match /E2.*84.*9C/m
|
|
19
|
+
_(result).must_match /11100010.*10000100.*10011100/m
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "works with UTF-16LE" do
|
|
23
23
|
result = Paint.unpaint(Unibits.visualize(string.encode('UTF-16LE')))
|
|
24
|
-
result.must_match "ℜ"
|
|
25
|
-
result.must_match "U+211C"
|
|
26
|
-
result.must_match /1C.*21/m
|
|
27
|
-
result.must_match /00011100.*00100001/m
|
|
24
|
+
_(result).must_match "ℜ"
|
|
25
|
+
_(result).must_match "U+211C"
|
|
26
|
+
_(result).must_match /1C.*21/m
|
|
27
|
+
_(result).must_match /00011100.*00100001/m
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it "works with UTF-16BE" do
|
|
31
31
|
result = Paint.unpaint(Unibits.visualize(string.encode('UTF-16BE')))
|
|
32
|
-
result.must_match "ℜ"
|
|
33
|
-
result.must_match "U+211C"
|
|
34
|
-
result.must_match /21.*1C/m
|
|
35
|
-
result.must_match /00100001.*00011100/m
|
|
32
|
+
_(result).must_match "ℜ"
|
|
33
|
+
_(result).must_match "U+211C"
|
|
34
|
+
_(result).must_match /21.*1C/m
|
|
35
|
+
_(result).must_match /00100001.*00011100/m
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
it "works with UTF-32LE" do
|
|
39
39
|
result = Paint.unpaint(Unibits.visualize(string.encode('UTF-32LE')))
|
|
40
|
-
result.must_match "ℜ"
|
|
41
|
-
result.must_match "U+211C"
|
|
42
|
-
result.must_match /1C.*21.*00.*00/m
|
|
43
|
-
result.must_match /00011100.*00100001.*00000000.*00000000/m
|
|
40
|
+
_(result).must_match "ℜ"
|
|
41
|
+
_(result).must_match "U+211C"
|
|
42
|
+
_(result).must_match /1C.*21.*00.*00/m
|
|
43
|
+
_(result).must_match /00011100.*00100001.*00000000.*00000000/m
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
it "works with UTF-32BE" do
|
|
47
47
|
result = Paint.unpaint(Unibits.visualize(string.encode('UTF-32BE')))
|
|
48
|
-
result.must_match "ℜ"
|
|
49
|
-
result.must_match "U+211C"
|
|
50
|
-
result.must_match /00.*00.*21.*1C/m
|
|
51
|
-
result.must_match /00000000.*00000000.*00100001.*00011100/m
|
|
48
|
+
_(result).must_match "ℜ"
|
|
49
|
+
_(result).must_match "U+211C"
|
|
50
|
+
_(result).must_match /00.*00.*21.*1C/m
|
|
51
|
+
_(result).must_match /00000000.*00000000.*00100001.*00011100/m
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
it "works with BINARY" do
|
|
55
55
|
result = Paint.unpaint(Unibits.visualize(string.dup.force_encoding('BINARY')))
|
|
56
56
|
# testing for the UTF-8 encoded "ℜ"
|
|
57
|
-
result.must_match "\\xE2"
|
|
58
|
-
result.must_match "\\x84"
|
|
59
|
-
result.must_match "\\x9C"
|
|
60
|
-
result.must_match /11100010.*10000100.*10011100/m
|
|
57
|
+
_(result).must_match "\\xE2"
|
|
58
|
+
_(result).must_match "\\x84"
|
|
59
|
+
_(result).must_match "\\x9C"
|
|
60
|
+
_(result).must_match /11100010.*10000100.*10011100/m
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
it "works with ASCII" do
|
|
64
|
-
result = Paint.unpaint(Unibits.visualize("ASCII string".force_encoding('ASCII')))
|
|
65
|
-
result.must_match "C"
|
|
66
|
-
result.must_match "43"
|
|
67
|
-
result.must_match "01000011"
|
|
64
|
+
result = Paint.unpaint(Unibits.visualize("ASCII string".dup.force_encoding('ASCII')))
|
|
65
|
+
_(result).must_match "C"
|
|
66
|
+
_(result).must_match "43"
|
|
67
|
+
_(result).must_match "01000011"
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
it "works with GB1988" do
|
|
71
|
-
result = Paint.unpaint(Unibits.visualize("ASCII string".force_encoding('GB1988')))
|
|
72
|
-
result.must_match "C"
|
|
73
|
-
result.must_match "43"
|
|
74
|
-
result.must_match "01000011"
|
|
71
|
+
result = Paint.unpaint(Unibits.visualize("ASCII string".dup.force_encoding('GB1988')))
|
|
72
|
+
_(result).must_match "C"
|
|
73
|
+
_(result).must_match "43"
|
|
74
|
+
_(result).must_match "01000011"
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
it "works with 'ISO-8859-X' encodings" do
|
|
78
|
-
string = "\xBC Idiosyncr\xE4tic\n\x91".force_encoding("ISO-8859-1")
|
|
78
|
+
string = "\xBC Idiosyncr\xE4tic\n\x91".dup.force_encoding("ISO-8859-1")
|
|
79
79
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
80
|
-
result.must_match "BC" # ¼
|
|
81
|
-
result.must_match "E4" # ä
|
|
82
|
-
result.must_match "␊" # \n
|
|
83
|
-
result.must_match "PU1" # C1 name for \x91
|
|
80
|
+
_(result).must_match "BC" # ¼
|
|
81
|
+
_(result).must_match "E4" # ä
|
|
82
|
+
_(result).must_match "␊" # \n
|
|
83
|
+
_(result).must_match "PU1" # C1 name for \x91
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
it "works with 'Windows-125X' encodings" do
|
|
87
|
-
string = "\xBC Idiosyncr\xE4tic\n\x81".force_encoding("Windows-1252")
|
|
87
|
+
string = "\xBC Idiosyncr\xE4tic\n\x81".dup.force_encoding("Windows-1252")
|
|
88
88
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
89
|
-
result.must_match "BC" # ¼
|
|
90
|
-
result.must_match "E4" # ä
|
|
91
|
-
result.must_match "␊" # \n
|
|
92
|
-
result.must_match "n/a" # \x81 is not assigned
|
|
89
|
+
_(result).must_match "BC" # ¼
|
|
90
|
+
_(result).must_match "E4" # ä
|
|
91
|
+
_(result).must_match "␊" # \n
|
|
92
|
+
_(result).must_match "n/a" # \x81 is not assigned
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
it "works with 'IBMX' encodings" do
|
|
96
|
-
string = "\xFE Idiosyncr\x84tic\n".force_encoding("IBM437")
|
|
96
|
+
string = "\xFE Idiosyncr\x84tic\n".dup.force_encoding("IBM437")
|
|
97
97
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
98
|
-
result.must_match "FE" # ■
|
|
99
|
-
result.must_match "84" # ä
|
|
100
|
-
result.must_match "␊" # \n
|
|
98
|
+
_(result).must_match "FE" # ■
|
|
99
|
+
_(result).must_match "84" # ä
|
|
100
|
+
_(result).must_match "␊" # \n
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
it "works with 'CP85X' encodings" do
|
|
104
|
-
string = "\xFE Idiosyncr\x84tic\n".force_encoding("CP850")
|
|
104
|
+
string = "\xFE Idiosyncr\x84tic\n".dup.force_encoding("CP850")
|
|
105
105
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
106
|
-
result.must_match "FE" # ■
|
|
107
|
-
result.must_match "84" # ä
|
|
108
|
-
result.must_match "␊" # \n
|
|
106
|
+
_(result).must_match "FE" # ■
|
|
107
|
+
_(result).must_match "84" # ä
|
|
108
|
+
_(result).must_match "␊" # \n
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
it "works with 'macX' encodings" do
|
|
112
|
-
string = "\xBD Idiosyncr\x8Atic \x11 \xF0\n".force_encoding("macRoman")
|
|
112
|
+
string = "\xBD Idiosyncr\x8Atic \x11 \xF0\n".dup.force_encoding("macRoman")
|
|
113
113
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
114
|
-
result.must_match "BD" # Ω
|
|
115
|
-
result.must_match "8A" # ä
|
|
116
|
-
result.must_match "Logo" # \xF0
|
|
117
|
-
result.must_match "⌘" # \x11
|
|
118
|
-
result.must_match "␊" # \n
|
|
114
|
+
_(result).must_match "BD" # Ω
|
|
115
|
+
_(result).must_match "8A" # ä
|
|
116
|
+
_(result).must_match "Logo" # \xF0
|
|
117
|
+
_(result).must_match "⌘" # \x11
|
|
118
|
+
_(result).must_match "␊" # \n
|
|
119
119
|
end
|
|
120
120
|
|
|
121
121
|
it "works with 'TIS-620/Windows-874' encodings" do
|
|
122
|
-
string = "\xA4 Idiosyncratic\n".force_encoding("TIS-620")
|
|
122
|
+
string = "\xA4 Idiosyncratic\n".dup.force_encoding("TIS-620")
|
|
123
123
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
124
|
-
result.must_match "A4" # ค
|
|
125
|
-
result.must_match "␊" # \n
|
|
124
|
+
_(result).must_match "A4" # ค
|
|
125
|
+
_(result).must_match "␊" # \n
|
|
126
126
|
end
|
|
127
127
|
|
|
128
128
|
it "works with 'KOI8-X' encodings" do
|
|
129
|
-
string = "\xE9\xE4\xE9\xEF\xF3\xF9\xEE\xE3\xF2\xE1\xF4\xE9\xE3\n".force_encoding("KOI8-R")
|
|
129
|
+
string = "\xE9\xE4\xE9\xEF\xF3\xF9\xEE\xE3\xF2\xE1\xF4\xE9\xE3\n".dup.force_encoding("KOI8-R")
|
|
130
130
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
131
|
-
result.must_match "F9" # Ы
|
|
132
|
-
result.must_match "␊" # \n
|
|
131
|
+
_(result).must_match "F9" # Ы
|
|
132
|
+
_(result).must_match "␊" # \n
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
describe "invalid UTF-8 encodings" do
|
|
136
136
|
it "- unexpected continuation byte (1/2)" do
|
|
137
137
|
string = "abc\x80efg"
|
|
138
138
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
139
|
-
result.must_match "�"
|
|
140
|
-
result.must_match "unexp.c."
|
|
141
|
-
result.must_match /e.*f.*g/m
|
|
139
|
+
_(result).must_match "�"
|
|
140
|
+
_(result).must_match "unexp.c."
|
|
141
|
+
_(result).must_match /e.*f.*g/m
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
it "- unexpected continuation byte (2/2)" do
|
|
145
145
|
string = "🌫\x81efg"
|
|
146
146
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
147
|
-
result.must_match "�"
|
|
148
|
-
result.must_match "unexp.c."
|
|
149
|
-
result.must_match /e.*f.*g/m
|
|
147
|
+
_(result).must_match "�"
|
|
148
|
+
_(result).must_match "unexp.c."
|
|
149
|
+
_(result).must_match /e.*f.*g/m
|
|
150
150
|
end
|
|
151
151
|
|
|
152
152
|
it "- not enough continuation bytes" do
|
|
153
153
|
string = "\xF0\x9F\x8CABC"
|
|
154
154
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
155
|
-
result.must_match "�"
|
|
156
|
-
result.must_match "n.e.con."
|
|
157
|
-
result.must_match /A.*B.*C/m
|
|
155
|
+
_(result).must_match "�"
|
|
156
|
+
_(result).must_match "n.e.con."
|
|
157
|
+
_(result).must_match /A.*B.*C/m
|
|
158
158
|
end
|
|
159
159
|
|
|
160
160
|
it "- overlong padding (1/2)" do
|
|
161
161
|
string = "\xE0\x81\x81ABC"
|
|
162
162
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
163
|
-
result.must_match "�"
|
|
164
|
-
result.must_match /overlong.*overlong.*overlong/m
|
|
165
|
-
result.must_match /A.*B.*C/m
|
|
163
|
+
_(result).must_match "�"
|
|
164
|
+
_(result).must_match /overlong.*overlong.*overlong/m
|
|
165
|
+
_(result).must_match /A.*B.*C/m
|
|
166
166
|
end
|
|
167
167
|
|
|
168
168
|
it "- overlong padding (2/2)" do
|
|
169
169
|
string = "\xC0\x80no double null"
|
|
170
170
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
171
|
-
result.must_match "�"
|
|
172
|
-
result.must_match /overlong.*overlong/m
|
|
171
|
+
_(result).must_match "�"
|
|
172
|
+
_(result).must_match /overlong.*overlong/m
|
|
173
173
|
end
|
|
174
174
|
|
|
175
175
|
it "- too large codepoint (1/2)" do
|
|
176
176
|
string = "\xF5\x8F\xBF\xBFABC"
|
|
177
177
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
178
|
-
result.must_match "�"
|
|
179
|
-
result.must_match /toolarge.*toolarge.*toolarge.*toolarge/m
|
|
180
|
-
result.must_match /A.*B.*C/m
|
|
178
|
+
_(result).must_match "�"
|
|
179
|
+
_(result).must_match /toolarge.*toolarge.*toolarge.*toolarge/m
|
|
180
|
+
_(result).must_match /A.*B.*C/m
|
|
181
181
|
end
|
|
182
182
|
|
|
183
183
|
it "- too large codepoint (2/2)" do
|
|
184
184
|
string = "\xF4\xAF\xBF\xBFABC"
|
|
185
185
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
186
|
-
result.must_match "�"
|
|
187
|
-
result.must_match /toolarge.*toolarge.*toolarge.*toolarge/m
|
|
188
|
-
result.must_match /A.*B.*C/m
|
|
186
|
+
_(result).must_match "�"
|
|
187
|
+
_(result).must_match /toolarge.*toolarge.*toolarge.*toolarge/m
|
|
188
|
+
_(result).must_match /A.*B.*C/m
|
|
189
189
|
end
|
|
190
190
|
|
|
191
191
|
it "- too large byte" do
|
|
192
192
|
string = "\xFF"
|
|
193
193
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
194
|
-
result.must_match "�"
|
|
195
|
-
result.must_match "toolarge"
|
|
194
|
+
_(result).must_match "�"
|
|
195
|
+
_(result).must_match "toolarge"
|
|
196
196
|
end
|
|
197
197
|
|
|
198
198
|
it "- has surrogate (1/2)" do
|
|
199
199
|
string = "\xED\xA0\x80ABC"
|
|
200
200
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
201
|
-
result.must_match "�"
|
|
202
|
-
result.must_match "sur.gate"
|
|
203
|
-
result.must_match /A.*B.*C/m
|
|
201
|
+
_(result).must_match "�"
|
|
202
|
+
_(result).must_match "sur.gate"
|
|
203
|
+
_(result).must_match /A.*B.*C/m
|
|
204
204
|
end
|
|
205
205
|
|
|
206
206
|
it "- has surrogate (2/2)" do
|
|
207
207
|
string = "\xED\xBF\xBFABC"
|
|
208
208
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
209
|
-
result.must_match "�"
|
|
210
|
-
result.must_match "sur.gate"
|
|
211
|
-
result.must_match /A.*B.*C/m
|
|
209
|
+
_(result).must_match "�"
|
|
210
|
+
_(result).must_match "sur.gate"
|
|
211
|
+
_(result).must_match /A.*B.*C/m
|
|
212
212
|
end
|
|
213
213
|
end
|
|
214
214
|
|
|
@@ -217,29 +217,29 @@ describe Unibits do
|
|
|
217
217
|
it "- incomplete number of bytes (1/2)" do
|
|
218
218
|
string = "a".b.force_encoding("UTF-16LE")
|
|
219
219
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
220
|
-
result.must_match "incompl."
|
|
221
|
-
result.must_match "�"
|
|
220
|
+
_(result).must_match "incompl."
|
|
221
|
+
_(result).must_match "�"
|
|
222
222
|
end
|
|
223
223
|
|
|
224
224
|
it "- incomplete number of bytes (2/2)" do
|
|
225
|
-
string = "🌫".b[0..-2].force_encoding("UTF-16LE")
|
|
225
|
+
string = "🌫".b[0..-2].dup.force_encoding("UTF-16LE")
|
|
226
226
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
227
|
-
result.must_match "incompl."
|
|
228
|
-
result.must_match "�"
|
|
227
|
+
_(result).must_match "incompl."
|
|
228
|
+
_(result).must_match "�"
|
|
229
229
|
end
|
|
230
230
|
end
|
|
231
231
|
it "- only lower half surrogate" do
|
|
232
|
-
string = "\x3C\xD8\x2Ba".force_encoding("UTF-16LE")
|
|
232
|
+
string = "\x3C\xD8\x2Ba".dup.force_encoding("UTF-16LE")
|
|
233
233
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
234
|
-
result.must_match "hlf.srg."
|
|
235
|
-
result.must_match "�"
|
|
234
|
+
_(result).must_match "hlf.srg."
|
|
235
|
+
_(result).must_match "�"
|
|
236
236
|
end
|
|
237
237
|
|
|
238
238
|
it "- only higher half surrogate" do
|
|
239
|
-
string = "\x3Ca\x2B\xDF".force_encoding("UTF-16LE")
|
|
239
|
+
string = "\x3Ca\x2B\xDF".dup.force_encoding("UTF-16LE")
|
|
240
240
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
241
|
-
result.must_match "hlf.srg."
|
|
242
|
-
result.must_match "�"
|
|
241
|
+
_(result).must_match "hlf.srg."
|
|
242
|
+
_(result).must_match "�"
|
|
243
243
|
end
|
|
244
244
|
end
|
|
245
245
|
|
|
@@ -250,53 +250,53 @@ describe Unibits do
|
|
|
250
250
|
it "- incomplete number of bytes (1/3)" do
|
|
251
251
|
string = "a".b.force_encoding("UTF-32LE")
|
|
252
252
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
253
|
-
result.must_match "incompl."
|
|
254
|
-
result.must_match "�"
|
|
253
|
+
_(result).must_match "incompl."
|
|
254
|
+
_(result).must_match "�"
|
|
255
255
|
end
|
|
256
256
|
|
|
257
257
|
it "- incomplete number of bytes (2/3)" do
|
|
258
258
|
string = "🌫".b[0..-2].force_encoding("UTF-32LE")
|
|
259
259
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
260
|
-
result.must_match "incompl."
|
|
261
|
-
result.must_match "�"
|
|
260
|
+
_(result).must_match "incompl."
|
|
261
|
+
_(result).must_match "�"
|
|
262
262
|
end
|
|
263
263
|
|
|
264
264
|
it "- incomplete number of bytes (3/3)" do
|
|
265
265
|
string = "🌫".b[0..-2].force_encoding("UTF-32LE")
|
|
266
266
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
267
|
-
result.must_match "incompl."
|
|
268
|
-
result.must_match "�"
|
|
267
|
+
_(result).must_match "incompl."
|
|
268
|
+
_(result).must_match "�"
|
|
269
269
|
end
|
|
270
270
|
end
|
|
271
271
|
|
|
272
272
|
it "- too large codepoint (1/2)" do
|
|
273
|
-
string = "\x00\x00\x11\x00".force_encoding("UTF-32LE")
|
|
273
|
+
string = "\x00\x00\x11\x00".dup.force_encoding("UTF-32LE")
|
|
274
274
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
275
|
-
result.must_match "�"
|
|
276
|
-
result.must_match "toolarge"
|
|
275
|
+
_(result).must_match "�"
|
|
276
|
+
_(result).must_match "toolarge"
|
|
277
277
|
end
|
|
278
278
|
|
|
279
279
|
it "- too large codepoint (2/2)" do
|
|
280
|
-
string = "\x00\x00\x00\x01".force_encoding("UTF-32LE")
|
|
280
|
+
string = "\x00\x00\x00\x01".dup.force_encoding("UTF-32LE")
|
|
281
281
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
282
|
-
result.must_match "�"
|
|
283
|
-
result.must_match "toolarge"
|
|
282
|
+
_(result).must_match "�"
|
|
283
|
+
_(result).must_match "toolarge"
|
|
284
284
|
end
|
|
285
285
|
|
|
286
286
|
it "- has surrogate" do
|
|
287
|
-
string = "\x00\xD8\x00\x00".force_encoding("UTF-32LE")
|
|
287
|
+
string = "\x00\xD8\x00\x00".dup.force_encoding("UTF-32LE")
|
|
288
288
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
289
|
-
result.must_match "�"
|
|
290
|
-
result.must_match "sur.gate"
|
|
289
|
+
_(result).must_match "�"
|
|
290
|
+
_(result).must_match "sur.gate"
|
|
291
291
|
end
|
|
292
292
|
end
|
|
293
293
|
|
|
294
294
|
describe "invalid ASCII encodings" do
|
|
295
295
|
it "- contains bytes with 8th bit set" do
|
|
296
|
-
string = "abc\x80efg".force_encoding("ASCII")
|
|
296
|
+
string = "abc\x80efg".dup.force_encoding("ASCII")
|
|
297
297
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
298
|
-
result.must_match "�"
|
|
299
|
-
result.must_match /e.*f.*g/m
|
|
298
|
+
_(result).must_match "�"
|
|
299
|
+
_(result).must_match /e.*f.*g/m
|
|
300
300
|
end
|
|
301
301
|
end
|
|
302
302
|
end
|
|
@@ -305,13 +305,13 @@ describe Unibits do
|
|
|
305
305
|
it "- default is 1" do
|
|
306
306
|
string = "⚀······"
|
|
307
307
|
result = Unibits.stats(string)
|
|
308
|
-
result.wont_match "13"
|
|
308
|
+
_(result).wont_match "13"
|
|
309
309
|
end
|
|
310
310
|
|
|
311
311
|
it "- default is 2" do
|
|
312
312
|
string = "⚀······"
|
|
313
313
|
result = Unibits.stats(string, wide_ambiguous: true)
|
|
314
|
-
result.must_match "13"
|
|
314
|
+
_(result).must_match "13"
|
|
315
315
|
end
|
|
316
316
|
end
|
|
317
317
|
|
|
@@ -319,7 +319,7 @@ describe Unibits do
|
|
|
319
319
|
it "sets a custom column width" do
|
|
320
320
|
string = "bla" * 99
|
|
321
321
|
result = Paint.unpaint(Unibits.visualize(string, width: 50))
|
|
322
|
-
(result[/^.*$/].size <= 50).must_equal true
|
|
322
|
+
_((result[/^.*$/].size <= 50)).must_equal true
|
|
323
323
|
end
|
|
324
324
|
end
|
|
325
325
|
|
|
@@ -327,8 +327,8 @@ describe Unibits do
|
|
|
327
327
|
it "should render ASCII space (U+20) as one byte [gh #1]" do
|
|
328
328
|
string = "\u{1f32b} abc"
|
|
329
329
|
result = Paint.unpaint(Unibits.visualize(string))
|
|
330
|
-
result.wont_match /20.*20.*5B/m
|
|
331
|
-
result.must_match /F0.*9F.*8C.*AB.*20.*61.*62.*63/m
|
|
330
|
+
_(result).wont_match /20.*20.*5B/m
|
|
331
|
+
_(result).must_match /F0.*9F.*8C.*AB.*20.*61.*62.*63/m
|
|
332
332
|
end
|
|
333
333
|
end
|
|
334
334
|
end
|
data/unibits.gemspec
CHANGED
|
@@ -5,8 +5,8 @@ require File.dirname(__FILE__) + "/lib/unibits/version"
|
|
|
5
5
|
Gem::Specification.new do |gem|
|
|
6
6
|
gem.name = "unibits"
|
|
7
7
|
gem.version = Unibits::VERSION
|
|
8
|
-
gem.summary = "
|
|
9
|
-
gem.description = "Visualizes encodings in the terminal. Supports UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE, US-ASCII, ASCII-8BIT, and
|
|
8
|
+
gem.summary = "[Unicode 18] CLI utility that visualizes a broad range of encodings of a string"
|
|
9
|
+
gem.description = "[Unicode 18] CLI utility that Visualizes a broad range of encodings in the terminal. Supports UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE, US-ASCII, ASCII-8BIT, and a variety of single-byte encodings."
|
|
10
10
|
gem.authors = ["Jan Lelis"]
|
|
11
11
|
gem.email = ["hi@ruby.consulting"]
|
|
12
12
|
gem.homepage = "https://github.com/janlelis/unibits"
|
|
@@ -14,14 +14,13 @@ Gem::Specification.new do |gem|
|
|
|
14
14
|
|
|
15
15
|
gem.files = Dir["{**/}{.*,*}"].select{ |path| File.file?(path) && path !~ /^(pkg|screenshots)/ }
|
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
17
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
18
17
|
gem.require_paths = ["lib"]
|
|
19
18
|
gem.metadata = { "rubygems_mfa_required" => "true" }
|
|
20
19
|
|
|
21
20
|
gem.add_dependency 'paint', '>= 0.9', '< 3.0'
|
|
22
|
-
gem.add_dependency 'unicode-display_width', '~> 3.
|
|
21
|
+
gem.add_dependency 'unicode-display_width', '~> 3.3'
|
|
23
22
|
gem.add_dependency 'symbolify', '~> 1.4'
|
|
24
|
-
gem.add_dependency 'characteristics', '~> 1.
|
|
23
|
+
gem.add_dependency 'characteristics', '~> 1.9'
|
|
25
24
|
gem.add_dependency 'rationalist', '~> 2.0', '>= 2.0.1'
|
|
26
25
|
|
|
27
26
|
gem.required_ruby_version = ">= 2.0"
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: unibits
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.15.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jan Lelis
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: paint
|
|
@@ -36,14 +35,14 @@ dependencies:
|
|
|
36
35
|
requirements:
|
|
37
36
|
- - "~>"
|
|
38
37
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '3.
|
|
38
|
+
version: '3.3'
|
|
40
39
|
type: :runtime
|
|
41
40
|
prerelease: false
|
|
42
41
|
version_requirements: !ruby/object:Gem::Requirement
|
|
43
42
|
requirements:
|
|
44
43
|
- - "~>"
|
|
45
44
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '3.
|
|
45
|
+
version: '3.3'
|
|
47
46
|
- !ruby/object:Gem::Dependency
|
|
48
47
|
name: symbolify
|
|
49
48
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -64,14 +63,14 @@ dependencies:
|
|
|
64
63
|
requirements:
|
|
65
64
|
- - "~>"
|
|
66
65
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: '1.
|
|
66
|
+
version: '1.9'
|
|
68
67
|
type: :runtime
|
|
69
68
|
prerelease: false
|
|
70
69
|
version_requirements: !ruby/object:Gem::Requirement
|
|
71
70
|
requirements:
|
|
72
71
|
- - "~>"
|
|
73
72
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: '1.
|
|
73
|
+
version: '1.9'
|
|
75
74
|
- !ruby/object:Gem::Dependency
|
|
76
75
|
name: rationalist
|
|
77
76
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -92,9 +91,9 @@ dependencies:
|
|
|
92
91
|
- - ">="
|
|
93
92
|
- !ruby/object:Gem::Version
|
|
94
93
|
version: 2.0.1
|
|
95
|
-
description:
|
|
96
|
-
UTF-
|
|
97
|
-
|
|
94
|
+
description: "[Unicode 18] CLI utility that Visualizes a broad range of encodings
|
|
95
|
+
in the terminal. Supports UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE, US-ASCII,
|
|
96
|
+
ASCII-8BIT, and a variety of single-byte encodings."
|
|
98
97
|
email:
|
|
99
98
|
- hi@ruby.consulting
|
|
100
99
|
executables:
|
|
@@ -121,7 +120,6 @@ licenses:
|
|
|
121
120
|
- MIT
|
|
122
121
|
metadata:
|
|
123
122
|
rubygems_mfa_required: 'true'
|
|
124
|
-
post_install_message:
|
|
125
123
|
rdoc_options: []
|
|
126
124
|
require_paths:
|
|
127
125
|
- lib
|
|
@@ -136,9 +134,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
136
134
|
- !ruby/object:Gem::Version
|
|
137
135
|
version: '0'
|
|
138
136
|
requirements: []
|
|
139
|
-
rubygems_version:
|
|
140
|
-
signing_key:
|
|
137
|
+
rubygems_version: 4.0.21
|
|
141
138
|
specification_version: 4
|
|
142
|
-
summary:
|
|
143
|
-
|
|
144
|
-
|
|
139
|
+
summary: "[Unicode 18] CLI utility that visualizes a broad range of encodings of a
|
|
140
|
+
string"
|
|
141
|
+
test_files: []
|