run $EDITOR on input/query ending with backslash
[diohsc.git] / WCWidth.hs
blob8dfd18671aa7f9398b498e322d3eedfa5b8280d0
1 -- Adapted from a pure haskell port of wcwidth by agentm, released under the
2 -- "Unlicense" licence, taken from:
3 -- https://raw.githubusercontent.com/agentm/project-m36/master/src/lib/ProjectM36/WCWidth.hs
5 {-# LANGUAGE Safe #-}
7 module WCWidth (wcwidth) where
8 import Data.Char
9 import Data.Set.Range
11 wIDEEASTASIAN :: RangeSet Int
12 wIDEEASTASIAN = foldr insertRange empty [
13 (0x1100, 0x115f), -- Hangul Choseong Kiyeok ..Hangul Choseong Filler
14 (0x231a, 0x231b), -- Watch ..Hourglass
15 (0x2329, 0x232a), -- Left-pointing Angle Brac..Right-pointing Angle Bra
16 (0x23e9, 0x23ec), -- Black Right-pointing Dou..Black Down-pointing Doub
17 (0x23f0, 0x23f0), -- Alarm Clock ..Alarm Clock
18 (0x23f3, 0x23f3), -- Hourglass With Flowing S..Hourglass With Flowing S
19 (0x25fd, 0x25fe), -- White Medium Small Squar..Black Medium Small Squar
20 (0x2614, 0x2615), -- Umbrella With Rain Drops..Hot Beverage
21 (0x2648, 0x2653), -- Aries ..Pisces
22 (0x267f, 0x267f), -- Wheelchair Symbol ..Wheelchair Symbol
23 (0x2693, 0x2693), -- Anchor ..Anchor
24 (0x26a1, 0x26a1), -- High Voltage Sign ..High Voltage Sign
25 (0x26aa, 0x26ab), -- Medium White Circle ..Medium Black Circle
26 (0x26bd, 0x26be), -- Soccer Ball ..Baseball
27 (0x26c4, 0x26c5), -- Snowman Without Snow ..Sun Behind Cloud
28 (0x26ce, 0x26ce), -- Ophiuchus ..Ophiuchus
29 (0x26d4, 0x26d4), -- No Entry ..No Entry
30 (0x26ea, 0x26ea), -- Church ..Church
31 (0x26f2, 0x26f3), -- Fountain ..Flag In Hole
32 (0x26f5, 0x26f5), -- Sailboat ..Sailboat
33 (0x26fa, 0x26fa), -- Tent ..Tent
34 (0x26fd, 0x26fd), -- Fuel Pump ..Fuel Pump
35 (0x2705, 0x2705), -- White Heavy Check Mark ..White Heavy Check Mark
36 (0x270a, 0x270b), -- Raised Fist ..Raised Hand
37 (0x2728, 0x2728), -- Sparkles ..Sparkles
38 (0x274c, 0x274c), -- Cross Mark ..Cross Mark
39 (0x274e, 0x274e), -- Negative Squared Cross M..Negative Squared Cross M
40 (0x2753, 0x2755), -- Black Question Mark Orna..White Exclamation Mark O
41 (0x2757, 0x2757), -- Heavy Exclamation Mark S..Heavy Exclamation Mark S
42 (0x2795, 0x2797), -- Heavy Plus Sign ..Heavy Division Sign
43 (0x27b0, 0x27b0), -- Curly Loop ..Curly Loop
44 (0x27bf, 0x27bf), -- Double Curly Loop ..Double Curly Loop
45 (0x2b1b, 0x2b1c), -- Black Large Square ..White Large Square
46 (0x2b50, 0x2b50), -- White Medium Star ..White Medium Star
47 (0x2b55, 0x2b55), -- Heavy Large Circle ..Heavy Large Circle
48 (0x2e80, 0x2e99), -- Cjk Radical Repeat ..Cjk Radical Rap
49 (0x2e9b, 0x2ef3), -- Cjk Radical Choke ..Cjk Radical C-simplified
50 (0x2f00, 0x2fd5), -- Kangxi Radical One ..Kangxi Radical Flute
51 (0x2ff0, 0x2ffb), -- Ideographic Description ..Ideographic Description
52 (0x3000, 0x303e), -- Ideographic Space ..Ideographic Variation In
53 (0x3041, 0x3096), -- Hiragana Letter Small A ..Hiragana Letter Small Ke
54 (0x3099, 0x30ff), -- Combining Katakana-hirag..Katakana Digraph Koto
55 (0x3105, 0x312d), -- Bopomofo Letter B ..Bopomofo Letter Ih
56 (0x3131, 0x318e), -- Hangul Letter Kiyeok ..Hangul Letter Araeae
57 (0x3190, 0x31ba), -- Ideographic Annotation L..Bopomofo Letter Zy
58 (0x31c0, 0x31e3), -- Cjk Stroke T ..Cjk Stroke Q
59 (0x31f0, 0x321e), -- Katakana Letter Small Ku..Parenthesized Korean Cha
60 (0x3220, 0x3247), -- Parenthesized Ideograph ..Circled Ideograph Koto
61 (0x3250, 0x32fe), -- Partnership Sign ..Circled Katakana Wo
62 (0x3300, 0x4dbf), -- Square Apaato ..
63 (0x4e00, 0xa48c), -- Cjk Unified Ideograph-4e..Yi Syllable Yyr
64 (0xa490, 0xa4c6), -- Yi Radical Qot ..Yi Radical Ke
65 (0xa960, 0xa97c), -- Hangul Choseong Tikeut-m..Hangul Choseong Ssangyeo
66 (0xac00, 0xd7a3), -- Hangul Syllable Ga ..Hangul Syllable Hih
67 (0xf900, 0xfaff), -- Cjk Compatibility Ideogr..
68 (0xfe10, 0xfe19), -- Presentation Form For Ve..Presentation Form For Ve
69 (0xfe30, 0xfe52), -- Presentation Form For Ve..Small Full Stop
70 (0xfe54, 0xfe66), -- Small Semicolon ..Small Equals Sign
71 (0xfe68, 0xfe6b), -- Small Reverse Solidus ..Small Commercial At
72 (0xff01, 0xff60), -- Fullwidth Exclamation Ma..Fullwidth Right White Pa
73 (0xffe0, 0xffe6), -- Fullwidth Cent Sign ..Fullwidth Won Sign
74 (0x16fe0, 0x16fe0), -- (nil) ..
75 (0x17000, 0x187ec), -- (nil) ..
76 (0x18800, 0x18af2), -- (nil) ..
77 (0x1b000, 0x1b001), -- Katakana Letter Archaic ..Hiragana Letter Archaic
78 (0x1f004, 0x1f004), -- Mahjong Tile Red Dragon ..Mahjong Tile Red Dragon
79 (0x1f0cf, 0x1f0cf), -- Playing Card Black Joker..Playing Card Black Joker
80 (0x1f18e, 0x1f18e), -- Negative Squared Ab ..Negative Squared Ab
81 (0x1f191, 0x1f19a), -- Squared Cl ..Squared Vs
82 (0x1f200, 0x1f202), -- Square Hiragana Hoka ..Squared Katakana Sa
83 (0x1f210, 0x1f23b), -- Squared Cjk Unified Ideo..
84 (0x1f240, 0x1f248), -- Tortoise Shell Bracketed..Tortoise Shell Bracketed
85 (0x1f250, 0x1f251), -- Circled Ideograph Advant..Circled Ideograph Accept
86 (0x1f300, 0x1f320), -- Cyclone ..Shooting Star
87 (0x1f32d, 0x1f335), -- Hot Dog ..Cactus
88 (0x1f337, 0x1f37c), -- Tulip ..Baby Bottle
89 (0x1f37e, 0x1f393), -- Bottle With Popping Cork..Graduation Cap
90 (0x1f3a0, 0x1f3ca), -- Carousel Horse ..Swimmer
91 (0x1f3cf, 0x1f3d3), -- Cricket Bat And Ball ..Table Tennis Paddle And
92 (0x1f3e0, 0x1f3f0), -- House Building ..European Castle
93 (0x1f3f4, 0x1f3f4), -- Waving Black Flag ..Waving Black Flag
94 (0x1f3f8, 0x1f43e), -- Badminton Racquet And Sh..Paw Prints
95 (0x1f440, 0x1f440), -- Eyes ..Eyes
96 (0x1f442, 0x1f4fc), -- Ear ..Videocassette
97 (0x1f4ff, 0x1f53d), -- Prayer Beads ..Down-pointing Small Red
98 (0x1f54b, 0x1f54e), -- Kaaba ..Menorah With Nine Branch
99 (0x1f550, 0x1f567), -- Clock Face One Oclock ..Clock Face Twelve-thirty
100 (0x1f57a, 0x1f57a), -- (nil) ..
101 (0x1f595, 0x1f596), -- Reversed Hand With Middl..Raised Hand With Part Be
102 (0x1f5a4, 0x1f5a4), -- (nil) ..
103 (0x1f5fb, 0x1f64f), -- Mount Fuji ..Person With Folded Hands
104 (0x1f680, 0x1f6c5), -- Rocket ..Left Luggage
105 (0x1f6cc, 0x1f6cc), -- Sleeping Accommodation ..Sleeping Accommodation
106 (0x1f6d0, 0x1f6d2), -- Place Of Worship ..
107 (0x1f6eb, 0x1f6ec), -- Airplane Departure ..Airplane Arriving
108 (0x1f6f4, 0x1f6f6), -- (nil) ..
109 (0x1f910, 0x1f91e), -- Zipper-mouth Face ..
110 (0x1f920, 0x1f927), -- (nil) ..
111 (0x1f930, 0x1f930), -- (nil) ..
112 (0x1f933, 0x1f93e), -- (nil) ..
113 (0x1f940, 0x1f94b), -- (nil) ..
114 (0x1f950, 0x1f95e), -- (nil) ..
115 (0x1f980, 0x1f991), -- Crab ..
116 (0x1f9c0, 0x1f9c0), -- Cheese Wedge ..Cheese Wedge
117 (0x20000, 0x2fffd), -- Cjk Unified Ideograph-20..
118 (0x30000, 0x3fffd) -- (nil) ..
121 zEROWIDTH :: RangeSet Int
122 zEROWIDTH = foldr insertRange empty [
123 (0x0300, 0x036f), -- Combining Grave Accent ..Combining Latin Small Le
124 (0x0483, 0x0489), -- Combining Cyrillic Titlo..Combining Cyrillic Milli
125 (0x0591, 0x05bd), -- Hebrew Accent Etnahta ..Hebrew Point Meteg
126 (0x05bf, 0x05bf), -- Hebrew Point Rafe ..Hebrew Point Rafe
127 (0x05c1, 0x05c2), -- Hebrew Point Shin Dot ..Hebrew Point Sin Dot
128 (0x05c4, 0x05c5), -- Hebrew Mark Upper Dot ..Hebrew Mark Lower Dot
129 (0x05c7, 0x05c7), -- Hebrew Point Qamats Qata..Hebrew Point Qamats Qata
130 (0x0610, 0x061a), -- Arabic Sign Sallallahou ..Arabic Small Kasra
131 (0x064b, 0x065f), -- Arabic Fathatan ..Arabic Wavy Hamza Below
132 (0x0670, 0x0670), -- Arabic Letter Superscrip..Arabic Letter Superscrip
133 (0x06d6, 0x06dc), -- Arabic Small High Ligatu..Arabic Small High Seen
134 (0x06df, 0x06e4), -- Arabic Small High Rounde..Arabic Small High Madda
135 (0x06e7, 0x06e8), -- Arabic Small High Yeh ..Arabic Small High Noon
136 (0x06ea, 0x06ed), -- Arabic Empty Centre Low ..Arabic Small Low Meem
137 (0x0711, 0x0711), -- Syriac Letter Superscrip..Syriac Letter Superscrip
138 (0x0730, 0x074a), -- Syriac Pthaha Above ..Syriac Barrekh
139 (0x07a6, 0x07b0), -- Thaana Abafili ..Thaana Sukun
140 (0x07eb, 0x07f3), -- Nko Combining Short High..Nko Combining Double Dot
141 (0x0816, 0x0819), -- Samaritan Mark In ..Samaritan Mark Dagesh
142 (0x081b, 0x0823), -- Samaritan Mark Epentheti..Samaritan Vowel Sign A
143 (0x0825, 0x0827), -- Samaritan Vowel Sign Sho..Samaritan Vowel Sign U
144 (0x0829, 0x082d), -- Samaritan Vowel Sign Lon..Samaritan Mark Nequdaa
145 (0x0859, 0x085b), -- Mandaic Affrication Mark..Mandaic Gemination Mark
146 (0x08d4, 0x08e1), -- (nil) ..
147 (0x08e3, 0x0902), -- Arabic Turned Damma Belo..Devanagari Sign Anusvara
148 (0x093a, 0x093a), -- Devanagari Vowel Sign Oe..Devanagari Vowel Sign Oe
149 (0x093c, 0x093c), -- Devanagari Sign Nukta ..Devanagari Sign Nukta
150 (0x0941, 0x0948), -- Devanagari Vowel Sign U ..Devanagari Vowel Sign Ai
151 (0x094d, 0x094d), -- Devanagari Sign Virama ..Devanagari Sign Virama
152 (0x0951, 0x0957), -- Devanagari Stress Sign U..Devanagari Vowel Sign Uu
153 (0x0962, 0x0963), -- Devanagari Vowel Sign Vo..Devanagari Vowel Sign Vo
154 (0x0981, 0x0981), -- Bengali Sign Candrabindu..Bengali Sign Candrabindu
155 (0x09bc, 0x09bc), -- Bengali Sign Nukta ..Bengali Sign Nukta
156 (0x09c1, 0x09c4), -- Bengali Vowel Sign U ..Bengali Vowel Sign Vocal
157 (0x09cd, 0x09cd), -- Bengali Sign Virama ..Bengali Sign Virama
158 (0x09e2, 0x09e3), -- Bengali Vowel Sign Vocal..Bengali Vowel Sign Vocal
159 (0x0a01, 0x0a02), -- Gurmukhi Sign Adak Bindi..Gurmukhi Sign Bindi
160 (0x0a3c, 0x0a3c), -- Gurmukhi Sign Nukta ..Gurmukhi Sign Nukta
161 (0x0a41, 0x0a42), -- Gurmukhi Vowel Sign U ..Gurmukhi Vowel Sign Uu
162 (0x0a47, 0x0a48), -- Gurmukhi Vowel Sign Ee ..Gurmukhi Vowel Sign Ai
163 (0x0a4b, 0x0a4d), -- Gurmukhi Vowel Sign Oo ..Gurmukhi Sign Virama
164 (0x0a51, 0x0a51), -- Gurmukhi Sign Udaat ..Gurmukhi Sign Udaat
165 (0x0a70, 0x0a71), -- Gurmukhi Tippi ..Gurmukhi Addak
166 (0x0a75, 0x0a75), -- Gurmukhi Sign Yakash ..Gurmukhi Sign Yakash
167 (0x0a81, 0x0a82), -- Gujarati Sign Candrabind..Gujarati Sign Anusvara
168 (0x0abc, 0x0abc), -- Gujarati Sign Nukta ..Gujarati Sign Nukta
169 (0x0ac1, 0x0ac5), -- Gujarati Vowel Sign U ..Gujarati Vowel Sign Cand
170 (0x0ac7, 0x0ac8), -- Gujarati Vowel Sign E ..Gujarati Vowel Sign Ai
171 (0x0acd, 0x0acd), -- Gujarati Sign Virama ..Gujarati Sign Virama
172 (0x0ae2, 0x0ae3), -- Gujarati Vowel Sign Voca..Gujarati Vowel Sign Voca
173 (0x0b01, 0x0b01), -- Oriya Sign Candrabindu ..Oriya Sign Candrabindu
174 (0x0b3c, 0x0b3c), -- Oriya Sign Nukta ..Oriya Sign Nukta
175 (0x0b3f, 0x0b3f), -- Oriya Vowel Sign I ..Oriya Vowel Sign I
176 (0x0b41, 0x0b44), -- Oriya Vowel Sign U ..Oriya Vowel Sign Vocalic
177 (0x0b4d, 0x0b4d), -- Oriya Sign Virama ..Oriya Sign Virama
178 (0x0b56, 0x0b56), -- Oriya Ai Length Mark ..Oriya Ai Length Mark
179 (0x0b62, 0x0b63), -- Oriya Vowel Sign Vocalic..Oriya Vowel Sign Vocalic
180 (0x0b82, 0x0b82), -- Tamil Sign Anusvara ..Tamil Sign Anusvara
181 (0x0bc0, 0x0bc0), -- Tamil Vowel Sign Ii ..Tamil Vowel Sign Ii
182 (0x0bcd, 0x0bcd), -- Tamil Sign Virama ..Tamil Sign Virama
183 (0x0c00, 0x0c00), -- Telugu Sign Combining Ca..Telugu Sign Combining Ca
184 (0x0c3e, 0x0c40), -- Telugu Vowel Sign Aa ..Telugu Vowel Sign Ii
185 (0x0c46, 0x0c48), -- Telugu Vowel Sign E ..Telugu Vowel Sign Ai
186 (0x0c4a, 0x0c4d), -- Telugu Vowel Sign O ..Telugu Sign Virama
187 (0x0c55, 0x0c56), -- Telugu Length Mark ..Telugu Ai Length Mark
188 (0x0c62, 0x0c63), -- Telugu Vowel Sign Vocali..Telugu Vowel Sign Vocali
189 (0x0c81, 0x0c81), -- Kannada Sign Candrabindu..Kannada Sign Candrabindu
190 (0x0cbc, 0x0cbc), -- Kannada Sign Nukta ..Kannada Sign Nukta
191 (0x0cbf, 0x0cbf), -- Kannada Vowel Sign I ..Kannada Vowel Sign I
192 (0x0cc6, 0x0cc6), -- Kannada Vowel Sign E ..Kannada Vowel Sign E
193 (0x0ccc, 0x0ccd), -- Kannada Vowel Sign Au ..Kannada Sign Virama
194 (0x0ce2, 0x0ce3), -- Kannada Vowel Sign Vocal..Kannada Vowel Sign Vocal
195 (0x0d01, 0x0d01), -- Malayalam Sign Candrabin..Malayalam Sign Candrabin
196 (0x0d41, 0x0d44), -- Malayalam Vowel Sign U ..Malayalam Vowel Sign Voc
197 (0x0d4d, 0x0d4d), -- Malayalam Sign Virama ..Malayalam Sign Virama
198 (0x0d62, 0x0d63), -- Malayalam Vowel Sign Voc..Malayalam Vowel Sign Voc
199 (0x0dca, 0x0dca), -- Sinhala Sign Al-lakuna ..Sinhala Sign Al-lakuna
200 (0x0dd2, 0x0dd4), -- Sinhala Vowel Sign Ketti..Sinhala Vowel Sign Ketti
201 (0x0dd6, 0x0dd6), -- Sinhala Vowel Sign Diga ..Sinhala Vowel Sign Diga
202 (0x0e31, 0x0e31), -- Thai Character Mai Han-a..Thai Character Mai Han-a
203 (0x0e34, 0x0e3a), -- Thai Character Sara I ..Thai Character Phinthu
204 (0x0e47, 0x0e4e), -- Thai Character Maitaikhu..Thai Character Yamakkan
205 (0x0eb1, 0x0eb1), -- Lao Vowel Sign Mai Kan ..Lao Vowel Sign Mai Kan
206 (0x0eb4, 0x0eb9), -- Lao Vowel Sign I ..Lao Vowel Sign Uu
207 (0x0ebb, 0x0ebc), -- Lao Vowel Sign Mai Kon ..Lao Semivowel Sign Lo
208 (0x0ec8, 0x0ecd), -- Lao Tone Mai Ek ..Lao Niggahita
209 (0x0f18, 0x0f19), -- Tibetan Astrological Sig..Tibetan Astrological Sig
210 (0x0f35, 0x0f35), -- Tibetan Mark Ngas Bzung ..Tibetan Mark Ngas Bzung
211 (0x0f37, 0x0f37), -- Tibetan Mark Ngas Bzung ..Tibetan Mark Ngas Bzung
212 (0x0f39, 0x0f39), -- Tibetan Mark Tsa -phru ..Tibetan Mark Tsa -phru
213 (0x0f71, 0x0f7e), -- Tibetan Vowel Sign Aa ..Tibetan Sign Rjes Su Nga
214 (0x0f80, 0x0f84), -- Tibetan Vowel Sign Rever..Tibetan Mark Halanta
215 (0x0f86, 0x0f87), -- Tibetan Sign Lci Rtags ..Tibetan Sign Yang Rtags
216 (0x0f8d, 0x0f97), -- Tibetan Subjoined Sign L..Tibetan Subjoined Letter
217 (0x0f99, 0x0fbc), -- Tibetan Subjoined Letter..Tibetan Subjoined Letter
218 (0x0fc6, 0x0fc6), -- Tibetan Symbol Padma Gda..Tibetan Symbol Padma Gda
219 (0x102d, 0x1030), -- Myanmar Vowel Sign I ..Myanmar Vowel Sign Uu
220 (0x1032, 0x1037), -- Myanmar Vowel Sign Ai ..Myanmar Sign Dot Below
221 (0x1039, 0x103a), -- Myanmar Sign Virama ..Myanmar Sign Asat
222 (0x103d, 0x103e), -- Myanmar Consonant Sign M..Myanmar Consonant Sign M
223 (0x1058, 0x1059), -- Myanmar Vowel Sign Vocal..Myanmar Vowel Sign Vocal
224 (0x105e, 0x1060), -- Myanmar Consonant Sign M..Myanmar Consonant Sign M
225 (0x1071, 0x1074), -- Myanmar Vowel Sign Geba ..Myanmar Vowel Sign Kayah
226 (0x1082, 0x1082), -- Myanmar Consonant Sign S..Myanmar Consonant Sign S
227 (0x1085, 0x1086), -- Myanmar Vowel Sign Shan ..Myanmar Vowel Sign Shan
228 (0x108d, 0x108d), -- Myanmar Sign Shan Counci..Myanmar Sign Shan Counci
229 (0x109d, 0x109d), -- Myanmar Vowel Sign Aiton..Myanmar Vowel Sign Aiton
230 (0x135d, 0x135f), -- Ethiopic Combining Gemin..Ethiopic Combining Gemin
231 (0x1712, 0x1714), -- Tagalog Vowel Sign I ..Tagalog Sign Virama
232 (0x1732, 0x1734), -- Hanunoo Vowel Sign I ..Hanunoo Sign Pamudpod
233 (0x1752, 0x1753), -- Buhid Vowel Sign I ..Buhid Vowel Sign U
234 (0x1772, 0x1773), -- Tagbanwa Vowel Sign I ..Tagbanwa Vowel Sign U
235 (0x17b4, 0x17b5), -- Khmer Vowel Inherent Aq ..Khmer Vowel Inherent Aa
236 (0x17b7, 0x17bd), -- Khmer Vowel Sign I ..Khmer Vowel Sign Ua
237 (0x17c6, 0x17c6), -- Khmer Sign Nikahit ..Khmer Sign Nikahit
238 (0x17c9, 0x17d3), -- Khmer Sign Muusikatoan ..Khmer Sign Bathamasat
239 (0x17dd, 0x17dd), -- Khmer Sign Atthacan ..Khmer Sign Atthacan
240 (0x180b, 0x180d), -- Mongolian Free Variation..Mongolian Free Variation
241 (0x1885, 0x1886), -- Mongolian Letter Ali Gal..Mongolian Letter Ali Gal
242 (0x18a9, 0x18a9), -- Mongolian Letter Ali Gal..Mongolian Letter Ali Gal
243 (0x1920, 0x1922), -- Limbu Vowel Sign A ..Limbu Vowel Sign U
244 (0x1927, 0x1928), -- Limbu Vowel Sign E ..Limbu Vowel Sign O
245 (0x1932, 0x1932), -- Limbu Small Letter Anusv..Limbu Small Letter Anusv
246 (0x1939, 0x193b), -- Limbu Sign Mukphreng ..Limbu Sign Sa-i
247 (0x1a17, 0x1a18), -- Buginese Vowel Sign I ..Buginese Vowel Sign U
248 (0x1a1b, 0x1a1b), -- Buginese Vowel Sign Ae ..Buginese Vowel Sign Ae
249 (0x1a56, 0x1a56), -- Tai Tham Consonant Sign ..Tai Tham Consonant Sign
250 (0x1a58, 0x1a5e), -- Tai Tham Sign Mai Kang L..Tai Tham Consonant Sign
251 (0x1a60, 0x1a60), -- Tai Tham Sign Sakot ..Tai Tham Sign Sakot
252 (0x1a62, 0x1a62), -- Tai Tham Vowel Sign Mai ..Tai Tham Vowel Sign Mai
253 (0x1a65, 0x1a6c), -- Tai Tham Vowel Sign I ..Tai Tham Vowel Sign Oa B
254 (0x1a73, 0x1a7c), -- Tai Tham Vowel Sign Oa A..Tai Tham Sign Khuen-lue
255 (0x1a7f, 0x1a7f), -- Tai Tham Combining Crypt..Tai Tham Combining Crypt
256 (0x1ab0, 0x1abe), -- Combining Doubled Circum..Combining Parentheses Ov
257 (0x1b00, 0x1b03), -- Balinese Sign Ulu Ricem ..Balinese Sign Surang
258 (0x1b34, 0x1b34), -- Balinese Sign Rerekan ..Balinese Sign Rerekan
259 (0x1b36, 0x1b3a), -- Balinese Vowel Sign Ulu ..Balinese Vowel Sign Ra R
260 (0x1b3c, 0x1b3c), -- Balinese Vowel Sign La L..Balinese Vowel Sign La L
261 (0x1b42, 0x1b42), -- Balinese Vowel Sign Pepe..Balinese Vowel Sign Pepe
262 (0x1b6b, 0x1b73), -- Balinese Musical Symbol ..Balinese Musical Symbol
263 (0x1b80, 0x1b81), -- Sundanese Sign Panyecek ..Sundanese Sign Panglayar
264 (0x1ba2, 0x1ba5), -- Sundanese Consonant Sign..Sundanese Vowel Sign Pan
265 (0x1ba8, 0x1ba9), -- Sundanese Vowel Sign Pam..Sundanese Vowel Sign Pan
266 (0x1bab, 0x1bad), -- Sundanese Sign Virama ..Sundanese Consonant Sign
267 (0x1be6, 0x1be6), -- Batak Sign Tompi ..Batak Sign Tompi
268 (0x1be8, 0x1be9), -- Batak Vowel Sign Pakpak ..Batak Vowel Sign Ee
269 (0x1bed, 0x1bed), -- Batak Vowel Sign Karo O ..Batak Vowel Sign Karo O
270 (0x1bef, 0x1bf1), -- Batak Vowel Sign U For S..Batak Consonant Sign H
271 (0x1c2c, 0x1c33), -- Lepcha Vowel Sign E ..Lepcha Consonant Sign T
272 (0x1c36, 0x1c37), -- Lepcha Sign Ran ..Lepcha Sign Nukta
273 (0x1cd0, 0x1cd2), -- Vedic Tone Karshana ..Vedic Tone Prenkha
274 (0x1cd4, 0x1ce0), -- Vedic Sign Yajurvedic Mi..Vedic Tone Rigvedic Kash
275 (0x1ce2, 0x1ce8), -- Vedic Sign Visarga Svari..Vedic Sign Visarga Anuda
276 (0x1ced, 0x1ced), -- Vedic Sign Tiryak ..Vedic Sign Tiryak
277 (0x1cf4, 0x1cf4), -- Vedic Tone Candra Above ..Vedic Tone Candra Above
278 (0x1cf8, 0x1cf9), -- Vedic Tone Ring Above ..Vedic Tone Double Ring A
279 (0x1dc0, 0x1df5), -- Combining Dotted Grave A..Combining Up Tack Above
280 (0x1dfb, 0x1dff), -- (nil) ..Combining Right Arrowhea
281 (0x20d0, 0x20f0), -- Combining Left Harpoon A..Combining Asterisk Above
282 (0x2cef, 0x2cf1), -- Coptic Combining Ni Abov..Coptic Combining Spiritu
283 (0x2d7f, 0x2d7f), -- Tifinagh Consonant Joine..Tifinagh Consonant Joine
284 (0x2de0, 0x2dff), -- Combining Cyrillic Lette..Combining Cyrillic Lette
285 (0x302a, 0x302d), -- Ideographic Level Tone M..Ideographic Entering Ton
286 (0x3099, 0x309a), -- Combining Katakana-hirag..Combining Katakana-hirag
287 (0xa66f, 0xa672), -- Combining Cyrillic Vzmet..Combining Cyrillic Thous
288 (0xa674, 0xa67d), -- Combining Cyrillic Lette..Combining Cyrillic Payer
289 (0xa69e, 0xa69f), -- Combining Cyrillic Lette..Combining Cyrillic Lette
290 (0xa6f0, 0xa6f1), -- Bamum Combining Mark Koq..Bamum Combining Mark Tuk
291 (0xa802, 0xa802), -- Syloti Nagri Sign Dvisva..Syloti Nagri Sign Dvisva
292 (0xa806, 0xa806), -- Syloti Nagri Sign Hasant..Syloti Nagri Sign Hasant
293 (0xa80b, 0xa80b), -- Syloti Nagri Sign Anusva..Syloti Nagri Sign Anusva
294 (0xa825, 0xa826), -- Syloti Nagri Vowel Sign ..Syloti Nagri Vowel Sign
295 (0xa8c4, 0xa8c5), -- Saurashtra Sign Virama ..
296 (0xa8e0, 0xa8f1), -- Combining Devanagari Dig..Combining Devanagari Sig
297 (0xa926, 0xa92d), -- Kayah Li Vowel Ue ..Kayah Li Tone Calya Plop
298 (0xa947, 0xa951), -- Rejang Vowel Sign I ..Rejang Consonant Sign R
299 (0xa980, 0xa982), -- Javanese Sign Panyangga ..Javanese Sign Layar
300 (0xa9b3, 0xa9b3), -- Javanese Sign Cecak Telu..Javanese Sign Cecak Telu
301 (0xa9b6, 0xa9b9), -- Javanese Vowel Sign Wulu..Javanese Vowel Sign Suku
302 (0xa9bc, 0xa9bc), -- Javanese Vowel Sign Pepe..Javanese Vowel Sign Pepe
303 (0xa9e5, 0xa9e5), -- Myanmar Sign Shan Saw ..Myanmar Sign Shan Saw
304 (0xaa29, 0xaa2e), -- Cham Vowel Sign Aa ..Cham Vowel Sign Oe
305 (0xaa31, 0xaa32), -- Cham Vowel Sign Au ..Cham Vowel Sign Ue
306 (0xaa35, 0xaa36), -- Cham Consonant Sign La ..Cham Consonant Sign Wa
307 (0xaa43, 0xaa43), -- Cham Consonant Sign Fina..Cham Consonant Sign Fina
308 (0xaa4c, 0xaa4c), -- Cham Consonant Sign Fina..Cham Consonant Sign Fina
309 (0xaa7c, 0xaa7c), -- Myanmar Sign Tai Laing T..Myanmar Sign Tai Laing T
310 (0xaab0, 0xaab0), -- Tai Viet Mai Kang ..Tai Viet Mai Kang
311 (0xaab2, 0xaab4), -- Tai Viet Vowel I ..Tai Viet Vowel U
312 (0xaab7, 0xaab8), -- Tai Viet Mai Khit ..Tai Viet Vowel Ia
313 (0xaabe, 0xaabf), -- Tai Viet Vowel Am ..Tai Viet Tone Mai Ek
314 (0xaac1, 0xaac1), -- Tai Viet Tone Mai Tho ..Tai Viet Tone Mai Tho
315 (0xaaec, 0xaaed), -- Meetei Mayek Vowel Sign ..Meetei Mayek Vowel Sign
316 (0xaaf6, 0xaaf6), -- Meetei Mayek Virama ..Meetei Mayek Virama
317 (0xabe5, 0xabe5), -- Meetei Mayek Vowel Sign ..Meetei Mayek Vowel Sign
318 (0xabe8, 0xabe8), -- Meetei Mayek Vowel Sign ..Meetei Mayek Vowel Sign
319 (0xabed, 0xabed), -- Meetei Mayek Apun Iyek ..Meetei Mayek Apun Iyek
320 (0xfb1e, 0xfb1e), -- Hebrew Point Judeo-spani..Hebrew Point Judeo-spani
321 (0xfe00, 0xfe0f), -- Variation Selector-1 ..Variation Selector-16
322 (0xfe20, 0xfe2f), -- Combining Ligature Left ..Combining Cyrillic Titlo
323 (0x101fd, 0x101fd), -- Phaistos Disc Sign Combi..Phaistos Disc Sign Combi
324 (0x102e0, 0x102e0), -- Coptic Epact Thousands M..Coptic Epact Thousands M
325 (0x10376, 0x1037a), -- Combining Old Permic Let..Combining Old Permic Let
326 (0x10a01, 0x10a03), -- Kharoshthi Vowel Sign I ..Kharoshthi Vowel Sign Vo
327 (0x10a05, 0x10a06), -- Kharoshthi Vowel Sign E ..Kharoshthi Vowel Sign O
328 (0x10a0c, 0x10a0f), -- Kharoshthi Vowel Length ..Kharoshthi Sign Visarga
329 (0x10a38, 0x10a3a), -- Kharoshthi Sign Bar Abov..Kharoshthi Sign Dot Belo
330 (0x10a3f, 0x10a3f), -- Kharoshthi Virama ..Kharoshthi Virama
331 (0x10ae5, 0x10ae6), -- Manichaean Abbreviation ..Manichaean Abbreviation
332 (0x11001, 0x11001), -- Brahmi Sign Anusvara ..Brahmi Sign Anusvara
333 (0x11038, 0x11046), -- Brahmi Vowel Sign Aa ..Brahmi Virama
334 (0x1107f, 0x11081), -- Brahmi Number Joiner ..Kaithi Sign Anusvara
335 (0x110b3, 0x110b6), -- Kaithi Vowel Sign U ..Kaithi Vowel Sign Ai
336 (0x110b9, 0x110ba), -- Kaithi Sign Virama ..Kaithi Sign Nukta
337 (0x11100, 0x11102), -- Chakma Sign Candrabindu ..Chakma Sign Visarga
338 (0x11127, 0x1112b), -- Chakma Vowel Sign A ..Chakma Vowel Sign Uu
339 (0x1112d, 0x11134), -- Chakma Vowel Sign Ai ..Chakma Maayyaa
340 (0x11173, 0x11173), -- Mahajani Sign Nukta ..Mahajani Sign Nukta
341 (0x11180, 0x11181), -- Sharada Sign Candrabindu..Sharada Sign Anusvara
342 (0x111b6, 0x111be), -- Sharada Vowel Sign U ..Sharada Vowel Sign O
343 (0x111ca, 0x111cc), -- Sharada Sign Nukta ..Sharada Extra Short Vowe
344 (0x1122f, 0x11231), -- Khojki Vowel Sign U ..Khojki Vowel Sign Ai
345 (0x11234, 0x11234), -- Khojki Sign Anusvara ..Khojki Sign Anusvara
346 (0x11236, 0x11237), -- Khojki Sign Nukta ..Khojki Sign Shadda
347 (0x1123e, 0x1123e), -- (nil) ..
348 (0x112df, 0x112df), -- Khudawadi Sign Anusvara ..Khudawadi Sign Anusvara
349 (0x112e3, 0x112ea), -- Khudawadi Vowel Sign U ..Khudawadi Sign Virama
350 (0x11300, 0x11301), -- Grantha Sign Combining A..Grantha Sign Candrabindu
351 (0x1133c, 0x1133c), -- Grantha Sign Nukta ..Grantha Sign Nukta
352 (0x11340, 0x11340), -- Grantha Vowel Sign Ii ..Grantha Vowel Sign Ii
353 (0x11366, 0x1136c), -- Combining Grantha Digit ..Combining Grantha Digit
354 (0x11370, 0x11374), -- Combining Grantha Letter..Combining Grantha Letter
355 (0x11438, 0x1143f), -- (nil) ..
356 (0x11442, 0x11444), -- (nil) ..
357 (0x11446, 0x11446), -- (nil) ..
358 (0x114b3, 0x114b8), -- Tirhuta Vowel Sign U ..Tirhuta Vowel Sign Vocal
359 (0x114ba, 0x114ba), -- Tirhuta Vowel Sign Short..Tirhuta Vowel Sign Short
360 (0x114bf, 0x114c0), -- Tirhuta Sign Candrabindu..Tirhuta Sign Anusvara
361 (0x114c2, 0x114c3), -- Tirhuta Sign Virama ..Tirhuta Sign Nukta
362 (0x115b2, 0x115b5), -- Siddham Vowel Sign U ..Siddham Vowel Sign Vocal
363 (0x115bc, 0x115bd), -- Siddham Sign Candrabindu..Siddham Sign Anusvara
364 (0x115bf, 0x115c0), -- Siddham Sign Virama ..Siddham Sign Nukta
365 (0x115dc, 0x115dd), -- Siddham Vowel Sign Alter..Siddham Vowel Sign Alter
366 (0x11633, 0x1163a), -- Modi Vowel Sign U ..Modi Vowel Sign Ai
367 (0x1163d, 0x1163d), -- Modi Sign Anusvara ..Modi Sign Anusvara
368 (0x1163f, 0x11640), -- Modi Sign Virama ..Modi Sign Ardhacandra
369 (0x116ab, 0x116ab), -- Takri Sign Anusvara ..Takri Sign Anusvara
370 (0x116ad, 0x116ad), -- Takri Vowel Sign Aa ..Takri Vowel Sign Aa
371 (0x116b0, 0x116b5), -- Takri Vowel Sign U ..Takri Vowel Sign Au
372 (0x116b7, 0x116b7), -- Takri Sign Nukta ..Takri Sign Nukta
373 (0x1171d, 0x1171f), -- Ahom Consonant Sign Medi..Ahom Consonant Sign Medi
374 (0x11722, 0x11725), -- Ahom Vowel Sign I ..Ahom Vowel Sign Uu
375 (0x11727, 0x1172b), -- Ahom Vowel Sign Aw ..Ahom Sign Killer
376 (0x11c30, 0x11c36), -- (nil) ..
377 (0x11c38, 0x11c3d), -- (nil) ..
378 (0x11c3f, 0x11c3f), -- (nil) ..
379 (0x11c92, 0x11ca7), -- (nil) ..
380 (0x11caa, 0x11cb0), -- (nil) ..
381 (0x11cb2, 0x11cb3), -- (nil) ..
382 (0x11cb5, 0x11cb6), -- (nil) ..
383 (0x16af0, 0x16af4), -- Bassa Vah Combining High..Bassa Vah Combining High
384 (0x16b30, 0x16b36), -- Pahawh Hmong Mark Cim Tu..Pahawh Hmong Mark Cim Ta
385 (0x16f8f, 0x16f92), -- Miao Tone Right ..Miao Tone Below
386 (0x1bc9d, 0x1bc9e), -- Duployan Thick Letter Se..Duployan Double Mark
387 (0x1d167, 0x1d169), -- Musical Symbol Combining..Musical Symbol Combining
388 (0x1d17b, 0x1d182), -- Musical Symbol Combining..Musical Symbol Combining
389 (0x1d185, 0x1d18b), -- Musical Symbol Combining..Musical Symbol Combining
390 (0x1d1aa, 0x1d1ad), -- Musical Symbol Combining..Musical Symbol Combining
391 (0x1d242, 0x1d244), -- Combining Greek Musical ..Combining Greek Musical
392 (0x1da00, 0x1da36), -- Signwriting Head Rim ..Signwriting Air Sucking
393 (0x1da3b, 0x1da6c), -- Signwriting Mouth Closed..Signwriting Excitement
394 (0x1da75, 0x1da75), -- Signwriting Upper Body T..Signwriting Upper Body T
395 (0x1da84, 0x1da84), -- Signwriting Location Hea..Signwriting Location Hea
396 (0x1da9b, 0x1da9f), -- Signwriting Fill Modifie..Signwriting Fill Modifie
397 (0x1daa1, 0x1daaf), -- Signwriting Rotation Mod..Signwriting Rotation Mod
398 (0x1e000, 0x1e006), -- (nil) ..
399 (0x1e008, 0x1e018), -- (nil) ..
400 (0x1e01b, 0x1e021), -- (nil) ..
401 (0x1e023, 0x1e024), -- (nil) ..
402 (0x1e026, 0x1e02a), -- (nil) ..
403 (0x1e8d0, 0x1e8d6), -- Mende Kikakui Combining ..Mende Kikakui Combining
404 (0x1e944, 0x1e94a), -- (nil) ..
405 (0xe0100, 0xe01ef) -- Variation Selector-17 ..Variation Selector-256
409 basicZero :: RangeSet Int
410 basicZero = foldr insertRange empty [
411 (0, 0),
412 (0x034f, 0x034f),
413 (0x200b, 0x200f),
414 (0x2028, 0x2029),
415 (0x202a, 0x202e),
416 (0x2060, 0x2063)
419 ctrlChars :: RangeSet Int
420 ctrlChars = foldr insertRange empty [
421 (1, 31),
422 (0x07f, 0x09F)
425 wcwidth :: Char -> Int
426 wcwidth c | queryPoint v basicZero = 0
427 | queryPoint v ctrlChars = -1
428 | queryPoint v wIDEEASTASIAN = 2
429 | queryPoint v zEROWIDTH = 0
430 | otherwise = 1
431 where v = ord c