comparison src/mbyte.c @ 2063:1378bc45ebe5 v7.2.348

updated for version 7.2.348 Problem: Unicode double-width characters are not up-to date. Solution: Produce the double-width table like the others.
author Bram Moolenaar <bram@zimbu.org>
date Wed, 27 Jan 2010 18:29:26 +0100
parents d5867fd6b2b7
children 7c8c7c95a865
comparison
equal deleted inserted replaced
2062:dae4cd29a0b7 2063:1378bc45ebe5
1198 */ 1198 */
1199 int 1199 int
1200 utf_char2cells(c) 1200 utf_char2cells(c)
1201 int c; 1201 int c;
1202 { 1202 {
1203 /* Sorted list of non-overlapping intervals of East Asian double width
1204 * characters, generated with ../runtime/tools/unicode.vim. */
1205 static struct interval doublewidth[] =
1206 {
1207 {0x1100, 0x115f},
1208 {0x11a3, 0x11a7},
1209 {0x11fa, 0x11ff},
1210 {0x2329, 0x232a},
1211 {0x2e80, 0x2e99},
1212 {0x2e9b, 0x2ef3},
1213 {0x2f00, 0x2fd5},
1214 {0x2ff0, 0x2ffb},
1215 {0x3000, 0x3029},
1216 {0x3030, 0x303e},
1217 {0x3041, 0x3096},
1218 {0x309b, 0x30ff},
1219 {0x3105, 0x312d},
1220 {0x3131, 0x318e},
1221 {0x3190, 0x31b7},
1222 {0x31c0, 0x31e3},
1223 {0x31f0, 0x321e},
1224 {0x3220, 0x3247},
1225 {0x3250, 0x32fe},
1226 {0x3300, 0x4dbf},
1227 {0x4e00, 0xa48c},
1228 {0xa490, 0xa4c6},
1229 {0xa960, 0xa97c},
1230 {0xac00, 0xd7a3},
1231 {0xd7b0, 0xd7c6},
1232 {0xd7cb, 0xd7fb},
1233 {0xf900, 0xfaff},
1234 {0xfe10, 0xfe19},
1235 {0xfe30, 0xfe52},
1236 {0xfe54, 0xfe66},
1237 {0xfe68, 0xfe6b},
1238 {0xff01, 0xff60},
1239 {0xffe0, 0xffe6},
1240 {0x1f200, 0x1f200},
1241 {0x1f210, 0x1f231},
1242 {0x1f240, 0x1f248},
1243 {0x20000, 0x2fffd},
1244 {0x30000, 0x3fffd}
1245 };
1203 /* Sorted list of non-overlapping intervals of East Asian Ambiguous 1246 /* Sorted list of non-overlapping intervals of East Asian Ambiguous
1204 * characters, generated with ../runtime/tools/unicode.vim. */ 1247 * characters, generated with ../runtime/tools/unicode.vim. */
1205 static struct interval ambiguous[] = 1248 static struct interval ambiguous[] =
1206 { 1249 {
1207 {0x00a1, 0x00a1}, 1250 {0x00a1, 0x00a1},
1401 if (n > 1) 1444 if (n > 1)
1402 return n; 1445 return n;
1403 #else 1446 #else
1404 if (!utf_printable(c)) 1447 if (!utf_printable(c))
1405 return 6; /* unprintable, displays <xxxx> */ 1448 return 6; /* unprintable, displays <xxxx> */
1406 if (c >= 0x1100 1449 if (intable(doublewidth, sizeof(doublewidth), c))
1407 && (c <= 0x115f /* Hangul Jamo */
1408 || c == 0x2329
1409 || c == 0x232a
1410 || (c >= 0x2e80 && c <= 0xa4cf
1411 && c != 0x303f) /* CJK ... Yi */
1412 || (c >= 0xac00 && c <= 0xd7a3) /* Hangul Syllables */
1413 || (c >= 0xf900 && c <= 0xfaff) /* CJK Compatibility
1414 Ideographs */
1415 || (c >= 0xfe30 && c <= 0xfe6f) /* CJK Compatibility Forms */
1416 || (c >= 0xff00 && c <= 0xff60) /* Fullwidth Forms */
1417 || (c >= 0xffe0 && c <= 0xffe6)
1418 || (c >= 0x20000 && c <= 0x2fffd)
1419 || (c >= 0x30000 && c <= 0x3fffd)))
1420 return 2; 1450 return 2;
1421 #endif 1451 #endif
1422 } 1452 }
1423 1453
1424 /* Characters below 0x100 are influenced by 'isprint' option */ 1454 /* Characters below 0x100 are influenced by 'isprint' option */