Skip to content

Commit 2af7be5

Browse files
gucong3000sindresorhus
authored andcommittedJul 18, 2017
Support combining characters (#12)
1 parent 175b26f commit 2af7be5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed
 

‎index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ module.exports = str => {
1414
for (let i = 0; i < str.length; i++) {
1515
const code = str.codePointAt(i);
1616

17-
// Ignore control characters
18-
if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) {
17+
// Ignore control characters & combining characters
18+
if (code <= 0x1F || (code >= 0x7F && code <= 0x9F) || (code >= 0x300 && code <= 0x36F)) {
1919
continue;
2020
}
2121

2222
// Surrogates
23-
if (code >= 0x10000) {
23+
if (code > 0xFFFF) {
2424
i++;
2525
}
2626

‎test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ test('ignores control characters', t => {
2121
t.is(m('\u001B'), 0);
2222
});
2323

24-
test.failing('handles combining characters', t => {
24+
test('handles combining characters', t => {
2525
t.is(m('x\u0300'), 1);
2626
});

0 commit comments

Comments
 (0)
Please sign in to comment.