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
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
/// A number of constants to give a name to all characters in this block.
mod constants {
    /// \u{aa80}: 'ꪀ'
    pub const LETTER_LOW_KO: char = 'ꪀ';
    /// \u{aa81}: 'ꪁ'
    pub const LETTER_HIGH_KO: char = 'ꪁ';
    /// \u{aa82}: 'ꪂ'
    pub const LETTER_LOW_KHO: char = 'ꪂ';
    /// \u{aa83}: 'ꪃ'
    pub const LETTER_HIGH_KHO: char = 'ꪃ';
    /// \u{aa84}: 'ꪄ'
    pub const LETTER_LOW_KHHO: char = 'ꪄ';
    /// \u{aa85}: 'ꪅ'
    pub const LETTER_HIGH_KHHO: char = 'ꪅ';
    /// \u{aa86}: 'ꪆ'
    pub const LETTER_LOW_GO: char = 'ꪆ';
    /// \u{aa87}: 'ꪇ'
    pub const LETTER_HIGH_GO: char = 'ꪇ';
    /// \u{aa88}: 'ꪈ'
    pub const LETTER_LOW_NGO: char = 'ꪈ';
    /// \u{aa89}: 'ꪉ'
    pub const LETTER_HIGH_NGO: char = 'ꪉ';
    /// \u{aa8a}: 'ꪊ'
    pub const LETTER_LOW_CO: char = 'ꪊ';
    /// \u{aa8b}: 'ꪋ'
    pub const LETTER_HIGH_CO: char = 'ꪋ';
    /// \u{aa8c}: 'ꪌ'
    pub const LETTER_LOW_CHO: char = 'ꪌ';
    /// \u{aa8d}: 'ꪍ'
    pub const LETTER_HIGH_CHO: char = 'ꪍ';
    /// \u{aa8e}: 'ꪎ'
    pub const LETTER_LOW_SO: char = 'ꪎ';
    /// \u{aa8f}: 'ꪏ'
    pub const LETTER_HIGH_SO: char = 'ꪏ';
    /// \u{aa90}: 'ꪐ'
    pub const LETTER_LOW_NYO: char = 'ꪐ';
    /// \u{aa91}: 'ꪑ'
    pub const LETTER_HIGH_NYO: char = 'ꪑ';
    /// \u{aa92}: 'ꪒ'
    pub const LETTER_LOW_DO: char = 'ꪒ';
    /// \u{aa93}: 'ꪓ'
    pub const LETTER_HIGH_DO: char = 'ꪓ';
    /// \u{aa94}: 'ꪔ'
    pub const LETTER_LOW_TO: char = 'ꪔ';
    /// \u{aa95}: 'ꪕ'
    pub const LETTER_HIGH_TO: char = 'ꪕ';
    /// \u{aa96}: 'ꪖ'
    pub const LETTER_LOW_THO: char = 'ꪖ';
    /// \u{aa97}: 'ꪗ'
    pub const LETTER_HIGH_THO: char = 'ꪗ';
    /// \u{aa98}: 'ꪘ'
    pub const LETTER_LOW_NO: char = 'ꪘ';
    /// \u{aa99}: 'ꪙ'
    pub const LETTER_HIGH_NO: char = 'ꪙ';
    /// \u{aa9a}: 'ꪚ'
    pub const LETTER_LOW_BO: char = 'ꪚ';
    /// \u{aa9b}: 'ꪛ'
    pub const LETTER_HIGH_BO: char = 'ꪛ';
    /// \u{aa9c}: 'ꪜ'
    pub const LETTER_LOW_PO: char = 'ꪜ';
    /// \u{aa9d}: 'ꪝ'
    pub const LETTER_HIGH_PO: char = 'ꪝ';
    /// \u{aa9e}: 'ꪞ'
    pub const LETTER_LOW_PHO: char = 'ꪞ';
    /// \u{aa9f}: 'ꪟ'
    pub const LETTER_HIGH_PHO: char = 'ꪟ';
    /// \u{aaa0}: 'ꪠ'
    pub const LETTER_LOW_FO: char = 'ꪠ';
    /// \u{aaa1}: 'ꪡ'
    pub const LETTER_HIGH_FO: char = 'ꪡ';
    /// \u{aaa2}: 'ꪢ'
    pub const LETTER_LOW_MO: char = 'ꪢ';
    /// \u{aaa3}: 'ꪣ'
    pub const LETTER_HIGH_MO: char = 'ꪣ';
    /// \u{aaa4}: 'ꪤ'
    pub const LETTER_LOW_YO: char = 'ꪤ';
    /// \u{aaa5}: 'ꪥ'
    pub const LETTER_HIGH_YO: char = 'ꪥ';
    /// \u{aaa6}: 'ꪦ'
    pub const LETTER_LOW_RO: char = 'ꪦ';
    /// \u{aaa7}: 'ꪧ'
    pub const LETTER_HIGH_RO: char = 'ꪧ';
    /// \u{aaa8}: 'ꪨ'
    pub const LETTER_LOW_LO: char = 'ꪨ';
    /// \u{aaa9}: 'ꪩ'
    pub const LETTER_HIGH_LO: char = 'ꪩ';
    /// \u{aaaa}: 'ꪪ'
    pub const LETTER_LOW_VO: char = 'ꪪ';
    /// \u{aaab}: 'ꪫ'
    pub const LETTER_HIGH_VO: char = 'ꪫ';
    /// \u{aaac}: 'ꪬ'
    pub const LETTER_LOW_HO: char = 'ꪬ';
    /// \u{aaad}: 'ꪭ'
    pub const LETTER_HIGH_HO: char = 'ꪭ';
    /// \u{aaae}: 'ꪮ'
    pub const LETTER_LOW_O: char = 'ꪮ';
    /// \u{aaaf}: 'ꪯ'
    pub const LETTER_HIGH_O: char = 'ꪯ';
    /// \u{aab0}: 'ꪰ'
    pub const MAI_KANG: char = 'ꪰ';
    /// \u{aab1}: 'ꪱ'
    pub const VOWEL_AA: char = 'ꪱ';
    /// \u{aab2}: 'ꪲ'
    pub const VOWEL_I: char = 'ꪲ';
    /// \u{aab3}: 'ꪳ'
    pub const VOWEL_UE: char = 'ꪳ';
    /// \u{aab4}: 'ꪴ'
    pub const VOWEL_U: char = 'ꪴ';
    /// \u{aab5}: 'ꪵ'
    pub const VOWEL_E: char = 'ꪵ';
    /// \u{aab6}: 'ꪶ'
    pub const VOWEL_O: char = 'ꪶ';
    /// \u{aab7}: 'ꪷ'
    pub const MAI_KHIT: char = 'ꪷ';
    /// \u{aab8}: 'ꪸ'
    pub const VOWEL_IA: char = 'ꪸ';
    /// \u{aab9}: 'ꪹ'
    pub const VOWEL_UEA: char = 'ꪹ';
    /// \u{aaba}: 'ꪺ'
    pub const VOWEL_UA: char = 'ꪺ';
    /// \u{aabb}: 'ꪻ'
    pub const VOWEL_AUE: char = 'ꪻ';
    /// \u{aabc}: 'ꪼ'
    pub const VOWEL_AY: char = 'ꪼ';
    /// \u{aabd}: 'ꪽ'
    pub const VOWEL_AN: char = 'ꪽ';
    /// \u{aabe}: 'ꪾ'
    pub const VOWEL_AM: char = 'ꪾ';
    /// \u{aabf}: '꪿'
    pub const TONE_MAI_EK: char = '꪿';
    /// \u{aac0}: 'ꫀ'
    pub const TONE_MAI_NUENG: char = 'ꫀ';
    /// \u{aac1}: '꫁'
    pub const TONE_MAI_THO: char = '꫁';
    /// \u{aac2}: 'ꫂ'
    pub const TONE_MAI_SONG: char = 'ꫂ';
    /// \u{aadb}: 'ꫛ'
    pub const SYMBOL_KON: char = 'ꫛ';
    /// \u{aadc}: 'ꫜ'
    pub const SYMBOL_NUENG: char = 'ꫜ';
    /// \u{aadd}: 'ꫝ'
    pub const SYMBOL_SAM: char = 'ꫝ';
    /// \u{aade}: '꫞'
    pub const SYMBOL_HO_HOI: char = '꫞';
}

/// An enum to represent all characters in the TaiViet block.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum TaiViet {
    /// \u{aa80}: 'ꪀ'
    LetterLowKo,
    /// \u{aa81}: 'ꪁ'
    LetterHighKo,
    /// \u{aa82}: 'ꪂ'
    LetterLowKho,
    /// \u{aa83}: 'ꪃ'
    LetterHighKho,
    /// \u{aa84}: 'ꪄ'
    LetterLowKhho,
    /// \u{aa85}: 'ꪅ'
    LetterHighKhho,
    /// \u{aa86}: 'ꪆ'
    LetterLowGo,
    /// \u{aa87}: 'ꪇ'
    LetterHighGo,
    /// \u{aa88}: 'ꪈ'
    LetterLowNgo,
    /// \u{aa89}: 'ꪉ'
    LetterHighNgo,
    /// \u{aa8a}: 'ꪊ'
    LetterLowCo,
    /// \u{aa8b}: 'ꪋ'
    LetterHighCo,
    /// \u{aa8c}: 'ꪌ'
    LetterLowCho,
    /// \u{aa8d}: 'ꪍ'
    LetterHighCho,
    /// \u{aa8e}: 'ꪎ'
    LetterLowSo,
    /// \u{aa8f}: 'ꪏ'
    LetterHighSo,
    /// \u{aa90}: 'ꪐ'
    LetterLowNyo,
    /// \u{aa91}: 'ꪑ'
    LetterHighNyo,
    /// \u{aa92}: 'ꪒ'
    LetterLowDo,
    /// \u{aa93}: 'ꪓ'
    LetterHighDo,
    /// \u{aa94}: 'ꪔ'
    LetterLowTo,
    /// \u{aa95}: 'ꪕ'
    LetterHighTo,
    /// \u{aa96}: 'ꪖ'
    LetterLowTho,
    /// \u{aa97}: 'ꪗ'
    LetterHighTho,
    /// \u{aa98}: 'ꪘ'
    LetterLowNo,
    /// \u{aa99}: 'ꪙ'
    LetterHighNo,
    /// \u{aa9a}: 'ꪚ'
    LetterLowBo,
    /// \u{aa9b}: 'ꪛ'
    LetterHighBo,
    /// \u{aa9c}: 'ꪜ'
    LetterLowPo,
    /// \u{aa9d}: 'ꪝ'
    LetterHighPo,
    /// \u{aa9e}: 'ꪞ'
    LetterLowPho,
    /// \u{aa9f}: 'ꪟ'
    LetterHighPho,
    /// \u{aaa0}: 'ꪠ'
    LetterLowFo,
    /// \u{aaa1}: 'ꪡ'
    LetterHighFo,
    /// \u{aaa2}: 'ꪢ'
    LetterLowMo,
    /// \u{aaa3}: 'ꪣ'
    LetterHighMo,
    /// \u{aaa4}: 'ꪤ'
    LetterLowYo,
    /// \u{aaa5}: 'ꪥ'
    LetterHighYo,
    /// \u{aaa6}: 'ꪦ'
    LetterLowRo,
    /// \u{aaa7}: 'ꪧ'
    LetterHighRo,
    /// \u{aaa8}: 'ꪨ'
    LetterLowLo,
    /// \u{aaa9}: 'ꪩ'
    LetterHighLo,
    /// \u{aaaa}: 'ꪪ'
    LetterLowVo,
    /// \u{aaab}: 'ꪫ'
    LetterHighVo,
    /// \u{aaac}: 'ꪬ'
    LetterLowHo,
    /// \u{aaad}: 'ꪭ'
    LetterHighHo,
    /// \u{aaae}: 'ꪮ'
    LetterLowO,
    /// \u{aaaf}: 'ꪯ'
    LetterHighO,
    /// \u{aab0}: 'ꪰ'
    MaiKang,
    /// \u{aab1}: 'ꪱ'
    VowelAa,
    /// \u{aab2}: 'ꪲ'
    VowelI,
    /// \u{aab3}: 'ꪳ'
    VowelUe,
    /// \u{aab4}: 'ꪴ'
    VowelU,
    /// \u{aab5}: 'ꪵ'
    VowelE,
    /// \u{aab6}: 'ꪶ'
    VowelO,
    /// \u{aab7}: 'ꪷ'
    MaiKhit,
    /// \u{aab8}: 'ꪸ'
    VowelIa,
    /// \u{aab9}: 'ꪹ'
    VowelUea,
    /// \u{aaba}: 'ꪺ'
    VowelUa,
    /// \u{aabb}: 'ꪻ'
    VowelAue,
    /// \u{aabc}: 'ꪼ'
    VowelAy,
    /// \u{aabd}: 'ꪽ'
    VowelAn,
    /// \u{aabe}: 'ꪾ'
    VowelAm,
    /// \u{aabf}: '꪿'
    ToneMaiEk,
    /// \u{aac0}: 'ꫀ'
    ToneMaiNueng,
    /// \u{aac1}: '꫁'
    ToneMaiTho,
    /// \u{aac2}: 'ꫂ'
    ToneMaiSong,
    /// \u{aadb}: 'ꫛ'
    SymbolKon,
    /// \u{aadc}: 'ꫜ'
    SymbolNueng,
    /// \u{aadd}: 'ꫝ'
    SymbolSam,
    /// \u{aade}: '꫞'
    SymbolHoHoi,
}

impl Into<char> for TaiViet {
    fn into(self) -> char {
        use constants::*;
        match self {
            TaiViet::LetterLowKo => LETTER_LOW_KO,
            TaiViet::LetterHighKo => LETTER_HIGH_KO,
            TaiViet::LetterLowKho => LETTER_LOW_KHO,
            TaiViet::LetterHighKho => LETTER_HIGH_KHO,
            TaiViet::LetterLowKhho => LETTER_LOW_KHHO,
            TaiViet::LetterHighKhho => LETTER_HIGH_KHHO,
            TaiViet::LetterLowGo => LETTER_LOW_GO,
            TaiViet::LetterHighGo => LETTER_HIGH_GO,
            TaiViet::LetterLowNgo => LETTER_LOW_NGO,
            TaiViet::LetterHighNgo => LETTER_HIGH_NGO,
            TaiViet::LetterLowCo => LETTER_LOW_CO,
            TaiViet::LetterHighCo => LETTER_HIGH_CO,
            TaiViet::LetterLowCho => LETTER_LOW_CHO,
            TaiViet::LetterHighCho => LETTER_HIGH_CHO,
            TaiViet::LetterLowSo => LETTER_LOW_SO,
            TaiViet::LetterHighSo => LETTER_HIGH_SO,
            TaiViet::LetterLowNyo => LETTER_LOW_NYO,
            TaiViet::LetterHighNyo => LETTER_HIGH_NYO,
            TaiViet::LetterLowDo => LETTER_LOW_DO,
            TaiViet::LetterHighDo => LETTER_HIGH_DO,
            TaiViet::LetterLowTo => LETTER_LOW_TO,
            TaiViet::LetterHighTo => LETTER_HIGH_TO,
            TaiViet::LetterLowTho => LETTER_LOW_THO,
            TaiViet::LetterHighTho => LETTER_HIGH_THO,
            TaiViet::LetterLowNo => LETTER_LOW_NO,
            TaiViet::LetterHighNo => LETTER_HIGH_NO,
            TaiViet::LetterLowBo => LETTER_LOW_BO,
            TaiViet::LetterHighBo => LETTER_HIGH_BO,
            TaiViet::LetterLowPo => LETTER_LOW_PO,
            TaiViet::LetterHighPo => LETTER_HIGH_PO,
            TaiViet::LetterLowPho => LETTER_LOW_PHO,
            TaiViet::LetterHighPho => LETTER_HIGH_PHO,
            TaiViet::LetterLowFo => LETTER_LOW_FO,
            TaiViet::LetterHighFo => LETTER_HIGH_FO,
            TaiViet::LetterLowMo => LETTER_LOW_MO,
            TaiViet::LetterHighMo => LETTER_HIGH_MO,
            TaiViet::LetterLowYo => LETTER_LOW_YO,
            TaiViet::LetterHighYo => LETTER_HIGH_YO,
            TaiViet::LetterLowRo => LETTER_LOW_RO,
            TaiViet::LetterHighRo => LETTER_HIGH_RO,
            TaiViet::LetterLowLo => LETTER_LOW_LO,
            TaiViet::LetterHighLo => LETTER_HIGH_LO,
            TaiViet::LetterLowVo => LETTER_LOW_VO,
            TaiViet::LetterHighVo => LETTER_HIGH_VO,
            TaiViet::LetterLowHo => LETTER_LOW_HO,
            TaiViet::LetterHighHo => LETTER_HIGH_HO,
            TaiViet::LetterLowO => LETTER_LOW_O,
            TaiViet::LetterHighO => LETTER_HIGH_O,
            TaiViet::MaiKang => MAI_KANG,
            TaiViet::VowelAa => VOWEL_AA,
            TaiViet::VowelI => VOWEL_I,
            TaiViet::VowelUe => VOWEL_UE,
            TaiViet::VowelU => VOWEL_U,
            TaiViet::VowelE => VOWEL_E,
            TaiViet::VowelO => VOWEL_O,
            TaiViet::MaiKhit => MAI_KHIT,
            TaiViet::VowelIa => VOWEL_IA,
            TaiViet::VowelUea => VOWEL_UEA,
            TaiViet::VowelUa => VOWEL_UA,
            TaiViet::VowelAue => VOWEL_AUE,
            TaiViet::VowelAy => VOWEL_AY,
            TaiViet::VowelAn => VOWEL_AN,
            TaiViet::VowelAm => VOWEL_AM,
            TaiViet::ToneMaiEk => TONE_MAI_EK,
            TaiViet::ToneMaiNueng => TONE_MAI_NUENG,
            TaiViet::ToneMaiTho => TONE_MAI_THO,
            TaiViet::ToneMaiSong => TONE_MAI_SONG,
            TaiViet::SymbolKon => SYMBOL_KON,
            TaiViet::SymbolNueng => SYMBOL_NUENG,
            TaiViet::SymbolSam => SYMBOL_SAM,
            TaiViet::SymbolHoHoi => SYMBOL_HO_HOI,
        }
    }
}

impl std::convert::TryFrom<char> for TaiViet {
    type Error = ();
    fn try_from(c: char) -> Result<Self, Self::Error> {
        use constants::*;
        match c {
            LETTER_LOW_KO => Ok(TaiViet::LetterLowKo),
            LETTER_HIGH_KO => Ok(TaiViet::LetterHighKo),
            LETTER_LOW_KHO => Ok(TaiViet::LetterLowKho),
            LETTER_HIGH_KHO => Ok(TaiViet::LetterHighKho),
            LETTER_LOW_KHHO => Ok(TaiViet::LetterLowKhho),
            LETTER_HIGH_KHHO => Ok(TaiViet::LetterHighKhho),
            LETTER_LOW_GO => Ok(TaiViet::LetterLowGo),
            LETTER_HIGH_GO => Ok(TaiViet::LetterHighGo),
            LETTER_LOW_NGO => Ok(TaiViet::LetterLowNgo),
            LETTER_HIGH_NGO => Ok(TaiViet::LetterHighNgo),
            LETTER_LOW_CO => Ok(TaiViet::LetterLowCo),
            LETTER_HIGH_CO => Ok(TaiViet::LetterHighCo),
            LETTER_LOW_CHO => Ok(TaiViet::LetterLowCho),
            LETTER_HIGH_CHO => Ok(TaiViet::LetterHighCho),
            LETTER_LOW_SO => Ok(TaiViet::LetterLowSo),
            LETTER_HIGH_SO => Ok(TaiViet::LetterHighSo),
            LETTER_LOW_NYO => Ok(TaiViet::LetterLowNyo),
            LETTER_HIGH_NYO => Ok(TaiViet::LetterHighNyo),
            LETTER_LOW_DO => Ok(TaiViet::LetterLowDo),
            LETTER_HIGH_DO => Ok(TaiViet::LetterHighDo),
            LETTER_LOW_TO => Ok(TaiViet::LetterLowTo),
            LETTER_HIGH_TO => Ok(TaiViet::LetterHighTo),
            LETTER_LOW_THO => Ok(TaiViet::LetterLowTho),
            LETTER_HIGH_THO => Ok(TaiViet::LetterHighTho),
            LETTER_LOW_NO => Ok(TaiViet::LetterLowNo),
            LETTER_HIGH_NO => Ok(TaiViet::LetterHighNo),
            LETTER_LOW_BO => Ok(TaiViet::LetterLowBo),
            LETTER_HIGH_BO => Ok(TaiViet::LetterHighBo),
            LETTER_LOW_PO => Ok(TaiViet::LetterLowPo),
            LETTER_HIGH_PO => Ok(TaiViet::LetterHighPo),
            LETTER_LOW_PHO => Ok(TaiViet::LetterLowPho),
            LETTER_HIGH_PHO => Ok(TaiViet::LetterHighPho),
            LETTER_LOW_FO => Ok(TaiViet::LetterLowFo),
            LETTER_HIGH_FO => Ok(TaiViet::LetterHighFo),
            LETTER_LOW_MO => Ok(TaiViet::LetterLowMo),
            LETTER_HIGH_MO => Ok(TaiViet::LetterHighMo),
            LETTER_LOW_YO => Ok(TaiViet::LetterLowYo),
            LETTER_HIGH_YO => Ok(TaiViet::LetterHighYo),
            LETTER_LOW_RO => Ok(TaiViet::LetterLowRo),
            LETTER_HIGH_RO => Ok(TaiViet::LetterHighRo),
            LETTER_LOW_LO => Ok(TaiViet::LetterLowLo),
            LETTER_HIGH_LO => Ok(TaiViet::LetterHighLo),
            LETTER_LOW_VO => Ok(TaiViet::LetterLowVo),
            LETTER_HIGH_VO => Ok(TaiViet::LetterHighVo),
            LETTER_LOW_HO => Ok(TaiViet::LetterLowHo),
            LETTER_HIGH_HO => Ok(TaiViet::LetterHighHo),
            LETTER_LOW_O => Ok(TaiViet::LetterLowO),
            LETTER_HIGH_O => Ok(TaiViet::LetterHighO),
            MAI_KANG => Ok(TaiViet::MaiKang),
            VOWEL_AA => Ok(TaiViet::VowelAa),
            VOWEL_I => Ok(TaiViet::VowelI),
            VOWEL_UE => Ok(TaiViet::VowelUe),
            VOWEL_U => Ok(TaiViet::VowelU),
            VOWEL_E => Ok(TaiViet::VowelE),
            VOWEL_O => Ok(TaiViet::VowelO),
            MAI_KHIT => Ok(TaiViet::MaiKhit),
            VOWEL_IA => Ok(TaiViet::VowelIa),
            VOWEL_UEA => Ok(TaiViet::VowelUea),
            VOWEL_UA => Ok(TaiViet::VowelUa),
            VOWEL_AUE => Ok(TaiViet::VowelAue),
            VOWEL_AY => Ok(TaiViet::VowelAy),
            VOWEL_AN => Ok(TaiViet::VowelAn),
            VOWEL_AM => Ok(TaiViet::VowelAm),
            TONE_MAI_EK => Ok(TaiViet::ToneMaiEk),
            TONE_MAI_NUENG => Ok(TaiViet::ToneMaiNueng),
            TONE_MAI_THO => Ok(TaiViet::ToneMaiTho),
            TONE_MAI_SONG => Ok(TaiViet::ToneMaiSong),
            SYMBOL_KON => Ok(TaiViet::SymbolKon),
            SYMBOL_NUENG => Ok(TaiViet::SymbolNueng),
            SYMBOL_SAM => Ok(TaiViet::SymbolSam),
            SYMBOL_HO_HOI => Ok(TaiViet::SymbolHoHoi),
            _ => Err(()),
        }
    }
}

impl Into<u32> for TaiViet {
    fn into(self) -> u32 {
        let c: char = self.into();
        let hex = c
            .escape_unicode()
            .to_string()
            .replace("\\u{", "")
            .replace("}", "");
        u32::from_str_radix(&hex, 16).unwrap()
    }
}

impl std::convert::TryFrom<u32> for TaiViet {
    type Error = ();
    fn try_from(u: u32) -> Result<Self, Self::Error> {
        if let Ok(c) = char::try_from(u) {
            Self::try_from(c)
        } else {
            Err(())
        }
    }
}

impl Iterator for TaiViet {
    type Item = Self;
    fn next(&mut self) -> Option<Self> {
        let index: u32 = (*self).into();
        use std::convert::TryFrom;
        Self::try_from(index + 1).ok()
    }
}

impl TaiViet {
    /// The character with the lowest index in this unicode block
    pub fn new() -> Self {
        TaiViet::LetterLowKo
    }

    /// The character's name, all lowercase and space-separated
    pub fn name(&self) -> &str {
        match self {
            TaiViet::LetterLowKo => "tai viet letter low ko",
            TaiViet::LetterHighKo => "tai viet letter high ko",
            TaiViet::LetterLowKho => "tai viet letter low kho",
            TaiViet::LetterHighKho => "tai viet letter high kho",
            TaiViet::LetterLowKhho => "tai viet letter low khho",
            TaiViet::LetterHighKhho => "tai viet letter high khho",
            TaiViet::LetterLowGo => "tai viet letter low go",
            TaiViet::LetterHighGo => "tai viet letter high go",
            TaiViet::LetterLowNgo => "tai viet letter low ngo",
            TaiViet::LetterHighNgo => "tai viet letter high ngo",
            TaiViet::LetterLowCo => "tai viet letter low co",
            TaiViet::LetterHighCo => "tai viet letter high co",
            TaiViet::LetterLowCho => "tai viet letter low cho",
            TaiViet::LetterHighCho => "tai viet letter high cho",
            TaiViet::LetterLowSo => "tai viet letter low so",
            TaiViet::LetterHighSo => "tai viet letter high so",
            TaiViet::LetterLowNyo => "tai viet letter low nyo",
            TaiViet::LetterHighNyo => "tai viet letter high nyo",
            TaiViet::LetterLowDo => "tai viet letter low do",
            TaiViet::LetterHighDo => "tai viet letter high do",
            TaiViet::LetterLowTo => "tai viet letter low to",
            TaiViet::LetterHighTo => "tai viet letter high to",
            TaiViet::LetterLowTho => "tai viet letter low tho",
            TaiViet::LetterHighTho => "tai viet letter high tho",
            TaiViet::LetterLowNo => "tai viet letter low no",
            TaiViet::LetterHighNo => "tai viet letter high no",
            TaiViet::LetterLowBo => "tai viet letter low bo",
            TaiViet::LetterHighBo => "tai viet letter high bo",
            TaiViet::LetterLowPo => "tai viet letter low po",
            TaiViet::LetterHighPo => "tai viet letter high po",
            TaiViet::LetterLowPho => "tai viet letter low pho",
            TaiViet::LetterHighPho => "tai viet letter high pho",
            TaiViet::LetterLowFo => "tai viet letter low fo",
            TaiViet::LetterHighFo => "tai viet letter high fo",
            TaiViet::LetterLowMo => "tai viet letter low mo",
            TaiViet::LetterHighMo => "tai viet letter high mo",
            TaiViet::LetterLowYo => "tai viet letter low yo",
            TaiViet::LetterHighYo => "tai viet letter high yo",
            TaiViet::LetterLowRo => "tai viet letter low ro",
            TaiViet::LetterHighRo => "tai viet letter high ro",
            TaiViet::LetterLowLo => "tai viet letter low lo",
            TaiViet::LetterHighLo => "tai viet letter high lo",
            TaiViet::LetterLowVo => "tai viet letter low vo",
            TaiViet::LetterHighVo => "tai viet letter high vo",
            TaiViet::LetterLowHo => "tai viet letter low ho",
            TaiViet::LetterHighHo => "tai viet letter high ho",
            TaiViet::LetterLowO => "tai viet letter low o",
            TaiViet::LetterHighO => "tai viet letter high o",
            TaiViet::MaiKang => "tai viet mai kang",
            TaiViet::VowelAa => "tai viet vowel aa",
            TaiViet::VowelI => "tai viet vowel i",
            TaiViet::VowelUe => "tai viet vowel ue",
            TaiViet::VowelU => "tai viet vowel u",
            TaiViet::VowelE => "tai viet vowel e",
            TaiViet::VowelO => "tai viet vowel o",
            TaiViet::MaiKhit => "tai viet mai khit",
            TaiViet::VowelIa => "tai viet vowel ia",
            TaiViet::VowelUea => "tai viet vowel uea",
            TaiViet::VowelUa => "tai viet vowel ua",
            TaiViet::VowelAue => "tai viet vowel aue",
            TaiViet::VowelAy => "tai viet vowel ay",
            TaiViet::VowelAn => "tai viet vowel an",
            TaiViet::VowelAm => "tai viet vowel am",
            TaiViet::ToneMaiEk => "tai viet tone mai ek",
            TaiViet::ToneMaiNueng => "tai viet tone mai nueng",
            TaiViet::ToneMaiTho => "tai viet tone mai tho",
            TaiViet::ToneMaiSong => "tai viet tone mai song",
            TaiViet::SymbolKon => "tai viet symbol kon",
            TaiViet::SymbolNueng => "tai viet symbol nueng",
            TaiViet::SymbolSam => "tai viet symbol sam",
            TaiViet::SymbolHoHoi => "tai viet symbol ho hoi",
        }
    }
}