- 更新日: 2014年5月7日
 - Mac & PC
 
Mac に KAKASI(漢字→ひらがな読み・ローマ字変換ライブラリ)をインストール
漢字かな交じりの単語や文章に、ひらがな・ローマ字の読み仮名を付けるために Kakasi を導入しました。Mac OSX へのインストール。
— 環境 —
Mac OS X Lion 10.7.5
KAKASI のインストールではまる…
| 
					 1 2 3 4 5 6 7 8  | 
						$ wget http://kakasi.namazu.org/stable/kakasi-2.3.6.tar.gz $ tar xzf kakasi-2.3.6.tar.gz $ cd kakasi-2.3.6 $ ./configure ... configure: error: can not use EUC-JP or UTF-8 encoding on iconv  | 
					
configure でエラー。
| 
					 1 2 3 4  | 
						$ which iconv /usr/local/bin/iconv  | 
					
iconv は入っていたので、prefix のオプションを付けて再度 configure。
| 
					 1 2 3 4 5  | 
						$ ./configure --with-libiconv-prefix=/usr/local/bin/iconv ... configure: error: can not use EUC-JP or UTF-8 encoding on iconv  | 
					
またエラー。Apple の llvm gcc が原因かもしれないので、入れてた gcc4.9 で試す。
| 
					 1 2 3 4 5 6 7 8  | 
						$ gcc --version i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) Copyright (C) 2007 Free Software Foundation, Inc. $ ./configure CC=/usr/local/bin/gcc-4.9 ... configure: error: can not use EUC-JP or UTF-8 encoding on iconv  | 
					
また同じ iconv のエラー。あー詰んだ、と少々諦め感が…
/usr/local/include/iconv.h が原因
うーん、configure が通りません。しばらく悩みつつググってたら、神の救いが!
Homebrewでエラーが出たらdoctorを呼ぶ – 面白コンテンツ探求日記
| 
					 1 2 3 4  | 
						$ ls /usr/local/include | grep iconv iconv.h  | 
					
これが原因っぽい!ということで、brew doctor で診断しました。
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  | 
						$ brew doctor Warning: Some keg-only formula are linked into the Cellar. Linking a keg-only formula, such as gettext, into the cellar with `brew link <formula>` will cause other formulae to detect them during the `./configure` step. This may cause problems when compiling those other formulae. Binaries provided by keg-only formulae may override system binaries with other strange results. You may wish to `brew unlink` these brews:     libiconv     libxml2     openssl     readline  | 
					
libiconv, libxml2, openssl, readline は brew unlink したほうが良いかもよと指示が出ているので、unlink 実行。
| 
					 1 2 3 4 5 6 7 8 9 10 11 12  | 
						$ brew unlink libiconv Unlinking /usr/local/Cellar/libiconv/1.14... 16 links removed $ brew unlink libxml2 Unlinking /usr/local/Cellar/libxml2/2.9.1... 6 links removed $ brew unlink openssl Unlinking /usr/local/Cellar/openssl/1.0.1e... 1139 links removed $ brew unlink readline Unlinking /usr/local/Cellar/readline/6.2.4... 12 links removed $ which iconv /usr/bin/iconv  | 
					
元から入ってる iconv を使う。
Kakasi の configure から続き
気を取り直して、再度 Kakasi の configure。
| 
					 1 2 3 4 5  | 
						$ ./configure $ make $ sudo make install  | 
					
これでやっと入りました。あー疲れた、いらん所ではまりました…
| 
					 1 2 3 4  | 
						$ which kakasi /usr/local/bin/kakasi  | 
					
Kakasi を使ってみる
| 
					 1 2 3 4  | 
						$ echo "あいうえお" | kakasi -Ha �yu��うえお  | 
					
? で文字化けするので nkf を入れる。
| 
					 1 2 3 4 5 6 7  | 
						$ brew install nkf $ echo "あいうえお" | nkf -e | kakasi -Ha | nkf -w aiueo $ echo "漢字と平仮名交じり" | nkf -e | kakasi -JH | nkf -w かんじとひらがなまじり  | 
					
おーし、使えました!!
kakasi -[変換前][変換後] とオプションを指定します。
a: ascii(アスキー文字、アルファベット)
j: jisroman
g: graphic
k: kana (j,k defined in jisx0201)
E: kigou
K: katakana(カタカナ)
H: hiragana(ひらがな)
J: kanji(E,K,H,J defined in jisx0208)(漢字)
J, H, K, a がよく使いそうです。
- – 参考リンク –
 - Hunting Field: 漢字→かな(ローマ字)変換プログラム KAKASIのインストールと使い方
 - Mac OS X MavericksへのKakasiのインストール – Qiita
 
- Mac & PC の関連記事
 - マークダウンのHTML表示確認にChrome拡張Markdown Preview Plusが便利
 - cdtoでMac El CapitanのFinderからiTerm2/ターミナルを起動
 - Mac OSをEl Capitanにアップデート/インストール
 - Macでスクリーンショット動画をキャプチャする手順
 - MacでWord/Excelファイルを作成・編集するにはOffice Onlineが便利
 - Macでトラックパッドとマウスのスクロール方向を逆に設定
 - Mac Chromeにマウスジェスチャー拡張 smartUp Gestures を入れた
 - Xcodeの操作が辛いので635円の無線マウスを買った
 - エンジニアでもできる洒落たロゴを短時間で作成するコツ4つ
 - Mac・YosemiteでDisplayLinkドライバを更新
 

画像付き英語辞書 Imagict | 英単語をイメージで暗記





Leave Your Message!