Posts

Showing posts from January, 2014

C/C++ Function to convert Unicode Japanese Katakana to Hiragana

I wrote a little tool which allows to add new words to the dictionary of the Chrome Extension Rikaikun (inspired by rikaichan for Firefox) and then recompile the index file. The index file stores all spellings in hiragana, so this was needed. Fortunately, the rikaikun source code already had this code ready, albeit in JavaScript. The function writes the result to r and returns the end of the converted string. // modified from Chrome extension rikaikun, file data.ja wchar_t * katakana_to_hiragana ( wchar_t * word , wchar_t * r ) { // katakana -> hiragana conversion tables wchar_t ch [ ] = { 0x3092 , 0x3041 , 0x3043 , 0x3045 , 0x3047 , 0x3049 , 0x3083 , 0x3085 , 0x3087 , 0x3063 , 0x30FC , 0x3042 , 0x3044 , 0x3046 , 0x3048 , 0x304A , 0x304B , 0x304D , 0x304F , 0x3051 , 0x3053 , 0x3055 , 0x3057 , 0x3059 , 0x305B , 0x305D , 0x305F , 0x3061 , 0x3064 , 0x3066 , 0x3068 , 0x306A , 0x306B , 0x306C , 0x306D , 0x306E , 0x306F