As my C memory is fading, maybe I will give you some directions rather than actual code. I am not familiar with the Japanese encodings actually, so I will state the general way of handling it.
As I said, the first thing before you start is to check whether you really are getting UTF-8 character code sequence from your input. Do you have gucharmap (Gnome Unicode character map) installed? It will help you check the UTF-8 representation quickly by entering a character from search.
http://gucharmap.sourceforge.net/
Also check your terminal that it can support the UTF-8 encoding with proper font. Check that you can read the content of a UTF-8 encoded Japanese text file, for instance, by "cat" should normally be sufficient to test it.
Then you can enter a Japanese character as input in your program, then read the char* from the input and use sprintf() to dump the character code. Just check that the sequence matches the UTF-8 character sequence then you know your input is in Unicode. Note that Japanese characters are represented in UTF-8 3 bytes each.
Encoding conversion between legacy JP encoding and UTF-8 is only needed if your input and output encodings differ. If you are sure both are UTF-8, then you don't need encoding conversion. Encoding conversion can be conducted with the iconv library.
You can find more information in the following documents:
http://www.tldp.org/HOWTO/Unicode-HOWTO.html
http://www.debian.org/doc/manuals/intro-i18n/
You may also find this thread with an example on iconv useful:
https://www.unix.com/showthread.php?t...ighlight=iconv
For background information on Unicode, you should find certain chapters (especially the introductory chapters) from the Unicode specification useful:
http://www.unicode.org/versions/Unicode4.1.0/