开发者

How to show Japanese characters in Mac OS X Terminal?

So I'm running MeCab (http://mecab.sourceforge.net/#download) to word-segment and do morpho-analysis of Japanese sentences. However, when I run the program, I see abracadabra due to some encoding issues in Mac OS X Terminal. I googled the topic, added Dfile.encoding option, added the following 3 lines in .inputrc:

set convert-meta off
set meta-flag on
set output-meta on

Nothing works. Any ideas how to show Japanese characters in Mac OS X Terminal? Here's the output of the run of the program test.java:

env DYLD_LIBRARY_PATH=. /usr/bin/java -Dfile.encoding=utf-8 test
0.98pre3
å¤  ̾»ì,°ìÈÌ,*,*,*,*,*
ª郎ã µ­¹æ,°ìÈÌ,*,*,*,*,*
¯ä  ̾»ì,¸Çͭ̾»ì,Áȿ¥,*,*,*,*
º郎にこのæ  µ­¹æ,°ìÈÌ,*,*,*,*,*
¬ã  ̾»ì,¥µÊÑÀܳ,*,*,*,*,*
    µ­¹æ,°ìÈÌ,*,*,*,*,*
æ¸  ̾»ì,°ìÈÌ,*,*,*,*,*
¡ã  µ­¹æ,³ç
    BOS/EOS,*,*,*,*,*,*,*,*
å   ̾»ì,°ìÈÌ,*,*,*,*
ª郎  µ­¹æ,°ìÈÌ,*,*,*
¯   ̾»ì,¸Çͭ̾»ì,Áȿ¥,*,*
º郎にこ    µ­¹æ,°ìÈÌ,*,*,*
¬   ̾»ì,¥µÊ开发者_开发技巧ÑÀܳ,*,*,*,
    µ­¹æ,°ìÈÌ,*,*,*
æ   ̾»ì,°ìÈÌ,*,*,*,*
¡   µ­¹æ,³ç¸̳«,*,*,*,*
    µ­¹æ,°ìÈÌ,*,*,*
    BOS/EOS,*,*,*,*,*,*,*,*
EOS


I would have thought that this was the default setting, but you could try selecting "Unicode (UTF-8)" as the Character encoding from Preferences..., Settings, Advanced, International. If this is already set, you may want to confirm that your program output is actually encoded in UTF-8. It could be Shift-JIS, EUC, or even UTF-16? In that case, try enabling those encodings from Preferences..., Encodings.


After this

% cd mecab-ipadic-2.7.0-xxxx
% ./configure --with-charset=utf8
% sudo make
% sudo make install

the output of 'mecab -D' is

% cd mecab-java-0.98pre3
% mecab -D
filename:    /usr/local/lib/mecab/dic/ipadic/sys.dic
version:    102
charset:    utf8
type:    0
size:    392126
left size:    1316
right size:    1316

Here's the output of running the test program.

bash-3.2$ env DYLD_LIBRARY_PATH=. /usr/bin/java test
0.98pre3
??    ??,????,??,?,*,*,??,???,???
?    ??,???,*,*,*,*,?,?,?
??    ??,????,??,?,*,*,??,???,???
?    ??,???,??,*,*,*,?,?,?
??    ???,*,*,*,*,*,??,??,??
?    ??,??,*,*,*,*,?,??,??
?    ??,???,??,*,*,*,?,?,?
??    ??,??,*,*,?????,???,??,???,???
?    ???,*,*,*,????,???,?,?,?
?    ??,??,*,*,*,*,?,?,?
EOS

    BOS/EOS,*,*,*,*,*,*,*,*
??    ??,????,??,?,*,*,??,???,???
?    ??,???,*,*,*,*,?,?,?
??    ??,????,??,?,*,*,??,???,???
?    ??,???,??,*,*,*,?,?,?
??    ???,*,*,*,*,*,??,??,??
?    ??,??,*,*,*,*,?,??,??
?    ??,???,??,*,*,*,?,?,?
??    ??,??,*,*,?????,???,??,???,???
?    ???,*,*,*,????,???,?,?,?
?    ??,??,*,*,*,*,?,?,?
    BOS/EOS,*,*,*,*,*,*,*,*
EOS

What am I missing to make encoding work?

P/S: all Japanese encodings are enabled at Preferences - Encodings in Terminal, encoding (Preferences - Settings - Advanced - International) in Mac OS X Terminal is UTF-8.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜