diff --git a/src/wp-admin/js/word-count.js b/src/wp-admin/js/word-count.js index bdf4adefae..025412e346 100644 --- a/src/wp-admin/js/word-count.js +++ b/src/wp-admin/js/word-count.js @@ -57,6 +57,7 @@ '\u2E00-\u2E7F', ']' ].join( '' ), 'g' ), + astralRegExp: /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, wordsRegExp: /\S\s+/g, charactersRegExp: /\S/g, allRegExp: /[^\f\n\r\t\v\u00ad\u2028\u2029]/g, @@ -82,6 +83,8 @@ if ( type === 'words' ) { text = text.replace( this.settings.connectorRegExp, ' ' ); text = text.replace( this.settings.removeRegExp, '' ); + } else { + text = text.replace( this.settings.astralRegExp, 'a' ); } text = text.match( this.settings[ type + 'RegExp' ] ); diff --git a/tests/qunit/wp-admin/js/word-count.js b/tests/qunit/wp-admin/js/word-count.js index ad69453e49..a31fc09668 100644 --- a/tests/qunit/wp-admin/js/word-count.js +++ b/tests/qunit/wp-admin/js/word-count.js @@ -51,6 +51,13 @@ words: 3, characters: 11, all: 12 + }, + { + message: 'Astrals.', + string: '\uD83D\uDCA9', + words: 1, + characters: 1, + all: 1 } ], function( test ) { _.each( [ 'words', 'characters', 'all' ], function( type ) {