http://www.pitman.co.za/projects/charva/index.html
http://www.nilab.info/resource/bbslog/megabbs/1070189533.html
http://www.prox.jpn.org/~hiro/java/index.shtml#c2-2
Charvaを使う
特徴
java.awt や javax.swing に似せて作ってあるため非常に使いやすい。
日本語の表示、入力に不具合あり。
Windowsのコマンドプロンプトだと罫線が化けるかも。
TeraTermを使う場合は、Tera Specialフォントが必要。
インストール
ダウンロードして解凍するだけ。
カスタマイズ後(後述)
charva.zip(508)
使い方
ドキュメントを見れば分かる。
カスタマイズ
3バイト以上のUTF-8が扱えなくなっているので
Toolkit.c
の
my_readkey
をUTF-8の仕様に合わせて書き直す。
1 |
if ( (utf[0] & 0x80) == 0 ) { //0xxxxxxxx (1 byte UTF-8) c = utf[0]; } else if ( (utf[0] & 0xe0) == 0xc0 ) { // 110xxxxx 10xxxxxx ( 2 byte UTF-8 ) utf[1] = getch(); if (utf[1] == -1) return -1; c = ((utf[0] & 0x1f) << 6) + (utf[1] & 0x3f); } else if ( (utf[0] & 0xf0) == 0xe0 ) { // 1110xxxx 10xxxxxx 10xxxxxx ( 3 byte UTF-8 ) // cannot be tested = not supported :-( // must be similar to 2 byte encoding utf[1] = getch(); utf[2] = getch(); if (utf[1] == -1 || utf[2] == -1) return -1; c = ((utf[0] & 0xf) << 12) + ((utf[1] & 0x3f) << 6 ) + (utf[2] & 0x3f); } else if ( (utf[0] & 0xf8) == 0xf0 ) { // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx( 4 byte UTF-8 ) // cannot be tested = not supported :-( // must be similar to 2 byte encoding utf[1] = getch(); utf[2] = getch(); utf[3] = getch(); if (utf[1] == -1 || utf[2] == -1 || utf[3] == -1) return -1; c = ((utf[0] & 0x7) << 18) + ((utf[1] & 0x3f) << 12 ) + ((utf[2] & 0x3f) << 6 ) + (utf[3] & 0x3f); } else if ( (utf[0] & 0xfc) == 0xf8 ) { // 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx( 5 byte UTF-8 ) // cannot be tested = not supported :-( // must be similar to 2 byte encoding utf[1] = getch(); utf[2] = getch(); utf[3] = getch(); utf[4] = getch(); if (utf[1] == -1 || utf[2] == -1 || utf[3] == -1 || utf[4] == -1) return -1; c = ((utf[0] & 0x3) << 24) + ((utf[1] & 0x3f) << 18 ) + ((utf[2] & 0x3f) << 12 ) + ((utf[3] & 0x3f) << 6 ) + (utf[4] & 0x3f); } if ( (utf[0] & 0xfe) == 0xfc ) { // 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx ( 6 byte UTF-8 ) // cannot be tested = not supported :-( // must be similar to 2 byte encoding utf[1] = getch(); utf[2] = getch(); utf[3] = getch(); utf[4] = getch(); utf[5] = getch(); if (utf[1] == -1 || utf[2] == -1 || utf[3] == -1 || utf[4] == -1 || utf[4] == -1) return -1; c = ((utf[0] & 0x1) << 30) + ((utf[1] & 0x3f) << 24 ) + ((utf[2] & 0x3f) << 18 ) + ((utf[3] & 0x3f) << 12 ) + ((utf[4] & 0x3f) << 6 ) +(utf[5] & 0x3f); } |
[カテゴリ: プログラミング言語 > Java]
[通知用URL]
Tweet
最終更新時間:2010年10月09日 01時14分12秒