code đờ
code đờ

Reputation: 615

Javascript indexOf/charAt not working for Japanese half-width Katakana

In my codebase I have this code, surprisingly it returns 1:

'トゲ'.indexOf('ケ') // Returns 1

The character doesn't seem to appear in string トゲ.

I also tried to run this code:

'トゲ'.charAt(1)  // Returns `ケ`

And to my surprise it returns .

Can you explain why the codes above return 1 and ? Thank you!

Upvotes: 0

Views: 62

Answers (1)

deceze
deceze

Reputation: 522005

Your string consists of three characters: ト, ケ and ゙. There is no dedicated halfwidth-ge character, you'll always use a regular halfwidth character and add the halfwidth voiced sound mark to it, which will be rendered as the combined glyph ゲ.

Note that there is a dedicated fullwidth ゲ KATAKANA LETTER GE U+30B2.

Upvotes: 2

Related Questions