Google Crisis Response(Google)
災害に関する情報源や、行方不明者情報の収集と検索を行う『パーソンファインダー』を初めとするツールの提供が行われています。

2004年6月7日 月曜日

Eclipse コンソールの文字化け問題の続報

Filed under: コンピューター
時間:1時36分
投稿者:よしとも
AddClips 経由でソーシャルブックマークに登録

 以前、Eclipse のコンソールは EUC-JP の出力に対応していないと言うことを書きましたが、バグとして報告されていることがわかりました。

 この問題の原因は、コンソールがプラットフォームの標準コードしか対応していないことのようです。Windows や Mac なら Shift_JIS、Linux や FreeBSD なら EUC-JP ですね。これに対処するには、プラグイン側で標準出力をフックして、プラットフォーム標準文字コードに変換してやるしかなさそうです。ソースコードを持って来ないと直せそうもないですね。

———-
同日 午前2時1
5分追記
 コードを眺めていたら、コンソール出力をしているところを見つけました。org.epic.perleditor.editors.util.PerlValidator.java です。このファイルにある、public static void validate(IResource resource, String sourceCode) というメソッドがそれで、次のようになっている部分です。
 幅を取るので、インデントを減らしました。また、行頭の3文字はこちらで追加した行番号と区切り文字です。
01| /*
02| * Due to Java Bug #4763384 sleep for a very small amount of time
03| * immediately after starting the subprocess
04| */
05| proc =
06| Runtime.getRuntime().exec(
07| cmdParams,
08| null,
09| new File(workingDir));
10| Thread.sleep(1);
11|
12| proc.getInputStream().close();
13| InputStream in = proc.getErrorStream();
14| OutputStream out = proc.getOutputStream();
15| //TODO which charset?
16| Reader inr = new InputStreamReader(in);
17| Writer outw = new OutputStreamWriter(out);
18|
19| StringReaderThread srt = new StringReaderThread();
20| srt.read(inr);
21|
22| try {
23| outw.write(sourceCode);
24| outw.write(0x1a); //this should avoid problem with Win98
25| outw.flush();
26| } catch (IOException e) {
27| e.printStackTrace();
28| }
29| out.close();
30|
31| String content = srt.getResult();
32| inr.close();
33| in.close();
34|
35| //TODO check if content is empty (indicates error)
36|
37| // DEBUG start
38| System.out.println("-----------------------------------------");
39| System.out.println(" OUTPUT");
40| System.out.println("-----------------------------------------");
41| System.out.println(content);
42| System.out.println("-----------------------------------------");
43| // DEBUG END

 15行目を見ると、「TODO which charset?」とあり、文字コードを気にしてくれていることがうかがえます。ぜひ対応させて欲しいものです。

Comments (0)

HTML convert time: 0.094 sec. Powered by

Images is enhanced with WordPress Lightbox JS by Zeo