Created
June 20, 2012 15:45
-
-
Save drnikko/2960578 to your computer and use it in GitHub Desktop.
Handy function to parse kanji out of sentences
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function parseText(text) { | |
| // simplified version of this guys' http://buildingonmud.blogspot.com/2009/06/convert-string-to-unicode-in-javascript.html | |
| var charArray = text.split(''); | |
| var justKanji = []; | |
| charArray.forEach( function(item) { | |
| // rejection ranges found @unicodemap.com | |
| // http://www.unicodemap.org/range/62/Hiragana/ & http://www.unicodemap.org/range/63/Katakana/ | |
| // 12352 - 12543 | |
| var unicode = item.charCodeAt(0); | |
| console.log(unicode); | |
| if (unicode < 12352 || unicode > 12543) { | |
| justKanji.push(item); | |
| } | |
| }); | |
| return justKanji; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment