File: README.md

package info (click to toggle)
ruby-unicode-blocks 1.11.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144 kB
  • sloc: ruby: 90; makefile: 4
file content (410 lines) | stat: -rw-r--r-- 8,119 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
# Unicode::Blocks [![[version]](https://badge.fury.io/rb/unicode-blocks.svg)](https://badge.fury.io/rb/unicode-blocks)  [![[ci]](https://github.com/janlelis/unicode-blocks/workflows/Test/badge.svg)](https://github.com/janlelis/unicode-blocks/actions?query=workflow%3ATest)

Each Unicode character belongs to a [block](https://en.wikipedia.org/wiki/Unicode_block). This gem returns the all blocks associated with the given string.

Unicode version: **17.0.0** (September 2025)

## Gemfile

```ruby
gem "unicode-blocks"
```

## Usage

```ruby
require "unicode/blocks"

# All blocks of a string
Unicode::Blocks.blocks("Abc") # => ["Basic Latin"]
Unicode::Blocks.blocks("СC") # => ["Cyrillic", "Basic Latin"]
Unicode::Blocks.blocks("⧉⪥⟤") # => ["Miscellaneous Mathematical Symbols-A",
                                    "Miscellaneous Mathematical Symbols-B",
                                    "Supplemental Mathematical Operators"]

# Also aliased as .of
Unicode::Blocks.of("🃉🂹") # => ["Playing Cards"]
Unicode::Blocks.of("\u{10c50}") # => ["No_Block"]

# Single character
Unicode::Blocks.block("☼") # => "Miscellaneous Symbols"
```

The list of blocks is always sorted alphabetically.

## Hints

### Regex Matching

If you have a string and want to match a substring/character from a specific Unicode block, you actually won't need this gem. Instead, you can use the [Regexp Unicode Property Syntax `\p{}`](https://ruby-doc.org/core/Regexp.html#class-Regexp-label-Character+Properties) with blocks by prefixing the block name with "In":

```ruby
"⧉⪥⟤".scan(/\p{In Miscellaneous Mathematical Symbols-B}/) # => ["⧉"]
```

See [Idiosyncratic Ruby: Proper Unicoding](https://idiosyncratic-ruby.com/41-proper-unicoding.html) for more info.

### Block Names

You can retrieve all block names (except for **No_Block**) like this:

```ruby
require "unicode/blocks"
puts Unicode::Blocks.names

# # # Output # # #

Basic Latin
Latin-1 Supplement
Latin Extended-A
Latin Extended-B
IPA Extensions
Spacing Modifier Letters
Combining Diacritical Marks
Greek and Coptic
Cyrillic
Cyrillic Supplement
Armenian
Hebrew
Arabic
Syriac
Arabic Supplement
Thaana
NKo
Samaritan
Mandaic
Syriac Supplement
Arabic Extended-B
Arabic Extended-A
Devanagari
Bengali
Gurmukhi
Gujarati
Oriya
Tamil
Telugu
Kannada
Malayalam
Sinhala
Thai
Lao
Tibetan
Myanmar
Georgian
Hangul Jamo
Ethiopic
Ethiopic Supplement
Cherokee
Unified Canadian Aboriginal Syllabics
Ogham
Runic
Tagalog
Hanunoo
Buhid
Tagbanwa
Khmer
Mongolian
Unified Canadian Aboriginal Syllabics Extended
Limbu
Tai Le
New Tai Lue
Khmer Symbols
Buginese
Tai Tham
Combining Diacritical Marks Extended
Balinese
Sundanese
Batak
Lepcha
Ol Chiki
Cyrillic Extended-C
Georgian Extended
Sundanese Supplement
Vedic Extensions
Phonetic Extensions
Phonetic Extensions Supplement
Combining Diacritical Marks Supplement
Latin Extended Additional
Greek Extended
General Punctuation
Superscripts and Subscripts
Currency Symbols
Combining Diacritical Marks for Symbols
Letterlike Symbols
Number Forms
Arrows
Mathematical Operators
Miscellaneous Technical
Control Pictures
Optical Character Recognition
Enclosed Alphanumerics
Box Drawing
Block Elements
Geometric Shapes
Miscellaneous Symbols
Dingbats
Miscellaneous Mathematical Symbols-A
Supplemental Arrows-A
Braille Patterns
Supplemental Arrows-B
Miscellaneous Mathematical Symbols-B
Supplemental Mathematical Operators
Miscellaneous Symbols and Arrows
Glagolitic
Latin Extended-C
Coptic
Georgian Supplement
Tifinagh
Ethiopic Extended
Cyrillic Extended-A
Supplemental Punctuation
CJK Radicals Supplement
Kangxi Radicals
Ideographic Description Characters
CJK Symbols and Punctuation
Hiragana
Katakana
Bopomofo
Hangul Compatibility Jamo
Kanbun
Bopomofo Extended
CJK Strokes
Katakana Phonetic Extensions
Enclosed CJK Letters and Months
CJK Compatibility
CJK Unified Ideographs Extension A
Yijing Hexagram Symbols
CJK Unified Ideographs
Yi Syllables
Yi Radicals
Lisu
Vai
Cyrillic Extended-B
Bamum
Modifier Tone Letters
Latin Extended-D
Syloti Nagri
Common Indic Number Forms
Phags-pa
Saurashtra
Devanagari Extended
Kayah Li
Rejang
Hangul Jamo Extended-A
Javanese
Myanmar Extended-B
Cham
Myanmar Extended-A
Tai Viet
Meetei Mayek Extensions
Ethiopic Extended-A
Latin Extended-E
Cherokee Supplement
Meetei Mayek
Hangul Syllables
Hangul Jamo Extended-B
High Surrogates
High Private Use Surrogates
Low Surrogates
Private Use Area
CJK Compatibility Ideographs
Alphabetic Presentation Forms
Arabic Presentation Forms-A
Variation Selectors
Vertical Forms
Combining Half Marks
CJK Compatibility Forms
Small Form Variants
Arabic Presentation Forms-B
Halfwidth and Fullwidth Forms
Specials
Linear B Syllabary
Linear B Ideograms
Aegean Numbers
Ancient Greek Numbers
Ancient Symbols
Phaistos Disc
Lycian
Carian
Coptic Epact Numbers
Old Italic
Gothic
Old Permic
Ugaritic
Old Persian
Deseret
Shavian
Osmanya
Osage
Elbasan
Caucasian Albanian
Vithkuqi
Todhri
Linear A
Latin Extended-F
Cypriot Syllabary
Imperial Aramaic
Palmyrene
Nabataean
Hatran
Phoenician
Lydian
Sidetic
Meroitic Hieroglyphs
Meroitic Cursive
Kharoshthi
Old South Arabian
Old North Arabian
Manichaean
Avestan
Inscriptional Parthian
Inscriptional Pahlavi
Psalter Pahlavi
Old Turkic
Old Hungarian
Hanifi Rohingya
Garay
Rumi Numeral Symbols
Yezidi
Arabic Extended-C
Old Sogdian
Sogdian
Old Uyghur
Chorasmian
Elymaic
Brahmi
Kaithi
Sora Sompeng
Chakma
Mahajani
Sharada
Sinhala Archaic Numbers
Khojki
Multani
Khudawadi
Grantha
Tulu-Tigalari
Newa
Tirhuta
Siddham
Modi
Mongolian Supplement
Takri
Myanmar Extended-C
Ahom
Dogra
Warang Citi
Dives Akuru
Nandinagari
Zanabazar Square
Soyombo
Unified Canadian Aboriginal Syllabics Extended-A
Pau Cin Hau
Devanagari Extended-A
Sharada Supplement
Sunuwar
Bhaiksuki
Marchen
Masaram Gondi
Gunjala Gondi
Tolong Siki
Makasar
Kawi
Lisu Supplement
Tamil Supplement
Cuneiform
Cuneiform Numbers and Punctuation
Early Dynastic Cuneiform
Cypro-Minoan
Egyptian Hieroglyphs
Egyptian Hieroglyph Format Controls
Egyptian Hieroglyphs Extended-A
Anatolian Hieroglyphs
Gurung Khema
Bamum Supplement
Mro
Tangsa
Bassa Vah
Pahawh Hmong
Kirat Rai
Medefaidrin
Beria Erfe
Miao
Ideographic Symbols and Punctuation
Tangut
Tangut Components
Khitan Small Script
Tangut Supplement
Tangut Components Supplement
Kana Extended-B
Kana Supplement
Kana Extended-A
Small Kana Extension
Nushu
Duployan
Shorthand Format Controls
Symbols for Legacy Computing Supplement
Miscellaneous Symbols Supplement
Znamenny Musical Notation
Byzantine Musical Symbols
Musical Symbols
Ancient Greek Musical Notation
Kaktovik Numerals
Mayan Numerals
Tai Xuan Jing Symbols
Counting Rod Numerals
Mathematical Alphanumeric Symbols
Sutton SignWriting
Latin Extended-G
Glagolitic Supplement
Cyrillic Extended-D
Nyiakeng Puachue Hmong
Toto
Wancho
Nag Mundari
Ol Onal
Tai Yo
Ethiopic Extended-B
Mende Kikakui
Adlam
Indic Siyaq Numbers
Ottoman Siyaq Numbers
Arabic Mathematical Alphabetic Symbols
Mahjong Tiles
Domino Tiles
Playing Cards
Enclosed Alphanumeric Supplement
Enclosed Ideographic Supplement
Miscellaneous Symbols and Pictographs
Emoticons
Ornamental Dingbats
Transport and Map Symbols
Alchemical Symbols
Geometric Shapes Extended
Supplemental Arrows-C
Supplemental Symbols and Pictographs
Chess Symbols
Symbols and Pictographs Extended-A
Symbols for Legacy Computing
CJK Unified Ideographs Extension B
CJK Unified Ideographs Extension C
CJK Unified Ideographs Extension D
CJK Unified Ideographs Extension E
CJK Unified Ideographs Extension F
CJK Unified Ideographs Extension I
CJK Compatibility Ideographs Supplement
CJK Unified Ideographs Extension G
CJK Unified Ideographs Extension H
CJK Unified Ideographs Extension J
Tags
Variation Selectors Supplement
Supplementary Private Use Area-A
Supplementary Private Use Area-B
```

See [unicode-x](https://github.com/janlelis/unicode-x) for more Unicode related micro libraries and [unicode-block.js](https://www.npmjs.com/package/unicode-block) for a JavaScript version of this library.

## MIT License

- Copyright (C) 2016-2025 Jan Lelis <https://janlelis.com>. Released under the MIT license.
- Unicode data: https://www.unicode.org/copyright.html#Exhibit1