Adobe AIRで過去の遺産が使えない

ちゃんと?ライブラリにした。id:kageroh_:20090514:1242275278

とりあえず、現状(Adobe AIR 1.5)でshift_jisコンテンツとかが使えない。utf-8だけっぽい。

hoge-app.xml

<?xml version="1.0" encoding="utf-8"?>
<application xmlns="http://ns.adobe.com/air/application/1.5">
	<id>examples.html.Hoge</id>
	<filename>ほげ</filename>
	<initialWindow>
		<content>hoge.html</content>
		<visible>true</visible>
	</initialWindow>
</application>

hoge.html

<?xml version="1.0" encoding="shift_jis"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=shift_jis" />
		<title>ほげ</title>
	</head>
	<body>
		<h1>ほげ</h1>
	</body>
</html>

xml宣言のencodingも、metaタグも無視される。hoge-app.xmlのencoding変えてもダメ。initialWindowの子要素で指定するのかと調べたけど、ない。仕方ないのでラップする。

hoge-app.xml

<?xml version="1.0" encoding="utf-8"?>
<application xmlns="http://ns.adobe.com/air/application/1.5">
	<id>examples.html.Hoge</id>
	<filename>ほげ</filename>
	<initialWindow>
		<content>HTMLLoader.html</content>
		<visible>true</visible>
	</initialWindow>
</application>
HTMLLoader.html
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
	<head>
		<title>HTMLLoader</title>
		<script type="text/javascript" charset="utf-8" src="AIRAliases.js" id="AIRAliases"></script>
		<script type="text/javascript" charset="utf-8" src="HTMLLoader.js"></script>
	</head>
	<body>
	</body>
</html>
HTMLLoader.js
(function() {
  var stage = htmlLoader.stage, html_loader = new air.HTMLLoader;
  stage.addChild(html_loader);
  html_loader.width = stage.width;
  html_loader.height = stage.height;
  html_loader.addEventListener(air.Event.COMPLETE, function() {
    var air_aliases = document.getElementById('AIRAliases');
    var script = html_loader.window.document.body.appendChild(document.createElement('script'));
    script.type = air_aliases.type;
    script.charset = air_aliases.charset;
    script.src = air_aliases.src;
  });

  document.title = 'ほげ';
  html_loader.textEncodingFallback = 'shift_jis';
  html_loader.load(new air.URLRequest('hoge.html'));
})();

これはHTMLベース開発の例だけど、別にスウィッフ(笑)でもいい。