unibits 2.1.1 → 2.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62770bc741ec5a7693759d4e888d46cf7b3860f2
4
- data.tar.gz: 171c479f1f4ebdcf11bc97c4e4e0b94bac713abb
3
+ metadata.gz: ca4463dcb78d345bf7cd7b89687d618803fb9a98
4
+ data.tar.gz: c2657ec5e6e74a70183e97ae629695170c446759
5
5
  SHA512:
6
- metadata.gz: 793cdfeca34183b1b1f6cc219ddd822b9faac5542e92f1ec1065c3fd6ff07c38762becc5312d9bd29fbe3f976bd6eabb3e4c5e228bcfbe8e6340e90b5407234e
7
- data.tar.gz: 9691e9072ff3084706e5dfe1ed51b1e6c206d2b11a9eaf710a37ee7b5f1e09b15a6eb3d85e3cb4517a64ef9e5b6aa0bb6bfadee72285487a4a1d0f3f66fa32bd
6
+ metadata.gz: 62beee1710b54962120c55b8b8bec94c42cda2305c9eab4d190945a0ec1716de5b8dae9cce3c201dc352c993c60d0709f8854b436241ab020a2c3d1348087b93
7
+ data.tar.gz: 0b7c3a0446cf3b0f3cb943465753fe13db6a3b130ffc9401e426300faa4be034f85c3d7af399a3c51617322ee3622d221c1e29387e6d8297c4b53cf54f1ec60d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## CHANGELOG
2
2
 
3
+ ### 2.2.0
4
+
5
+ * Add mongolian free variation selectors and combining grapheme joiner to interesting codepoints list
6
+ * Green highlighting of "marks" in Unicode
7
+ * Always use dotted circle for non-spacing marks
8
+ * Always prepend enclosing marks with a space
9
+ * Update characteristics gem (includes new blanks and UTF-8 dialects with japanese emojis)
10
+
3
11
  ### 2.1.1
4
12
 
5
13
  * Proper UTF-32 validness / invalid codepoint highlighting, see https://bugs.ruby-lang.org/issues/13292
data/README.md CHANGED
@@ -16,6 +16,7 @@ Each byte of the given string is highlighted using the following mechanism (char
16
16
  - Blue for control characters
17
17
  - Light blue for blanks
18
18
  - Non-control formatting characters in pink
19
+ - Green for marks (Unicode only)
19
20
  - Random color for all other characters
20
21
 
21
22
  ## Setup
data/bin/unibits CHANGED
@@ -56,6 +56,7 @@ if argv[:help]
56
56
  #{Paint["control", Unibits::COLORS[:control]]}
57
57
  #{Paint["blank", Unibits::COLORS[:blank]]}
58
58
  #{Paint["format", Unibits::COLORS[:format]]}
59
+ #{Paint["mark", Unibits::COLORS[:mark]]}
59
60
 
60
61
  #{Paint["STATS", :underline]}
61
62
 
@@ -76,6 +77,12 @@ if argv[:help]
76
77
  incompl. | not enough bytes left to finish codepoint
77
78
  hlf.srg. | other half of surrogate missing
78
79
 
80
+ UTF-32
81
+
82
+ incompl. | not enough bytes left to finish codepoint
83
+ toolarge | codepoint value exceeds maximum allowed (U+10FFFF)
84
+ sur.gate | codepoint value would be a surrogate half
85
+
79
86
  #{Paint["MORE INFO", :underline]}
80
87
 
81
88
  https://github.com/janlelis/unibits
data/lib/unibits.rb CHANGED
@@ -10,6 +10,7 @@ module Unibits
10
10
  SUPPORTED_ENCODINGS = Encoding.name_list.grep(
11
11
  Regexp.union(
12
12
  /^UTF-8$/,
13
+ /^UTF8-/,
13
14
  /^UTF-...E$/,
14
15
  /^ASCII-8BIT$/,
15
16
  /^US-ASCII$/,
@@ -30,6 +31,7 @@ module Unibits
30
31
  control: "#0000FF",
31
32
  blank: "#33AADD",
32
33
  format: "#FF00FF",
34
+ mark: "#228822",
33
35
  }
34
36
 
35
37
  DEFAULT_TERMINAL_WIDTH = 80
@@ -100,7 +102,7 @@ module Unibits
100
102
  case encoding_name
101
103
  when "US-ASCII"
102
104
  codepoint = "invalid"
103
- when "UTF-8"
105
+ when "UTF-8", /^UTF8/
104
106
  # this tries to detect what is wrong with this utf-8 encoded string
105
107
  # sorry for this mess
106
108
  case char.unpack("B*")[0]
@@ -244,6 +246,8 @@ module Unibits
244
246
  COLORS[:blank]
245
247
  elsif char_info.format?
246
248
  COLORS[:format]
249
+ elsif char_info.unicode? && char_info.category[0] == "M"
250
+ COLORS[:mark]
247
251
  else
248
252
  random_color
249
253
  end
@@ -267,7 +271,7 @@ module Unibits
267
271
  when 'ASCII-8BIT'
268
272
  bin_byte_1 = ""
269
273
  bin_byte_2 = bin_byte_complete
270
- when 'UTF-8'
274
+ when 'UTF-8', /^UTF8/
271
275
  if byteindex == 0
272
276
  if bin_byte_complete =~ /^(0|1{2,4}0)([01]+)$/
273
277
  bin_byte_1 = $1
@@ -79,6 +79,10 @@ module Unibits
79
79
  }
80
80
 
81
81
  INTERESTING_CODEPOINTS = {
82
+ 0x180B => "FVS1",
83
+ 0x180C => "FVS2",
84
+ 0x180D => "FVS3",
85
+
82
86
  0x200E => "LRM",
83
87
  0x200F => "RLM",
84
88
  0x202A => "LRE",
@@ -91,6 +95,8 @@ module Unibits
91
95
  0x2068 => "FSI",
92
96
  0x2069 => "PDI",
93
97
 
98
+ 0x034F => "CGJ",
99
+
94
100
  0xFE00 => "VS1",
95
101
  0xFE01 => "VS2",
96
102
  0xFE02 => "VS3",
@@ -395,9 +401,8 @@ module Unibits
395
401
  def self.unicode(char, char_info)
396
402
  return "n/a" if !char_info.assigned?
397
403
 
398
- char = char.dup
404
+ char = char.dup.encode("UTF-8")
399
405
  ord = char.ord
400
- encoding = char_info.encoding
401
406
 
402
407
  if char_info.delete?
403
408
  char = CONTROL_DELETE_SYMBOL
@@ -406,15 +411,18 @@ module Unibits
406
411
  elsif char_info.c1?
407
412
  char = CONTROL_C1_NAMES[ord]
408
413
  elsif char_info.blank?
409
- char = "]".encode(encoding) + char + "[".encode(encoding)
414
+ char = "]" + char + "["
410
415
  elsif ord > 917536 && ord < 917631
411
- char = "TAG ".encode(encoding) +
412
- char.tr(TAGS.encode(encoding), ASCII_CHARS.encode(encoding))
416
+ char = "TAG " + char.tr(TAGS, ASCII_CHARS)
417
+ elsif char_info.category == "Mn"
418
+ char = "◌" + char
419
+ elsif char_info.category == "Me"
420
+ char = " " + char
413
421
  else
414
422
  char = INTERESTING_CODEPOINTS[char.ord] || char
415
423
  end
416
424
 
417
- char.encode("UTF-8")
425
+ char
418
426
  end
419
427
 
420
428
  def self.byte(char, char_info)
@@ -1,3 +1,3 @@
1
1
  module Unibits
2
- VERSION = "2.1.1".freeze
2
+ VERSION = "2.2.0".freeze
3
3
  end
data/unibits.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
19
19
 
20
20
  gem.add_dependency 'paint', '>= 0.9', '< 3.0'
21
21
  gem.add_dependency 'unicode-display_width', '~> 1.1'
22
- gem.add_dependency 'characteristics', '~> 0.3.0'
22
+ gem.add_dependency 'characteristics', '~> 0.4'
23
23
  gem.add_dependency 'rationalist', '~> 2.0'
24
24
 
25
25
  gem.required_ruby_version = "~> 2.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unibits
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Lelis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-19 00:00:00.000000000 Z
11
+ date: 2017-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: paint
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: 0.3.0
53
+ version: '0.4'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: 0.3.0
60
+ version: '0.4'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rationalist
63
63
  requirement: !ruby/object:Gem::Requirement