Skip to content

Commit

Permalink
Recognize half width symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
as-cii committed Oct 15, 2015
1 parent a3c3b48 commit 8f7b303
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions spec/text-utils-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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)
7 changes: 4 additions & 3 deletions src/text-utils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?
Expand Down

0 comments on commit 8f7b303

Please sign in to comment.