Internationalization Cookbook
This is my personal blog. The views expressed on these pages are mine alone and not those of my employer.

“Reverse IME” (getting hiragana/katakana/pinyin/bopomofo from kanji)

Q. Is there is an inverse API-function or library which makes it possible to receive a list of possible transcriptions in pinyin or romaji (depending on the actual IME one is using) out of complex characters?

A. The easy way is IFELanguage::GetPhonetic. More complex (but offering more control) is IFELanguage::GetJMorphResult.

Just code for now

I have found this question quite interesting (especially since previously I have played with IFELanguage::GetPhonetic, but not with IFELanguage::GetJMorphResult), so over the week-end I have managed to put together a small application to investigate how GetJMorphResult works.

According to the documentation, IFELanguage::GetPhonetic “is a thin wrapper function of GetJMorphResult with FELANG_REQ_REV.” and the parameters and how to use it is way easier.

In the same time, I am to lazy now to write a full article. So, I am posting the code, some pictures, and I promise to write something later.
Otherwise the one asking the question will retire before I post anything :-)

So, here it is:

This is direct conversion, pretty much what a user will get when typing on a US keyboard:

But those familiar with Japanese and with the name will tell you this is not correct, and they are right.

So we set the FELANG_CMODE_NAME flag, trying to force a selection that is appropriate for names:

And this time the result is correct (and we can check it here: http://en.wikipedia.org/wiki/Miyamoto_Musashi)

Now we cam take the Kanji and convert them back to Hiragana using MSIME.Japan:

We cam obtain the Bopomofo using the MSIME.Taiwan:

Or (for those of us who cannot read any of the above :-)) we get the PinYin using MSIME.China:

Ok, enough with the stories. If you think this looks useful, you can download the code from here (yes, it is Visual Studio 2005, but except for the project file, everything else should be ok :-).

If something is not clear, ask. If something is not correct, say it. If something is ugly, don’t look at it :-)

One comment to ““Reverse IME” (getting hiragana/katakana/pinyin/bopomofo from kanji)”

  1. Anonymous says:

    Thanks for the code. You saved my day !

Leave a comment to Anonymous