Skip to content

Commit dd3bc82

Browse files
committed
Fix Emoji range #184
1 parent 315c8bd commit dd3bc82

File tree

1 file changed

+92
-11
lines changed

1 file changed

+92
-11
lines changed

src/mbyte.c

Lines changed: 92 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,16 +1244,8 @@ utf_char2cells(c)
12441244
static struct interval doublewidth[] =
12451245
{
12461246
{0x1100, 0x115f},
1247-
{0x2300, 0x23ff},
1248-
{0x2700, 0x2757},
1249-
{0x275d, 0x2767},
1250-
{0x2776, 0x27bf},
1251-
{0x2b00, 0x2b1c},
1252-
{0x2b1f, 0x2b29},
1253-
{0x2b2c, 0x2b2d},
1254-
{0x2b30, 0x2b55},
1255-
{0x2b90, 0x2b91},
1256-
{0x2e00, 0x2e99},
1247+
{0x2329, 0x232a},
1248+
{0x2e80, 0x2e99},
12571249
{0x2e9b, 0x2ef3},
12581250
{0x2f00, 0x2fd5},
12591251
{0x2ff0, 0x2ffb},
@@ -1279,11 +1271,98 @@ utf_char2cells(c)
12791271
{0xfe68, 0xfe6b},
12801272
{0xff01, 0xff60},
12811273
{0xffe0, 0xffe6},
1282-
{0x10000, 0x1fffd},
1274+
{0x1b000, 0x1b001},
1275+
{0x1f200, 0x1f202},
1276+
{0x1f210, 0x1f23a},
1277+
{0x1f240, 0x1f248},
1278+
{0x1f250, 0x1f251},
12831279
{0x20000, 0x2fffd},
12841280
{0x30000, 0x3fffd}
12851281
};
12861282

1283+
/* Sorted list of non-overlapping intervals of Emoji characters,
1284+
* based on http://unicode.org/emoji/charts/emoji-list.html */
1285+
static struct interval emoji[] =
1286+
{
1287+
{0x2196, 0x2199},
1288+
{0x21a9, 0x21aa},
1289+
{0x231a, 0x231b},
1290+
{0x2328, 0x2328},
1291+
{0x23cf, 0x23cf},
1292+
{0x23e9, 0x23f3},
1293+
{0x23f8, 0x23fa},
1294+
{0x24c2, 0x24c2},
1295+
{0x25b6, 0x25b6},
1296+
{0x25c0, 0x25c0},
1297+
{0x25fb, 0x25fe},
1298+
{0x2600, 0x2604},
1299+
{0x260e, 0x260e},
1300+
{0x2611, 0x2611},
1301+
{0x2614, 0x2615},
1302+
{0x2618, 0x2618},
1303+
{0x261d, 0x261d},
1304+
{0x2620, 0x2620},
1305+
{0x2622, 0x2623},
1306+
{0x2626, 0x2626},
1307+
{0x262a, 0x262a},
1308+
{0x262e, 0x262f},
1309+
{0x2638, 0x2639},
1310+
{0x2648, 0x2653},
1311+
{0x2668, 0x2668},
1312+
{0x267b, 0x267b},
1313+
{0x267f, 0x267f},
1314+
{0x2692, 0x2694},
1315+
{0x2696, 0x2697},
1316+
{0x2699, 0x2699},
1317+
{0x269b, 0x269c},
1318+
{0x26a0, 0x26a1},
1319+
{0x26aa, 0x26ab},
1320+
{0x26b0, 0x26b1},
1321+
{0x26bd, 0x26be},
1322+
{0x26c4, 0x26c5},
1323+
{0x26c8, 0x26c8},
1324+
{0x26ce, 0x26cf},
1325+
{0x26d1, 0x26d1},
1326+
{0x26d3, 0x26d4},
1327+
{0x26e9, 0x26ea},
1328+
{0x26f0, 0x26f5},
1329+
{0x26f7, 0x26fa},
1330+
{0x26fd, 0x26fd},
1331+
{0x2702, 0x2702},
1332+
{0x2705, 0x2705},
1333+
{0x2708, 0x270b},
1334+
{0x270d, 0x270d},
1335+
{0x270f, 0x270f},
1336+
{0x2712, 0x2712},
1337+
{0x2714, 0x2714},
1338+
{0x2716, 0x2716},
1339+
{0x271d, 0x271d},
1340+
{0x2721, 0x2721},
1341+
{0x2728, 0x2728},
1342+
{0x2733, 0x2734},
1343+
{0x2744, 0x2744},
1344+
{0x2747, 0x2747},
1345+
{0x274c, 0x274c},
1346+
{0x274e, 0x274e},
1347+
{0x2753, 0x2755},
1348+
{0x2757, 0x2757},
1349+
{0x2764, 0x2764},
1350+
{0x2795, 0x2797},
1351+
{0x27a1, 0x27a1},
1352+
{0x27b0, 0x27b0},
1353+
{0x27bf, 0x27bf},
1354+
{0x2934, 0x2935},
1355+
{0x2b05, 0x2b07},
1356+
{0x2b1b, 0x2b1c},
1357+
{0x2b50, 0x2b50},
1358+
{0x2b55, 0x2b55},
1359+
{0x3030, 0x3030},
1360+
{0x303d, 0x303d},
1361+
{0x3297, 0x3297},
1362+
{0x3299, 0x3299},
1363+
{0x1f000, 0x1fffd}
1364+
};
1365+
12871366
/* Sorted list of non-overlapping intervals of East Asian Ambiguous
12881367
* characters, generated with ../runtime/tools/unicode.vim. */
12891368
static struct interval ambiguous[] =
@@ -1482,6 +1561,8 @@ utf_char2cells(c)
14821561
if (intable(doublewidth, sizeof(doublewidth), c))
14831562
return 2;
14841563
#endif
1564+
if (intable(emoji, sizeof(emoji), c))
1565+
return 2;
14851566
}
14861567

14871568
/* Characters below 0x100 are influenced by 'isprint' option */

0 commit comments

Comments
 (0)