From 8f7b303fc5927811b876c73bccd066618bd4fbe1 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 15 Oct 2015 19:01:23 +0200 Subject: [PATCH] Recognize half width symbols --- spec/text-utils-spec.coffee | 1 + src/text-utils.coffee | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/text-utils-spec.coffee b/spec/text-utils-spec.coffee index f95d7c22c73..eace87513c5 100644 --- a/spec/text-utils-spec.coffee +++ b/spec/text-utils-spec.coffee @@ -64,4 +64,5 @@ describe 'text utilities', -> expect(textUtils.isHalfWidthCharacter("ハ")).toBe(true) expect(textUtils.isHalfWidthCharacter("ヒ")).toBe(true) expect(textUtils.isHalfWidthCharacter("ᆲ")).toBe(true) + expect(textUtils.isHalfWidthCharacter("■")).toBe(true) expect(textUtils.isHalfWidthCharacter("B")).toBe(false) diff --git a/src/text-utils.coffee b/src/text-utils.coffee index dfb83425232..cfe0e807cc3 100644 --- a/src/text-utils.coffee +++ b/src/text-utils.coffee @@ -65,10 +65,10 @@ isKoreanCharacter = (charCode) -> 0xD7B0 <= charCode <= 0xD7FF isJapaneseCharacter = (charCode) -> - 0x3000 <= charCode <= 0x30ff + 0x3000 <= charCode <= 0x30FF isCjkUnifiedIdeograph = (charCode) -> - 0x4e00 <= charCode <= 0x9faf + 0x4E00 <= charCode <= 0x9FAF isFullWidthForm = (charCode) -> 0xFF01 <= charCode <= 0xFF5E or @@ -85,7 +85,8 @@ isDoubleWidthCharacter = (character) -> isHalfWidthCharacter = (character) -> charCode = character.charCodeAt(0) - 0xFF65 <= charCode <= 0xFFDC + 0xFF65 <= charCode <= 0xFFDC or + 0xFFE8 <= charCode <= 0xFFEE # Does the given string contain at least surrogate pair, variation sequence, # or combined character?