今日は久しぶりに朝から出社。通勤ラッシュの電車に乗るのも久しぶり。だからって、たまにはいいもんだ、なんてとても思えないけどね。暑いー。
昨日買った本の著者名に“î”という文字があるんだけど、これをHYMLでは“î”と書く。そういう書き方の一覧を作った。当然W3Cには置いてあるんだろうけど、手近にあると便利だし。DTDからHTMLへはJavaプログラムで変換した。場当たり的なコードだから公開できないけど。
そのXML本にUTF-8が基本だと書いてあった。試しにNativeテキストをUTF8に変換するJavaアプリケーションを書いて試してみる。をお。IEもNNもちゃんと表示する。エライエライ。あ、当然ヘッダにおまじない(<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">)を書いてやらないとダメなんだけど。
import java.io.*;
public class Native2UTF8 {
public static void main(String[] args) {
try {
BufferedReader in = new BufferedReader(new InputStreamReader(args.length < 1 ? System.in : new FileInputStream(args[0])));
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(args.length < 2 ? (OutputStream)System.out : new FileOutputStream(args[1]), "UTF8"));
while (true) {
String line = in.readLine();
if (line == null) {
break;
}
out.write(line);
out.newLine();
}
out.flush();
} catch (Exception ex) {
System.err.println(ex.getMessage());
System.err.println("usage: java Native2UTF8 [input [output]]");
}
}
}
あ。しょっくー。↑を調べてたらお気に入りだった<xmp>タグってHTML4.0外なのね。仕方ないから全部<pre>に置換だ。

コメントする