libm3/src/types/Unicode.m3


---------------------------------------------------------------------------*\
 *  Copyright (c) 2003 - 2004 by Dirk Muysers.
 *  For details see file copying.txt
 *
 *  MODULE:    Unicode.m3
 *  PURPOSE:   Unicode character set
 *  HISTORY:
 *    DATE          PROGRAMMER       DESCRIPTION
 *    30-Nov-2003   Dirk Muysers     Initial creation
 *
 *  NOTE:
 *    The data tables in this module are based on the file 
 *    UnicodeData-3.2.0.txt.
 *
 *----------------------------------------------------------------------------
 *  $Id: Unicode.m3.html,v 1.3 2010-04-29 17:19:04 wagner Exp $
\*---------------------------------------------------------------------------
UNSAFE MODULE Unicode;
---------------------------------------------------------------------------*} * DESCRIPTION: * * This implementation admittedly uses a brute force approach. * * Normally, UNICODE character properties should be provided by the operating * system, which is not the case for the majority of the existing Win32 * platforms. This implementation, while being a performance hog, has the * advantage of having a minimal memory footprint. Most operating system * implementations that offer good performance require at least 2 MB of * memory for hosting the corresponding property tables. * * Reference: Optimal Unicode 3.x Character Attributes and Access Methods * <http://developers.sun.com/dev/gadc/technicalpublications/presentations/ * iuc19-optimalunicode.pdf> * {*---------------------------------------------------------------------------

===========================================================================*} * TYPES {*===========================================================================

TYPE
  Ord = BITS 16 FOR [0..16_FFFF];
  Ptr = UNTRACED REF Ord;
===========================================================================*} * DATA {*===========================================================================

VAR
---------------------------------------------------------------------------*} * Spaces {*---------------------------------------------------------------------------

space2 := ARRAY [0..13] OF Ord {
    16_0009, 16_000D, (* tab, form feed, newline and carriage return *)
    16_0020, 16_0020, (* space *)
    16_00a0, 16_00A0, (* non-break space *)
    16_2000, 16_200B, (*   - ​ *)
    16_2028, 16_2029, (* 
 - 
 *)
    16_3000, 16_3000, (*   *)
    16_FEFF, 16_FEFF  (* byte order mark *)
    };
---------------------------------------------------------------------------*} * Letter ranges (covers only those ranges that are not in lower or upper) {*---------------------------------------------------------------------------

alpha2 := ARRAY [0..303] OF Ord {
    16_00D8,	16_00F6,	(* Ø - ö *)
    16_00F8,	16_01F5,	(* ø - ǵ *)
    16_0250,	16_02A8,	(* ɐ - ʨ *)
    16_038E,	16_03A1,	(* Ύ - Ρ *)
    16_03A3,	16_03CE,	(* Σ - ώ *)
    16_03D0,	16_03D6,	(* ϐ - ϖ *)
    16_03E2,	16_03F3,	(* Ϣ - ϳ *)
    16_0490,	16_04C4,	(* Ґ - ӄ *)
    16_0561,	16_0587,	(* ա - և *)
    16_05D0,	16_05EA,	(* א - ת *)
    16_05F0,	16_05F2,	(* װ - ײ *)
    16_0621,	16_063A,	(* ء - غ *)
    16_0640,	16_064A,	(* ـ - ي *)
    16_0671,	16_06B7,	(* ٱ - ڷ *)
    16_06BA,	16_06BE,	(* ں - ھ *)
    16_06C0,	16_06CE,	(* ۀ - ێ *)
    16_06D0,	16_06D3,	(* ې - ۓ *)
    16_0905,	16_0939,	(* अ - ह *)
    16_0958,	16_0961,	(* क़ - ॡ *)
    16_0985,	16_098C,	(* অ - ঌ *)
    16_098F,	16_0990,	(* এ - ঐ *)
    16_0993,	16_09A8,	(* ও - ন *)
    16_09AA,	16_09B0,	(* প - র *)
    16_09B6,	16_09B9,	(* শ - হ *)
    16_09DC,	16_09DD,	(* ড় - ঢ় *)
    16_09DF,	16_09E1,	(* য় - ৡ *)
    16_09F0,	16_09F1,	(* ৰ - ৱ *)
    16_0A05,	16_0A0A,	(* ਅ - ਊ *)
    16_0A0F,	16_0A10,	(* ਏ - ਐ *)
    16_0A13,	16_0A28,	(* ਓ - ਨ *)
    16_0A2A,	16_0A30,	(* ਪ - ਰ *)
    16_0A32,	16_0A33,	(* ਲ - ਲ਼ *)
    16_0A35,	16_0A36,	(* ਵ - ਸ਼ *)
    16_0A38,	16_0A39,	(* ਸ - ਹ *)
    16_0A59,	16_0A5C,	(* ਖ਼ - ੜ *)
    16_0A85,	16_0A8B,	(* અ - ઋ *)
    16_0A8F,	16_0A91,	(* એ - ઑ *)
    16_0A93,	16_0AA8,	(* ઓ - ન *)
    16_0AAA,	16_0AB0,	(* પ - ર *)
    16_0AB2,	16_0AB3,	(* લ - ળ *)
    16_0AB5,	16_0AB9,	(* વ - હ *)
    16_0B05,	16_0B0C,	(* ଅ - ଌ *)
    16_0B0F,	16_0B10,	(* ଏ - ଐ *)
    16_0B13,	16_0B28,	(* ଓ - ନ *)
    16_0B2A,	16_0B30,	(* ପ - ର *)
    16_0B32,	16_0B33,	(* ଲ - ଳ *)
    16_0B36,	16_0B39,	(* ଶ - ହ *)
    16_0B5C,	16_0B5D,	(* ଡ଼ - ଢ଼ *)
    16_0B5F,	16_0B61,	(* ୟ - ୡ *)
    16_0B85,	16_0B8A,	(* அ - ஊ *)
    16_0B8E,	16_0B90,	(* எ - ஐ *)
    16_0B92,	16_0B95,	(* ஒ - க *)
    16_0B99,	16_0B9A,	(* ங - ச *)
    16_0B9E,	16_0B9F,	(* ஞ - ட *)
    16_0BA3,	16_0BA4,	(* ண - த *)
    16_0BA8,	16_0BAA,	(* ந - ப *)
    16_0BAE,	16_0BB5,	(* ம - வ *)
    16_0BB7,	16_0BB9,	(* ஷ - ஹ *)
    16_0C05,	16_0C0C,	(* అ - ఌ *)
    16_0C0E,	16_0C10,	(* ఎ - ఐ *)
    16_0C12,	16_0C28,	(* ఒ - న *)
    16_0C2A,	16_0C33,	(* ప - ళ *)
    16_0C35,	16_0C39,	(* వ - హ *)
    16_0C60,	16_0C61,	(* ౠ - ౡ *)
    16_0C85,	16_0C8C,	(* ಅ - ಌ *)
    16_0C8E,	16_0C90,	(* ಎ - ಐ *)
    16_0C92,	16_0CA8,	(* ಒ - ನ *)
    16_0CAA,	16_0CB3,	(* ಪ - ಳ *)
    16_0CB5,	16_0CB9,	(* ವ - ಹ *)
    16_0CE0,	16_0CE1,	(* ೠ - ೡ *)
    16_0D05,	16_0D0C,	(* അ - ഌ *)
    16_0D0E,	16_0D10,	(* എ - ഐ *)
    16_0D12,	16_0D28,	(* ഒ - ന *)
    16_0D2A,	16_0D39,	(* പ - ഹ *)
    16_0D60,	16_0D61,	(* ൠ - ൡ *)
    16_0E01,	16_0E30,	(* ก - ะ *)
    16_0E32,	16_0E33,	(* า - ำ *)
    16_0E40,	16_0E46,	(* เ - ๆ *)
    16_0E5A,	16_0E5B,	(* ๚ - ๛ *)
    16_0E81,	16_0E82,	(* ກ - ຂ *)
    16_0E87,	16_0E88,	(* ງ - ຈ *)
    16_0E94,	16_0E97,	(* ດ - ທ *)
    16_0E99,	16_0E9F,	(* ນ - ຟ *)
    16_0EA1,	16_0EA3,	(* ມ - ຣ *)
    16_0EAA,	16_0EAB,	(* ສ - ຫ *)
    16_0EAD,	16_0EAE,	(* ອ - ຮ *)
    16_0EB2,	16_0EB3,	(* າ - ຳ *)
    16_0EC0,	16_0EC4,	(* ເ - ໄ *)
    16_0EDC,	16_0EDD,	(* ໜ - ໝ *)
    16_0F18,	16_0F19,	(* ༘ - ༙ *)
    16_0F40,	16_0F47,	(* ཀ - ཇ *)
    16_0F49,	16_0F69,	(* ཉ - ཀྵ *)
    16_10D0,	16_10F6,	(* ა - ჶ *)
    16_1100,	16_1159,	(* ᄀ - ᅙ *)
    16_115F,	16_11A2,	(* ᅟ - ᆢ *)
    16_11A8,	16_11F9,	(* ᆨ - ᇹ *)
    16_1E00,	16_1E9B,	(* Ḁ - ẛ *)
    16_1F50,	16_1F57,	(* ὐ - ὗ *)
    16_1F80,	16_1FB4,	(* ᾀ - ᾴ *)
    16_1FB6,	16_1FBC,	(* ᾶ - ᾼ *)
    16_1FC2,	16_1FC4,	(* ῂ - ῄ *)
    16_1FC6,	16_1FCC,	(* ῆ - ῌ *)
    16_1FD0,	16_1FD3,	(* ῐ - ΐ *)
    16_1FD6,	16_1FDB,	(* ῖ - Ί *)
    16_1FE0,	16_1FEC,	(* ῠ - Ῥ *)
    16_1FF2,	16_1FF4,	(* ῲ - ῴ *)
    16_1FF6,	16_1FFC,	(* ῶ - ῼ *)
    16_210A,	16_2113,	(* ℊ - ℓ *)
    16_2115,	16_211D,	(* ℕ - ℝ *)
    16_2120,	16_2122,	(* ℠ - ™ *)
    16_212A,	16_2131,	(* K - ℱ *)
    16_2133,	16_2138,	(* ℳ - ℸ *)
    16_3041,	16_3094,	(* ぁ - ゔ *)
    16_30A1,	16_30FA,	(* ァ - ヺ *)
    16_3105,	16_312C,	(* ㄅ - ㄬ *)
    16_3131,	16_318E,	(* ㄱ - ㆎ *)
    16_3192,	16_319F,	(* ㆒ - ㆟ *)
    16_3260,	16_327B,	(* ㉠ - ㉻ *)
    16_328A,	16_32B0,	(* ㊊ - ㊰ *)
    16_32D0,	16_32FE,	(* ㋐ - ㋾ *)
    16_3300,	16_3357,	(* ㌀ - ㍗ *)
    16_3371,	16_3376,	(* ㍱ - ㍶ *)
    16_337B,	16_3394,	(* ㍻ - ㎔ *)
    16_3399,	16_339E,	(* ㎙ - ㎞ *)
    16_33A9,	16_33AD,	(* ㎩ - ㎭ *)
    16_33B0,	16_33C1,	(* ㎰ - ㏁ *)
    16_33C3,	16_33C5,	(* ㏃ - ㏅ *)
    16_33C7,	16_33D7,	(* ㏇ - ㏗ *)
    16_33D9,	16_33DD,	(* ㏙ - ㏝ *)
    16_4E00,	16_9FFF,	(* 一 - 鿿 *)
    16_AC00,	16_D7A3,	(* 가 - 힣 *)
    16_F900,	16_FB06,	(* 豈 - st *)
    16_FB13,	16_FB17,	(* ﬓ - ﬗ *)
    16_FB1F,	16_FB28,	(* ײַ - ﬨ *)
    16_FB2A,	16_FB36,	(* שׁ - זּ *)
    16_FB38,	16_FB3C,	(* טּ - לּ *)
    16_FB40,	16_FB41,	(* נּ - סּ *)
    16_FB43,	16_FB44,	(* ףּ - פּ *)
    16_FB46,	16_FBB1,	(* צּ - ﮱ *)
    16_FBD3,	16_FD3D,	(* ﯓ - ﴽ *)
    16_FD50,	16_FD8F,	(* ﵐ - ﶏ *)
    16_FD92,	16_FDC7,	(* ﶒ - ﷇ *)
    16_FDF0,	16_FDF9,	(* ﷰ - ﷹ *)
    16_FE70,	16_FE72,	(* ﹰ - ﹲ *)
    16_FE76,	16_FEFC,	(* ﹶ - ﻼ *)
    16_FF66,	16_FF6F,	(* ヲ - ッ *)
    16_FF71,	16_FF9D,	(* ア - ン *)
    16_FFA0,	16_FFBE,	(* ᅠ - ᄒ *)
    16_FFC2,	16_FFC7,	(* ᅡ - ᅦ *)
    16_FFCA,	16_FFCF,	(* ᅧ - ᅬ *)
    16_FFD2,	16_FFD7,	(* ᅭ - ᅲ *)
    16_FFDA,    16_FFDC         (* ᅳ - ᅵ *)
    };
---------------------------------------------------------------------------*} * Letter singletons (only covers those letters that are not in upper/lower) {*---------------------------------------------------------------------------

alpha1 := ARRAY [0..31] OF Ord {
    16_00AA,	(* ª *)
    16_00B5,	(* µ *)
    16_00BA,	(* º *)
    16_03DA,	(* Ϛ *)
    16_03DC,	(* Ϝ *)
    16_03DE,	(* Ϟ *)
    16_03E0,	(* Ϡ *)
    16_06D5,	(* ە *)
    16_09B2,	(* ল *)
    16_0A5E,	(* ਫ਼ *)
    16_0A8D,	(* ઍ *)
    16_0AE0,	(* ૠ *)
    16_0B9C,	(* ஜ *)
    16_0CDE,	(* ೞ *)
    16_0E4F,	(* ๏ *)
    16_0E84,	(* ຄ *)
    16_0E8A,	(* ຊ *)
    16_0E8D,	(* ຍ *)
    16_0EA5,	(* ລ *)
    16_0EA7,	(* ວ *)
    16_0EB0,	(* ະ *)
    16_0EBD,	(* ຽ *)
    16_1FBE,	(* ι *)
    16_207F,	(* ⁿ *)
    16_20A8,	(* ₨ *)
    16_2102,	(* ℂ *)
    16_2107,	(* ℇ *)
    16_2124,	(* ℤ *)
    16_2126,	(* Ω *)
    16_2128,	(* ℨ *)
    16_FB3E,	(* מּ *)
    16_FE74	(* ﹴ *)
    };
---------------------------------------------------------------------------*} * Decimal digit ranges {*---------------------------------------------------------------------------

digit2 := ARRAY [0..41] OF Ord {
    16_0030, 16_0039, (* Digit *)
    16_0660, 16_0669, (* Arabic Indic *)
    16_06F0, 16_06F9, (* Extended Arabic Indic *)
    16_0966, 16_096F, (* Devanagari *)
    16_09E6, 16_09EF, (* Bengali *)
    16_0A66, 16_0A6F, (* Gurmukhi *)
    16_0AE6, 16_0AEF, (* Gujarati *)
    16_0B66, 16_0B6F, (* Oriya *)
    16_0BE7, 16_0BEF, (* Tamil [1..9] :-( *)
    16_0C66, 16_0C6F, (* Telugu *)
    16_0CE6, 16_0CEF, (* Kannara *)
    16_0D66, 16_0D6F, (* Malyalam *)
    16_0E50, 16_0E59, (* Thai *)
    16_0ED0, 16_0ED9, (* Lao *)
    16_0F20, 16_0F29, (* Tibetan *)
    16_1040, 16_1049, (* Burmese *)
    16_1369, 16_1371, (* Ethiopian [1..9] :-( *)
    16_17E0, 16_17E9, (* Khmer *)
    16_1810, 16_1819, (* Gurmukhi *)
    16_0A66, 16_0A6F, (* Mongolian *)
    16_FF10, 16_FF19  (* Fullwidth digit *)
    };
---------------------------------------------------------------------------*} * Upper-case ranges (3rd column is conversion excess 500) {*---------------------------------------------------------------------------

tolower3 := ARRAY [0..107] OF Ord {
    16_0041, 16_005A, 532, (* A-Z a-z *)
    16_00C0, 16_00D6, 532, (* À-Ö à-ö *)
    16_00D8, 16_00DE, 532, (* Ø-Þ ø-þ *)
    16_0189, 16_018A, 705, (* Ɖ-Ɗ ɖ-ɗ *)
    16_018E, 16_018F, 702, (* Ǝ-Ə ɘ-ə *)
    16_01B1, 16_01B2, 717, (* Ʊ-Ʋ ʊ-ʋ *)
    16_0388, 16_038A, 537, (* Έ-Ί έ-ί *)
    16_038E, 16_038F, 563, (* Ύ-Ώ ύ-ώ *)
    16_0391, 16_03A1, 532, (* Α-Ρ α-ρ *)
    16_03A3, 16_03AB, 532, (* Σ-Ϋ σ-ϋ *)
    16_0401, 16_040C, 580, (* Ё-Ќ ё-ќ *)
    16_040E, 16_040F, 580, (* Ў-Џ ў-џ *)
    16_0410, 16_042F, 532, (* А-Я а-я *)
    16_0531, 16_0556, 548, (* Ա-Ֆ ա-ֆ *)
    16_10A0, 16_10C5, 548, (* Ⴀ-Ⴥ ა-ჵ *)
    16_1F08, 16_1F0F, 492, (* Ἀ-Ἇ ἀ-ἇ *)
    16_1F18, 16_1F1D, 492, (* Ἐ-Ἕ ἐ-ἕ *)
    16_1F28, 16_1F2F, 492, (* Ἠ-Ἧ ἠ-ἧ *)
    16_1F38, 16_1F3F, 492, (* Ἰ-Ἷ ἰ-ἷ *)
    16_1F48, 16_1F4D, 492, (* Ὀ-Ὅ ὀ-ὅ *)
    16_1F68, 16_1F6F, 492, (* Ὠ-Ὧ ὠ-ὧ *)
    16_1F88, 16_1F8F, 492, (* -ᾏ ᾀ-ᾇ *)
    16_1F98, 16_1F9F, 492, (* ᾘ-ᾟ ᾐ-ᾗ *)
    16_1FA8, 16_1FAF, 492, (* ᾨ-ᾯ ᾠ-ᾧ *)
    16_1FB8, 16_1FB9, 492, (* Ᾰ-Ᾱ ᾰ-ᾱ *)
    16_1FBA, 16_1FBB, 426, (* Ὰ-Ά ὰ-ά *)
    16_1FC8, 16_1FCB, 414, (* Ὲ-Ή ὲ-ή *)
    16_1FD8, 16_1FD9, 492, (* Ῐ-Ῑ ῐ-ῑ *)
    16_1FDA, 16_1FDB, 400, (* Ὶ-Ί ὶ-ί *)
    16_1FE8, 16_1FE9, 492, (* Ῠ-Ῡ ῠ-ῡ *)
    16_1FEA, 16_1FEB, 388, (* Ὺ-Ύ ὺ-ύ *)
    16_1FF8, 16_1FF9, 372, (* Ὸ-Ό ὸ-ό *)
    16_1FFA, 16_1FFB, 374, (* Ὼ-Ώ ὼ-ώ *)
    16_2160, 16_216F, 516, (* Ⅰ-Ⅿ ⅰ-ⅿ *)
    16_24B6, 16_24CF, 526, (* Ⓐ-Ⓩ ⓐ-ⓩ *)
    16_FF21, 16_FF3A, 532  (* A-Z a-z *)
    };
---------------------------------------------------------------------------*} * Upper-case Singletons (2nd column is conversion excess 500 {*---------------------------------------------------------------------------

tolower2 := ARRAY [0..665] OF Ord {
    16_0100, 501,	(* Ā ā *)
    16_0102, 501,	(* Ă ă *)
    16_0104, 501,	(* Ą ą *)
    16_0106, 501,	(* Ć ć *)
    16_0108, 501,	(* Ĉ ĉ *)
    16_010A, 501,	(* Ċ ċ *)
    16_010C, 501,	(* Č č *)
    16_010E, 501,	(* Ď ď *)
    16_0110, 501,	(* Đ đ *)
    16_0112, 501,	(* Ē ē *)
    16_0114, 501,	(* Ĕ ĕ *)
    16_0116, 501,	(* Ė ė *)
    16_0118, 501,	(* Ę ę *)
    16_011A, 501,	(* Ě ě *)
    16_011C, 501,	(* Ĝ ĝ *)
    16_011E, 501,	(* Ğ ğ *)
    16_0120, 501,	(* Ġ ġ *)
    16_0122, 501,	(* Ģ ģ *)
    16_0124, 501,	(* Ĥ ĥ *)
    16_0126, 501,	(* Ħ ħ *)
    16_0128, 501,	(* Ĩ ĩ *)
    16_012A, 501,	(* Ī ī *)
    16_012C, 501,	(* Ĭ ĭ *)
    16_012E, 501,	(* Į į *)
    16_0130, 301,	(* İ i *)
    16_0132, 501,	(* IJ ij *)
    16_0134, 501,	(* Ĵ ĵ *)
    16_0136, 501,	(* Ķ ķ *)
    16_0139, 501,	(* Ĺ ĺ *)
    16_013B, 501,	(* Ļ ļ *)
    16_013D, 501,	(* Ľ ľ *)
    16_013F, 501,	(* Ŀ ŀ *)
    16_0141, 501,	(* Ł ł *)
    16_0143, 501,	(* Ń ń *)
    16_0145, 501,	(* Ņ ņ *)
    16_0147, 501,	(* Ň ň *)
    16_014A, 501,	(* Ŋ ŋ *)
    16_014C, 501,	(* Ō ō *)
    16_014E, 501,	(* Ŏ ŏ *)
    16_0150, 501,	(* Ő ő *)
    16_0152, 501,	(* Œ œ *)
    16_0154, 501,	(* Ŕ ŕ *)
    16_0156, 501,	(* Ŗ ŗ *)
    16_0158, 501,	(* Ř ř *)
    16_015A, 501,	(* Ś ś *)
    16_015C, 501,	(* Ŝ ŝ *)
    16_015E, 501,	(* Ş ş *)
    16_0160, 501,	(* Š š *)
    16_0162, 501,	(* Ţ ţ *)
    16_0164, 501,	(* Ť ť *)
    16_0166, 501,	(* Ŧ ŧ *)
    16_0168, 501,	(* Ũ ũ *)
    16_016A, 501,	(* Ū ū *)
    16_016C, 501,	(* Ŭ ŭ *)
    16_016E, 501,	(* Ů ů *)
    16_0170, 501,	(* Ű ű *)
    16_0172, 501,	(* Ų ų *)
    16_0174, 501,	(* Ŵ ŵ *)
    16_0176, 501,	(* Ŷ ŷ *)
    16_0178, 379,	(* Ÿ ÿ *)
    16_0179, 501,	(* Ź ź *)
    16_017B, 501,	(* Ż ż *)
    16_017D, 501,	(* Ž ž *)
    16_0181, 710,	(* Ɓ ɓ *)
    16_0182, 501,	(* Ƃ ƃ *)
    16_0184, 501,	(* Ƅ ƅ *)
    16_0186, 706,	(* Ɔ ɔ *)
    16_0187, 501,	(* Ƈ ƈ *)
    16_018B, 501,	(* Ƌ ƌ *)
    16_0190, 703,	(* Ɛ ɛ *)
    16_0191, 501,	(* Ƒ ƒ *)
    16_0193, 705,	(* Ɠ ɠ *)
    16_0194, 707,	(* Ɣ ɣ *)
    16_0196, 711,	(* Ɩ ɩ *)
    16_0197, 709,	(* Ɨ ɨ *)
    16_0198, 501,	(* Ƙ ƙ *)
    16_019C, 711,	(* Ɯ ɯ *)
    16_019D, 713,	(* Ɲ ɲ *)
    16_01A0, 501,	(* Ơ ơ *)
    16_01A2, 501,	(* Ƣ ƣ *)
    16_01A4, 501,	(* Ƥ ƥ *)
    16_01A7, 501,	(* Ƨ ƨ *)
    16_01A9, 718,	(* Ʃ ʃ *)
    16_01AC, 501,	(* Ƭ ƭ *)
    16_01AE, 718,	(* Ʈ ʈ *)
    16_01AF, 501,	(* Ư ư *)
    16_01B3, 501,	(* Ƴ ƴ *)
    16_01B5, 501,	(* Ƶ ƶ *)
    16_01B7, 719,	(* Ʒ ʒ *)
    16_01B8, 501,	(* Ƹ ƹ *)
    16_01BC, 501,	(* Ƽ ƽ *)
    16_01C4, 502,	(* DŽ dž *)
    16_01C5, 501,	(* Dž dž *)
    16_01C7, 502,	(* LJ lj *)
    16_01C8, 501,	(* Lj lj *)
    16_01CA, 502,	(* NJ nj *)
    16_01CB, 501,	(* Nj nj *)
    16_01CD, 501,	(* Ǎ ǎ *)
    16_01CF, 501,	(* Ǐ ǐ *)
    16_01D1, 501,	(* Ǒ ǒ *)
    16_01D3, 501,	(* Ǔ ǔ *)
    16_01D5, 501,	(* Ǖ ǖ *)
    16_01D7, 501,	(* Ǘ ǘ *)
    16_01D9, 501,	(* Ǚ ǚ *)
    16_01DB, 501,	(* Ǜ ǜ *)
    16_01DE, 501,	(* Ǟ ǟ *)
    16_01E0, 501,	(* Ǡ ǡ *)
    16_01E2, 501,	(* Ǣ ǣ *)
    16_01E4, 501,	(* Ǥ ǥ *)
    16_01E6, 501,	(* Ǧ ǧ *)
    16_01E8, 501,	(* Ǩ ǩ *)
    16_01EA, 501,	(* Ǫ ǫ *)
    16_01EC, 501,	(* Ǭ ǭ *)
    16_01EE, 501,	(* Ǯ ǯ *)
    16_01F1, 502,	(* DZ dz *)
    16_01F2, 501,	(* Dz dz *)
    16_01F4, 501,	(* Ǵ ǵ *)
    16_01FA, 501,	(* Ǻ ǻ *)
    16_01FC, 501,	(* Ǽ ǽ *)
    16_01FE, 501,	(* Ǿ ǿ *)
    16_0200, 501,	(* Ȁ ȁ *)
    16_0202, 501,	(* Ȃ ȃ *)
    16_0204, 501,	(* Ȅ ȅ *)
    16_0206, 501,	(* Ȇ ȇ *)
    16_0208, 501,	(* Ȉ ȉ *)
    16_020A, 501,	(* Ȋ ȋ *)
    16_020C, 501,	(* Ȍ ȍ *)
    16_020E, 501,	(* Ȏ ȏ *)
    16_0210, 501,	(* Ȑ ȑ *)
    16_0212, 501,	(* Ȓ ȓ *)
    16_0214, 501,	(* Ȕ ȕ *)
    16_0216, 501,	(* Ȗ ȗ *)
    16_0386, 538,	(* Ά ά *)
    16_038C, 564,	(* Ό ό *)
    16_03E2, 501,	(* Ϣ ϣ *)
    16_03E4, 501,	(* Ϥ ϥ *)
    16_03E6, 501,	(* Ϧ ϧ *)
    16_03E8, 501,	(* Ϩ ϩ *)
    16_03EA, 501,	(* Ϫ ϫ *)
    16_03EC, 501,	(* Ϭ ϭ *)
    16_03EE, 501,	(* Ϯ ϯ *)
    16_0460, 501,	(* Ѡ ѡ *)
    16_0462, 501,	(* Ѣ ѣ *)
    16_0464, 501,	(* Ѥ ѥ *)
    16_0466, 501,	(* Ѧ ѧ *)
    16_0468, 501,	(* Ѩ ѩ *)
    16_046A, 501,	(* Ѫ ѫ *)
    16_046C, 501,	(* Ѭ ѭ *)
    16_046E, 501,	(* Ѯ ѯ *)
    16_0470, 501,	(* Ѱ ѱ *)
    16_0472, 501,	(* Ѳ ѳ *)
    16_0474, 501,	(* Ѵ ѵ *)
    16_0476, 501,	(* Ѷ ѷ *)
    16_0478, 501,	(* Ѹ ѹ *)
    16_047A, 501,	(* Ѻ ѻ *)
    16_047C, 501,	(* Ѽ ѽ *)
    16_047E, 501,	(* Ѿ ѿ *)
    16_0480, 501,	(* Ҁ ҁ *)
    16_0490, 501,	(* Ґ ґ *)
    16_0492, 501,	(* Ғ ғ *)
    16_0494, 501,	(* Ҕ ҕ *)
    16_0496, 501,	(* Җ җ *)
    16_0498, 501,	(* Ҙ ҙ *)
    16_049A, 501,	(* Қ қ *)
    16_049C, 501,	(* Ҝ ҝ *)
    16_049E, 501,	(* Ҟ ҟ *)
    16_04A0, 501,	(* Ҡ ҡ *)
    16_04A2, 501,	(* Ң ң *)
    16_04A4, 501,	(* Ҥ ҥ *)
    16_04A6, 501,	(* Ҧ ҧ *)
    16_04A8, 501,	(* Ҩ ҩ *)
    16_04AA, 501,	(* Ҫ ҫ *)
    16_04AC, 501,	(* Ҭ ҭ *)
    16_04AE, 501,	(* Ү ү *)
    16_04B0, 501,	(* Ұ ұ *)
    16_04B2, 501,	(* Ҳ ҳ *)
    16_04B4, 501,	(* Ҵ ҵ *)
    16_04B6, 501,	(* Ҷ ҷ *)
    16_04B8, 501,	(* Ҹ ҹ *)
    16_04BA, 501,	(* Һ һ *)
    16_04BC, 501,	(* Ҽ ҽ *)
    16_04BE, 501,	(* Ҿ ҿ *)
    16_04C1, 501,	(* Ӂ ӂ *)
    16_04C3, 501,	(* Ӄ ӄ *)
    16_04C7, 501,	(* Ӈ ӈ *)
    16_04CB, 501,	(* Ӌ ӌ *)
    16_04D0, 501,	(* Ӑ ӑ *)
    16_04D2, 501,	(* Ӓ ӓ *)
    16_04D4, 501,	(* Ӕ ӕ *)
    16_04D6, 501,	(* Ӗ ӗ *)
    16_04D8, 501,	(* Ә ә *)
    16_04DA, 501,	(* Ӛ ӛ *)
    16_04DC, 501,	(* Ӝ ӝ *)
    16_04DE, 501,	(* Ӟ ӟ *)
    16_04E0, 501,	(* Ӡ ӡ *)
    16_04E2, 501,	(* Ӣ ӣ *)
    16_04E4, 501,	(* Ӥ ӥ *)
    16_04E6, 501,	(* Ӧ ӧ *)
    16_04E8, 501,	(* Ө ө *)
    16_04EA, 501,	(* Ӫ ӫ *)
    16_04EE, 501,	(* Ӯ ӯ *)
    16_04F0, 501,	(* Ӱ ӱ *)
    16_04F2, 501,	(* Ӳ ӳ *)
    16_04F4, 501,	(* Ӵ ӵ *)
    16_04F8, 501,	(* Ӹ ӹ *)
    16_1E00, 501,	(* Ḁ ḁ *)
    16_1E02, 501,	(* Ḃ ḃ *)
    16_1E04, 501,	(* Ḅ ḅ *)
    16_1E06, 501,	(* Ḇ ḇ *)
    16_1E08, 501,	(* Ḉ ḉ *)
    16_1E0A, 501,	(* Ḋ ḋ *)
    16_1E0C, 501,	(* Ḍ ḍ *)
    16_1E0E, 501,	(* Ḏ ḏ *)
    16_1E10, 501,	(* Ḑ ḑ *)
    16_1E12, 501,	(* Ḓ ḓ *)
    16_1E14, 501,	(* Ḕ ḕ *)
    16_1E16, 501,	(* Ḗ ḗ *)
    16_1E18, 501,	(* Ḙ ḙ *)
    16_1E1A, 501,	(* Ḛ ḛ *)
    16_1E1C, 501,	(* Ḝ ḝ *)
    16_1E1E, 501,	(* Ḟ ḟ *)
    16_1E20, 501,	(* Ḡ ḡ *)
    16_1E22, 501,	(* Ḣ ḣ *)
    16_1E24, 501,	(* Ḥ ḥ *)
    16_1E26, 501,	(* Ḧ ḧ *)
    16_1E28, 501,	(* Ḩ ḩ *)
    16_1E2A, 501,	(* Ḫ ḫ *)
    16_1E2C, 501,	(* Ḭ ḭ *)
    16_1E2E, 501,	(* Ḯ ḯ *)
    16_1E30, 501,	(* Ḱ ḱ *)
    16_1E32, 501,	(* Ḳ ḳ *)
    16_1E34, 501,	(* Ḵ ḵ *)
    16_1E36, 501,	(* Ḷ ḷ *)
    16_1E38, 501,	(* Ḹ ḹ *)
    16_1E3A, 501,	(* Ḻ ḻ *)
    16_1E3C, 501,	(* Ḽ ḽ *)
    16_1E3E, 501,	(* Ḿ ḿ *)
    16_1E40, 501,	(* Ṁ ṁ *)
    16_1E42, 501,	(* Ṃ ṃ *)
    16_1E44, 501,	(* Ṅ ṅ *)
    16_1E46, 501,	(* Ṇ ṇ *)
    16_1E48, 501,	(* Ṉ ṉ *)
    16_1E4A, 501,	(* Ṋ ṋ *)
    16_1E4C, 501,	(* Ṍ ṍ *)
    16_1E4E, 501,	(* Ṏ ṏ *)
    16_1E50, 501,	(* Ṑ ṑ *)
    16_1E52, 501,	(* Ṓ ṓ *)
    16_1E54, 501,	(* Ṕ ṕ *)
    16_1E56, 501,	(* Ṗ ṗ *)
    16_1E58, 501,	(* Ṙ ṙ *)
    16_1E5A, 501,	(* Ṛ ṛ *)
    16_1E5C, 501,	(* Ṝ ṝ *)
    16_1E5E, 501,	(* Ṟ ṟ *)
    16_1E60, 501,	(* Ṡ ṡ *)
    16_1E62, 501,	(* Ṣ ṣ *)
    16_1E64, 501,	(* Ṥ ṥ *)
    16_1E66, 501,	(* Ṧ ṧ *)
    16_1E68, 501,	(* Ṩ ṩ *)
    16_1E6A, 501,	(* Ṫ ṫ *)
    16_1E6C, 501,	(* Ṭ ṭ *)
    16_1E6E, 501,	(* Ṯ ṯ *)
    16_1E70, 501,	(* Ṱ ṱ *)
    16_1E72, 501,	(* Ṳ ṳ *)
    16_1E74, 501,	(* Ṵ ṵ *)
    16_1E76, 501,	(* Ṷ ṷ *)
    16_1E78, 501,	(* Ṹ ṹ *)
    16_1E7A, 501,	(* Ṻ ṻ *)
    16_1E7C, 501,	(* Ṽ ṽ *)
    16_1E7E, 501,	(* Ṿ ṿ *)
    16_1E80, 501,	(* Ẁ ẁ *)
    16_1E82, 501,	(* Ẃ ẃ *)
    16_1E84, 501,	(* Ẅ ẅ *)
    16_1E86, 501,	(* Ẇ ẇ *)
    16_1E88, 501,	(* Ẉ ẉ *)
    16_1E8A, 501,	(* Ẋ ẋ *)
    16_1E8C, 501,	(* Ẍ ẍ *)
    16_1E8E, 501,	(* Ẏ ẏ *)
    16_1E90, 501,	(* Ẑ ẑ *)
    16_1E92, 501,	(* Ẓ ẓ *)
    16_1E94, 501,	(* Ẕ ẕ *)
    16_1EA0, 501,	(* Ạ ạ *)
    16_1EA2, 501,	(* Ả ả *)
    16_1EA4, 501,	(* Ấ ấ *)
    16_1EA6, 501,	(* Ầ ầ *)
    16_1EA8, 501,	(* Ẩ ẩ *)
    16_1EAA, 501,	(* Ẫ ẫ *)
    16_1EAC, 501,	(* Ậ ậ *)
    16_1EAE, 501,	(* Ắ ắ *)
    16_1EB0, 501,	(* Ằ ằ *)
    16_1EB2, 501,	(* Ẳ ẳ *)
    16_1EB4, 501,	(* Ẵ ẵ *)
    16_1EB6, 501,	(* Ặ ặ *)
    16_1EB8, 501,	(* Ẹ ẹ *)
    16_1EBA, 501,	(* Ẻ ẻ *)
    16_1EBC, 501,	(* Ẽ ẽ *)
    16_1EBE, 501,	(* Ế ế *)
    16_1EC0, 501,	(* Ề ề *)
    16_1EC2, 501,	(* Ể ể *)
    16_1EC4, 501,	(* Ễ ễ *)
    16_1EC6, 501,	(* Ệ ệ *)
    16_1EC8, 501,	(* Ỉ ỉ *)
    16_1ECA, 501,	(* Ị ị *)
    16_1ECC, 501,	(* Ọ ọ *)
    16_1ECE, 501,	(* Ỏ ỏ *)
    16_1ED0, 501,	(* Ố ố *)
    16_1ED2, 501,	(* Ồ ồ *)
    16_1ED4, 501,	(* Ổ ổ *)
    16_1ED6, 501,	(* Ỗ ỗ *)
    16_1ED8, 501,	(* Ộ ộ *)
    16_1EDA, 501,	(* Ớ ớ *)
    16_1EDC, 501,	(* Ờ ờ *)
    16_1EDE, 501,	(* Ở ở *)
    16_1EE0, 501,	(* Ỡ ỡ *)
    16_1EE2, 501,	(* Ợ ợ *)
    16_1EE4, 501,	(* Ụ ụ *)
    16_1EE6, 501,	(* Ủ ủ *)
    16_1EE8, 501,	(* Ứ ứ *)
    16_1EEA, 501,	(* Ừ ừ *)
    16_1EEC, 501,	(* Ử ử *)
    16_1EEE, 501,	(* Ữ ữ *)
    16_1EF0, 501,	(* Ự ự *)
    16_1EF2, 501,	(* Ỳ ỳ *)
    16_1EF4, 501,	(* Ỵ ỵ *)
    16_1EF6, 501,	(* Ỷ ỷ *)
    16_1EF8, 501,	(* Ỹ ỹ *)
    16_1F59, 492,	(* Ὑ ὑ *)
    16_1F5B, 492,	(* Ὓ ὓ *)
    16_1F5D, 492,	(* Ὕ ὕ *)
    16_1F5F, 492,	(* Ὗ ὗ *)
    16_1FBC, 491,	(* ᾼ ᾳ *)
    16_1FCC, 491,	(* ῌ ῃ *)
    16_1FEC, 493,	(* Ῥ ῥ *)
    16_1FFC, 491	(* ῼ ῳ *)
    };
---------------------------------------------------------------------------*} * Lower-case ranges (3rd column is conversion excess 500) {*---------------------------------------------------------------------------

toupper3 := ARRAY [0..104] OF Ord {
    16_0061, 16_007A, 468, (* a-z A-Z *)
    16_00E0, 16_00F6, 468, (* à-ö À-Ö *)
    16_00F8, 16_00FE, 468, (* ø-þ Ø-Þ *)
    16_0256, 16_0257, 295, (* ɖ-ɗ Ɖ-Ɗ *)
    16_0258, 16_0259, 298, (* ɘ-ə Ǝ-Ə *)
    16_028A, 16_028B, 283, (* ʊ-ʋ Ʊ-Ʋ *)
    16_03AD, 16_03AF, 463, (* έ-ί Έ-Ί *)
    16_03B1, 16_03C1, 468, (* α-ρ Α-Ρ *)
    16_03C3, 16_03CB, 468, (* σ-ϋ Σ-Ϋ *)
    16_03CD, 16_03CE, 437, (* ύ-ώ Ύ-Ώ *)
    16_0430, 16_044F, 468, (* а-я А-Я *)
    16_0451, 16_045C, 420, (* ё-ќ Ё-Ќ *)
    16_045E, 16_045F, 420, (* ў-џ Ў-Џ *)
    16_0561, 16_0586, 452, (* ա-ֆ Ա-Ֆ *)
    16_1F00, 16_1F07, 508, (* ἀ-ἇ Ἀ-Ἇ *)
    16_1F10, 16_1F15, 508, (* ἐ-ἕ Ἐ-Ἕ *)
    16_1F20, 16_1F27, 508, (* ἠ-ἧ Ἠ-Ἧ *)
    16_1F30, 16_1F37, 508, (* ἰ-ἷ Ἰ-Ἷ *)
    16_1F40, 16_1F45, 508, (* ὀ-ὅ Ὀ-Ὅ *)
    16_1F60, 16_1F67, 508, (* ὠ-ὧ Ὠ-Ὧ *)
    16_1F70, 16_1F71, 574, (* ὰ-ά Ὰ-Ά *)
    16_1F72, 16_1F75, 586, (* ὲ-ή Ὲ-Ή *)
    16_1F76, 16_1F77, 600, (* ὶ-ί Ὶ-Ί *)
    16_1F78, 16_1F79, 628, (* ὸ-ό Ὸ-Ό *)
    16_1F7A, 16_1F7B, 612, (* ὺ-ύ Ὺ-Ύ *)
    16_1F7C, 16_1F7D, 626, (* ὼ-ώ Ὼ-Ώ *)
    16_1F80, 16_1F87, 508, (* ᾀ-ᾇ ᾈ-ᾏ *)
    16_1F90, 16_1F97, 508, (* ᾐ-ᾗ ᾘ-ᾟ *)
    16_1FA0, 16_1FA7, 508, (* ᾠ-ᾧ ᾨ-ᾯ *)
    16_1FB0, 16_1FB1, 508, (* ᾰ-ᾱ Ᾰ-Ᾱ *)
    16_1FD0, 16_1FD1, 508, (* ῐ-ῑ Ῐ-Ῑ *)
    16_1FE0, 16_1FE1, 508, (* ῠ-ῡ Ῠ-Ῡ *)
    16_2170, 16_217F, 484, (* ⅰ-ⅿ Ⅰ-Ⅿ *)
    16_24D0, 16_24E9, 474, (* ⓐ-ⓩ Ⓐ-Ⓩ *)
    16_FF41, 16_FF5A, 468  (* a-z A-Z *)
    };
---------------------------------------------------------------------------*} * Lower-case singletons (2nd column is conversion excess 500) {*---------------------------------------------------------------------------

toupper2 := ARRAY [0..679] OF Ord {
    16_00FF, 621, (* ÿ Ÿ *)
    16_0101, 499, (* ā Ā *)
    16_0103, 499, (* ă Ă *)
    16_0105, 499, (* ą Ą *)
    16_0107, 499, (* ć Ć *)
    16_0109, 499, (* ĉ Ĉ *)
    16_010B, 499, (* ċ Ċ *)
    16_010D, 499, (* č Č *)
    16_010F, 499, (* ď Ď *)
    16_0111, 499, (* đ Đ *)
    16_0113, 499, (* ē Ē *)
    16_0115, 499, (* ĕ Ĕ *)
    16_0117, 499, (* ė Ė *)
    16_0119, 499, (* ę Ę *)
    16_011B, 499, (* ě Ě *)
    16_011D, 499, (* ĝ Ĝ *)
    16_011F, 499, (* ğ Ğ *)
    16_0121, 499, (* ġ Ġ *)
    16_0123, 499, (* ģ Ģ *)
    16_0125, 499, (* ĥ Ĥ *)
    16_0127, 499, (* ħ Ħ *)
    16_0129, 499, (* ĩ Ĩ *)
    16_012B, 499, (* ī Ī *)
    16_012D, 499, (* ĭ Ĭ *)
    16_012F, 499, (* į Į *)
    16_0131, 268, (* ı I *)
    16_0133, 499, (* ij IJ *)
    16_0135, 499, (* ĵ Ĵ *)
    16_0137, 499, (* ķ Ķ *)
    16_013A, 499, (* ĺ Ĺ *)
    16_013C, 499, (* ļ Ļ *)
    16_013E, 499, (* ľ Ľ *)
    16_0140, 499, (* ŀ Ŀ *)
    16_0142, 499, (* ł Ł *)
    16_0144, 499, (* ń Ń *)
    16_0146, 499, (* ņ Ņ *)
    16_0148, 499, (* ň Ň *)
    16_014B, 499, (* ŋ Ŋ *)
    16_014D, 499, (* ō Ō *)
    16_014F, 499, (* ŏ Ŏ *)
    16_0151, 499, (* ő Ő *)
    16_0153, 499, (* œ Œ *)
    16_0155, 499, (* ŕ Ŕ *)
    16_0157, 499, (* ŗ Ŗ *)
    16_0159, 499, (* ř Ř *)
    16_015B, 499, (* ś Ś *)
    16_015D, 499, (* ŝ Ŝ *)
    16_015F, 499, (* ş Ş *)
    16_0161, 499, (* š Š *)
    16_0163, 499, (* ţ Ţ *)
    16_0165, 499, (* ť Ť *)
    16_0167, 499, (* ŧ Ŧ *)
    16_0169, 499, (* ũ Ũ *)
    16_016B, 499, (* ū Ū *)
    16_016D, 499, (* ŭ Ŭ *)
    16_016F, 499, (* ů Ů *)
    16_0171, 499, (* ű Ű *)
    16_0173, 499, (* ų Ų *)
    16_0175, 499, (* ŵ Ŵ *)
    16_0177, 499, (* ŷ Ŷ *)
    16_017A, 499, (* ź Ź *)
    16_017C, 499, (* ż Ż *)
    16_017E, 499, (* ž Ž *)
    16_017F, 200, (* ſ S *)
    16_0183, 499, (* ƃ Ƃ *)
    16_0185, 499, (* ƅ Ƅ *)
    16_0188, 499, (* ƈ Ƈ *)
    16_018C, 499, (* ƌ Ƌ *)
    16_0192, 499, (* ƒ Ƒ *)
    16_0199, 499, (* ƙ Ƙ *)
    16_01A1, 499, (* ơ Ơ *)
    16_01A3, 499, (* ƣ Ƣ *)
    16_01A5, 499, (* ƥ Ƥ *)
    16_01A8, 499, (* ƨ Ƨ *)
    16_01AD, 499, (* ƭ Ƭ *)
    16_01B0, 499, (* ư Ư *)
    16_01B4, 499, (* ƴ Ƴ *)
    16_01B6, 499, (* ƶ Ƶ *)
    16_01B9, 499, (* ƹ Ƹ *)
    16_01BD, 499, (* ƽ Ƽ *)
    16_01C5, 499, (* Dž DŽ *)
    16_01C6, 498, (* dž DŽ *)
    16_01C8, 499, (* Lj LJ *)
    16_01C9, 498, (* lj LJ *)
    16_01CB, 499, (* Nj NJ *)
    16_01CC, 498, (* nj NJ *)
    16_01CE, 499, (* ǎ Ǎ *)
    16_01D0, 499, (* ǐ Ǐ *)
    16_01D2, 499, (* ǒ Ǒ *)
    16_01D4, 499, (* ǔ Ǔ *)
    16_01D6, 499, (* ǖ Ǖ *)
    16_01D8, 499, (* ǘ Ǘ *)
    16_01DA, 499, (* ǚ Ǚ *)
    16_01DC, 499, (* ǜ Ǜ *)
    16_01DF, 499, (* ǟ Ǟ *)
    16_01E1, 499, (* ǡ Ǡ *)
    16_01E3, 499, (* ǣ Ǣ *)
    16_01E5, 499, (* ǥ Ǥ *)
    16_01E7, 499, (* ǧ Ǧ *)
    16_01E9, 499, (* ǩ Ǩ *)
    16_01EB, 499, (* ǫ Ǫ *)
    16_01ED, 499, (* ǭ Ǭ *)
    16_01EF, 499, (* ǯ Ǯ *)
    16_01F2, 499, (* Dz DZ *)
    16_01F3, 498, (* dz DZ *)
    16_01F5, 499, (* ǵ Ǵ *)
    16_01FB, 499, (* ǻ Ǻ *)
    16_01FD, 499, (* ǽ Ǽ *)
    16_01FF, 499, (* ǿ Ǿ *)
    16_0201, 499, (* ȁ Ȁ *)
    16_0203, 499, (* ȃ Ȃ *)
    16_0205, 499, (* ȅ Ȅ *)
    16_0207, 499, (* ȇ Ȇ *)
    16_0209, 499, (* ȉ Ȉ *)
    16_020B, 499, (* ȋ Ȋ *)
    16_020D, 499, (* ȍ Ȍ *)
    16_020F, 499, (* ȏ Ȏ *)
    16_0211, 499, (* ȑ Ȑ *)
    16_0213, 499, (* ȓ Ȓ *)
    16_0215, 499, (* ȕ Ȕ *)
    16_0217, 499, (* ȗ Ȗ *)
    16_0253, 290, (* ɓ Ɓ *)
    16_0254, 294, (* ɔ Ɔ *)
    16_025B, 297, (* ɛ Ɛ *)
    16_0260, 295, (* ɠ Ɠ *)
    16_0263, 293, (* ɣ Ɣ *)
    16_0268, 291, (* ɨ Ɨ *)
    16_0269, 289, (* ɩ Ɩ *)
    16_026F, 289, (* ɯ Ɯ *)
    16_0272, 287, (* ɲ Ɲ *)
    16_0283, 282, (* ʃ Ʃ *)
    16_0288, 282, (* ʈ Ʈ *)
    16_0292, 281, (* ʒ Ʒ *)
    16_03AC, 462, (* ά Ά *)
    16_03CC, 436, (* ό Ό *)
    16_03D0, 438, (* ϐ Β *)
    16_03D1, 443, (* ϑ Θ *)
    16_03D5, 453, (* ϕ Φ *)
    16_03D6, 446, (* ϖ Π *)
    16_03E3, 499, (* ϣ Ϣ *)
    16_03E5, 499, (* ϥ Ϥ *)
    16_03E7, 499, (* ϧ Ϧ *)
    16_03E9, 499, (* ϩ Ϩ *)
    16_03EB, 499, (* ϫ Ϫ *)
    16_03ED, 499, (* ϭ Ϭ *)
    16_03EF, 499, (* ϯ Ϯ *)
    16_03F0, 414, (* ϰ Κ *)
    16_03F1, 420, (* ϱ Ρ *)
    16_0461, 499, (* ѡ Ѡ *)
    16_0463, 499, (* ѣ Ѣ *)
    16_0465, 499, (* ѥ Ѥ *)
    16_0467, 499, (* ѧ Ѧ *)
    16_0469, 499, (* ѩ Ѩ *)
    16_046B, 499, (* ѫ Ѫ *)
    16_046D, 499, (* ѭ Ѭ *)
    16_046F, 499, (* ѯ Ѯ *)
    16_0471, 499, (* ѱ Ѱ *)
    16_0473, 499, (* ѳ Ѳ *)
    16_0475, 499, (* ѵ Ѵ *)
    16_0477, 499, (* ѷ Ѷ *)
    16_0479, 499, (* ѹ Ѹ *)
    16_047B, 499, (* ѻ Ѻ *)
    16_047D, 499, (* ѽ Ѽ *)
    16_047F, 499, (* ѿ Ѿ *)
    16_0481, 499, (* ҁ Ҁ *)
    16_0491, 499, (* ґ Ґ *)
    16_0493, 499, (* ғ Ғ *)
    16_0495, 499, (* ҕ Ҕ *)
    16_0497, 499, (* җ Җ *)
    16_0499, 499, (* ҙ Ҙ *)
    16_049B, 499, (* қ Қ *)
    16_049D, 499, (* ҝ Ҝ *)
    16_049F, 499, (* ҟ Ҟ *)
    16_04A1, 499, (* ҡ Ҡ *)
    16_04A3, 499, (* ң Ң *)
    16_04A5, 499, (* ҥ Ҥ *)
    16_04A7, 499, (* ҧ Ҧ *)
    16_04A9, 499, (* ҩ Ҩ *)
    16_04AB, 499, (* ҫ Ҫ *)
    16_04AD, 499, (* ҭ Ҭ *)
    16_04AF, 499, (* ү Ү *)
    16_04B1, 499, (* ұ Ұ *)
    16_04B3, 499, (* ҳ Ҳ *)
    16_04B5, 499, (* ҵ Ҵ *)
    16_04B7, 499, (* ҷ Ҷ *)
    16_04B9, 499, (* ҹ Ҹ *)
    16_04BB, 499, (* һ Һ *)
    16_04BD, 499, (* ҽ Ҽ *)
    16_04BF, 499, (* ҿ Ҿ *)
    16_04C2, 499, (* ӂ Ӂ *)
    16_04C4, 499, (* ӄ Ӄ *)
    16_04C8, 499, (* ӈ Ӈ *)
    16_04CC, 499, (* ӌ Ӌ *)
    16_04D1, 499, (* ӑ Ӑ *)
    16_04D3, 499, (* ӓ Ӓ *)
    16_04D5, 499, (* ӕ Ӕ *)
    16_04D7, 499, (* ӗ Ӗ *)
    16_04D9, 499, (* ә Ә *)
    16_04DB, 499, (* ӛ Ӛ *)
    16_04DD, 499, (* ӝ Ӝ *)
    16_04DF, 499, (* ӟ Ӟ *)
    16_04E1, 499, (* ӡ Ӡ *)
    16_04E3, 499, (* ӣ Ӣ *)
    16_04E5, 499, (* ӥ Ӥ *)
    16_04E7, 499, (* ӧ Ӧ *)
    16_04E9, 499, (* ө Ө *)
    16_04EB, 499, (* ӫ Ӫ *)
    16_04EF, 499, (* ӯ Ӯ *)
    16_04F1, 499, (* ӱ Ӱ *)
    16_04F3, 499, (* ӳ Ӳ *)
    16_04F5, 499, (* ӵ Ӵ *)
    16_04F9, 499, (* ӹ Ӹ *)
    16_1E01, 499, (* ḁ Ḁ *)
    16_1E03, 499, (* ḃ Ḃ *)
    16_1E05, 499, (* ḅ Ḅ *)
    16_1E07, 499, (* ḇ Ḇ *)
    16_1E09, 499, (* ḉ Ḉ *)
    16_1E0B, 499, (* ḋ Ḋ *)
    16_1E0D, 499, (* ḍ Ḍ *)
    16_1E0F, 499, (* ḏ Ḏ *)
    16_1E11, 499, (* ḑ Ḑ *)
    16_1E13, 499, (* ḓ Ḓ *)
    16_1E15, 499, (* ḕ Ḕ *)
    16_1E17, 499, (* ḗ Ḗ *)
    16_1E19, 499, (* ḙ Ḙ *)
    16_1E1B, 499, (* ḛ Ḛ *)
    16_1E1D, 499, (* ḝ Ḝ *)
    16_1E1F, 499, (* ḟ Ḟ *)
    16_1E21, 499, (* ḡ Ḡ *)
    16_1E23, 499, (* ḣ Ḣ *)
    16_1E25, 499, (* ḥ Ḥ *)
    16_1E27, 499, (* ḧ Ḧ *)
    16_1E29, 499, (* ḩ Ḩ *)
    16_1E2B, 499, (* ḫ Ḫ *)
    16_1E2D, 499, (* ḭ Ḭ *)
    16_1E2F, 499, (* ḯ Ḯ *)
    16_1E31, 499, (* ḱ Ḱ *)
    16_1E33, 499, (* ḳ Ḳ *)
    16_1E35, 499, (* ḵ Ḵ *)
    16_1E37, 499, (* ḷ Ḷ *)
    16_1E39, 499, (* ḹ Ḹ *)
    16_1E3B, 499, (* ḻ Ḻ *)
    16_1E3D, 499, (* ḽ Ḽ *)
    16_1E3F, 499, (* ḿ Ḿ *)
    16_1E41, 499, (* ṁ Ṁ *)
    16_1E43, 499, (* ṃ Ṃ *)
    16_1E45, 499, (* ṅ Ṅ *)
    16_1E47, 499, (* ṇ Ṇ *)
    16_1E49, 499, (* ṉ Ṉ *)
    16_1E4B, 499, (* ṋ Ṋ *)
    16_1E4D, 499, (* ṍ Ṍ *)
    16_1E4F, 499, (* ṏ Ṏ *)
    16_1E51, 499, (* ṑ Ṑ *)
    16_1E53, 499, (* ṓ Ṓ *)
    16_1E55, 499, (* ṕ Ṕ *)
    16_1E57, 499, (* ṗ Ṗ *)
    16_1E59, 499, (* ṙ Ṙ *)
    16_1E5B, 499, (* ṛ Ṛ *)
    16_1E5D, 499, (* ṝ Ṝ *)
    16_1E5F, 499, (* ṟ Ṟ *)
    16_1E61, 499, (* ṡ Ṡ *)
    16_1E63, 499, (* ṣ Ṣ *)
    16_1E65, 499, (* ṥ Ṥ *)
    16_1E67, 499, (* ṧ Ṧ *)
    16_1E69, 499, (* ṩ Ṩ *)
    16_1E6B, 499, (* ṫ Ṫ *)
    16_1E6D, 499, (* ṭ Ṭ *)
    16_1E6F, 499, (* ṯ Ṯ *)
    16_1E71, 499, (* ṱ Ṱ *)
    16_1E73, 499, (* ṳ Ṳ *)
    16_1E75, 499, (* ṵ Ṵ *)
    16_1E77, 499, (* ṷ Ṷ *)
    16_1E79, 499, (* ṹ Ṹ *)
    16_1E7B, 499, (* ṻ Ṻ *)
    16_1E7D, 499, (* ṽ Ṽ *)
    16_1E7F, 499, (* ṿ Ṿ *)
    16_1E81, 499, (* ẁ Ẁ *)
    16_1E83, 499, (* ẃ Ẃ *)
    16_1E85, 499, (* ẅ Ẅ *)
    16_1E87, 499, (* ẇ Ẇ *)
    16_1E89, 499, (* ẉ Ẉ *)
    16_1E8B, 499, (* ẋ Ẋ *)
    16_1E8D, 499, (* ẍ Ẍ *)
    16_1E8F, 499, (* ẏ Ẏ *)
    16_1E91, 499, (* ẑ Ẑ *)
    16_1E93, 499, (* ẓ Ẓ *)
    16_1E95, 499, (* ẕ Ẕ *)
    16_1EA1, 499, (* ạ Ạ *)
    16_1EA3, 499, (* ả Ả *)
    16_1EA5, 499, (* ấ Ấ *)
    16_1EA7, 499, (* ầ Ầ *)
    16_1EA9, 499, (* ẩ Ẩ *)
    16_1EAB, 499, (* ẫ Ẫ *)
    16_1EAD, 499, (* ậ Ậ *)
    16_1EAF, 499, (* ắ Ắ *)
    16_1EB1, 499, (* ằ Ằ *)
    16_1EB3, 499, (* ẳ Ẳ *)
    16_1EB5, 499, (* ẵ Ẵ *)
    16_1EB7, 499, (* ặ Ặ *)
    16_1EB9, 499, (* ẹ Ẹ *)
    16_1EBB, 499, (* ẻ Ẻ *)
    16_1EBD, 499, (* ẽ Ẽ *)
    16_1EBF, 499, (* ế Ế *)
    16_1EC1, 499, (* ề Ề *)
    16_1EC3, 499, (* ể Ể *)
    16_1EC5, 499, (* ễ Ễ *)
    16_1EC7, 499, (* ệ Ệ *)
    16_1EC9, 499, (* ỉ Ỉ *)
    16_1ECB, 499, (* ị Ị *)
    16_1ECD, 499, (* ọ Ọ *)
    16_1ECF, 499, (* ỏ Ỏ *)
    16_1ED1, 499, (* ố Ố *)
    16_1ED3, 499, (* ồ Ồ *)
    16_1ED5, 499, (* ổ Ổ *)
    16_1ED7, 499, (* ỗ Ỗ *)
    16_1ED9, 499, (* ộ Ộ *)
    16_1EDB, 499, (* ớ Ớ *)
    16_1EDD, 499, (* ờ Ờ *)
    16_1EDF, 499, (* ở Ở *)
    16_1EE1, 499, (* ỡ Ỡ *)
    16_1EE3, 499, (* ợ Ợ *)
    16_1EE5, 499, (* ụ Ụ *)
    16_1EE7, 499, (* ủ Ủ *)
    16_1EE9, 499, (* ứ Ứ *)
    16_1EEB, 499, (* ừ Ừ *)
    16_1EED, 499, (* ử Ử *)
    16_1EEF, 499, (* ữ Ữ *)
    16_1EF1, 499, (* ự Ự *)
    16_1EF3, 499, (* ỳ Ỳ *)
    16_1EF5, 499, (* ỵ Ỵ *)
    16_1EF7, 499, (* ỷ Ỷ *)
    16_1EF9, 499, (* ỹ Ỹ *)
    16_1F51, 508, (* ὑ Ὑ *)
    16_1F53, 508, (* ὓ Ὓ *)
    16_1F55, 508, (* ὕ Ὕ *)
    16_1F57, 508, (* ὗ Ὗ *)
    16_1FB3, 509, (* ᾳ ᾼ *)
    16_1FC3, 509, (* ῃ ῌ *)
    16_1FE5, 507, (* ῥ Ῥ *)
    16_1FF3, 509  (* ῳ ῼ *)
    };
---------------------------------------------------------------------------*} * Lower-case singletons that have title-case equivalents * (2nd col. conversion excess 500) {*---------------------------------------------------------------------------

totitle2 := ARRAY [0..15] OF Ord {
    16_01C4, 501,	(* DŽ Dž *)
    16_01C6, 499,	(* dž Dž *)
    16_01C7, 501,	(* LJ Lj *)
    16_01C9, 499,	(* lj Lj *)
    16_01CA, 501,	(* NJ Nj *)
    16_01CC, 499,	(* nj Nj *)
    16_01F1, 501,	(* DZ Dz *)
    16_01F3, 499	(* dz Dz *)
    };
===========================================================================*} * EXPORTED PROCEDURES {*===========================================================================

PROCEDURE IsDefined (t: T): BOOLEAN =
  BEGIN
    IF ORD (t) > 16_FFFD THEN RETURN FALSE END;
    IF ORD (t) < 16_D800 OR ORD (t) > 16_DFFF THEN RETURN TRUE END;
    RETURN FALSE;
  END IsDefined;

PROCEDURE IsASCII (t: T): BOOLEAN =
  BEGIN
    RETURN ORD (t) <= ORD (LAST (CHAR));
  END IsASCII;

PROCEDURE IsSpace (t: T): BOOLEAN =
  VAR p := BSearch (t, ADR (space2), NUMBER (space2) DIV 2, 2);
  BEGIN
    IF p # NIL AND  p^ <= ORD (t) AND
      ORD (t) <= LOOPHOLE(p + ADRSIZE (Ord), Ptr)^ THEN
      RETURN TRUE;
    END;
    RETURN FALSE;
  END IsSpace;

PROCEDURE IsLetter (t: T): BOOLEAN =
  VAR p: Ptr;
  BEGIN
    IF IsUpperCase (t) OR IsLowerCase (t) THEN RETURN TRUE END;
    p := BSearch (t, ADR (alpha2), NUMBER (alpha2) DIV 2, 2);
    IF p # NIL AND p^ <= ORD (t) AND
      ORD (t) <= LOOPHOLE(p + ADRSIZE (Ord), Ptr)^ THEN
      RETURN TRUE;
    END;
    p := BSearch (t, ADR (alpha1), NUMBER (alpha1), 1);
    IF p # NIL AND ORD (t) = p^ THEN RETURN TRUE END;
    RETURN FALSE;
  END IsLetter;

PROCEDURE IsDigit (t: T): BOOLEAN =
  VAR p := BSearch (t, ADR (digit2), NUMBER (digit2) DIV 2, 2);
  BEGIN
    IF p # NIL AND p^ <= ORD (t) AND
      ORD (t) <= LOOPHOLE(p + ADRSIZE (Ord), Ptr)^ THEN
      RETURN TRUE;
    END;
    RETURN FALSE;
  END IsDigit;

PROCEDURE IsLetterOrDigit (t: T): BOOLEAN =
  BEGIN
    RETURN IsLetter (t) OR IsDigit (t);
  END IsLetterOrDigit;

PROCEDURE IsUpperCase (t: T): BOOLEAN =
  VAR p: Ptr;
  BEGIN
    p := BSearch (t, ADR (tolower3), NUMBER (tolower3) DIV 3, 3);
    IF p # NIL AND p^ <= ORD (t) AND
      ORD (t) <= LOOPHOLE(p + ADRSIZE (Ord), Ptr)^ THEN
      RETURN TRUE;
    END;
    p := BSearch (t, ADR (tolower2), NUMBER (tolower2) DIV 2, 2);
    IF p # NIL AND p^ = ORD (t) THEN RETURN TRUE END;
    RETURN FALSE;
  END IsUpperCase;

PROCEDURE IsLowerCase (t: T): BOOLEAN =
  VAR p: Ptr;
  BEGIN
    p := BSearch (t, ADR (toupper3), NUMBER (toupper3) DIV 3, 3);
    IF p # NIL AND p^ <= ORD (t) AND
      ORD (t) <= LOOPHOLE(p + ADRSIZE (Ord), Ptr)^ THEN
      RETURN TRUE;
    END;
    p := BSearch (t, ADR (toupper2), NUMBER (toupper2) DIV 2, 2);
    IF p # NIL AND p^ = ORD (t) THEN RETURN TRUE END;
    RETURN FALSE;
  END IsLowerCase;

PROCEDURE IsTitleCase (t: T): BOOLEAN =
  BEGIN
    RETURN IsLowerCase (t) AND IsUpperCase (t);
  END IsTitleCase;

PROCEDURE ToUpperCase (t: T): T =
  VAR p := BSearch (t, ADR (toupper3), NUMBER (toupper3) DIV 3, 3);
  BEGIN
    IF p # NIL AND p^ <= ORD (t) AND
      ORD (t) <= LOOPHOLE(p + ADRSIZE (Ord), Ptr)^ THEN
      RETURN VAL (ORD (t) + LOOPHOLE(p + 2 * ADRSIZE (Ord), Ptr)^ - 500, T);
    END;
    p := BSearch (t, ADR (toupper2), NUMBER (toupper2) DIV 2, 2);
    IF p # NIL AND ORD (t) = p^ THEN
      RETURN VAL (ORD (t) + LOOPHOLE(p + ADRSIZE (Ord), Ptr)^ - 500, T);
    END;
    RETURN t;
  END ToUpperCase;

PROCEDURE ToLowerCase (t: T): T =
  VAR p := BSearch (t, ADR (tolower3), NUMBER (tolower3) DIV 3, 3);
  BEGIN
    IF p # NIL AND p^ <= ORD (t) AND
      ORD (t) <= LOOPHOLE(p + ADRSIZE (Ord), Ptr)^ THEN
      RETURN VAL (ORD (t) + LOOPHOLE(p + 2 * ADRSIZE (Ord), Ptr)^ - 500, T);
    END;
    p := BSearch (t, ADR (tolower2), NUMBER (tolower2) DIV 2, 2);
    IF p # NIL AND p^ = ORD (t) THEN
      RETURN VAL (ORD (t) + LOOPHOLE(p + ADRSIZE (Ord), Ptr)^ - 500, T);
    END;
    RETURN t;
  END ToLowerCase;

PROCEDURE ToTitleCase (t: T): T =
  VAR p := BSearch (t, ADR (totitle2), NUMBER (totitle2) DIV 2, 2);
  BEGIN
    IF p # NIL AND p^ = ORD (t) THEN
      RETURN VAL (ORD (t) + LOOPHOLE(p + ADRSIZE (Ord), Ptr)^ - 500, T);
    END;
    RETURN t;
  END ToTitleCase;

PROCEDURE ToDigitValue (t: T): CARDINAL =
  VAR p := BSearch (t, ADR (digit2), NUMBER (digit2) DIV 2, 2);
  BEGIN
    IF p # NIL AND p^ <= ORD (t) AND
      ORD (t) <= LOOPHOLE(p + ADRSIZE (Ord), Ptr)^ THEN
      IF p^ = 16_0BE7 OR p^ = 16_1369 THEN
        (* Tamils and Ethiopians have no zero digit *)
        RETURN ORD (t) - p^ + 1;
      ELSE
        RETURN ORD (t) - p^;
      END;
    ELSE
      RETURN LAST (CARDINAL);
    END;
  END ToDigitValue;
===========================================================================*} * LOCAL PROCEDURES {*===========================================================================

---------------------------------------------------------------------------*} * BSearch - Binary Search of a Codepoint Range Table * Arguments: t - wide character * r - pointer to range tuple table * n - nbr of tuple entries * a - tuple arity * Returns: ptr - Pointer to tuple or NIL {*---------------------------------------------------------------------------

PROCEDURE BSearch (c: T;  r: Ptr;  n, a: INTEGER): Ptr =
  VAR tsize := a * ADRSIZE (Ord);  p: Ptr;  m: INTEGER;
  BEGIN
    WHILE n > 1 DO
      m := n DIV 2;
      p := r + m * tsize;
      IF ORD (c) >= p^ THEN
        r := p;
        n := n - m;
      ELSE
        n := m;
      END;
    END;
    IF n > 0 AND ORD (c) >= r^ THEN RETURN r END;
    RETURN NIL;
  END BSearch;

BEGIN
END Unicode.
vi: set ai sw=2 ts=2 tw=80: