memo.xight.org

日々のメモ

EUC-JP で変換できない機種依存文字を置換する

Summary

UTF-8で変換できない機種依存文字を置換する[2006-06-19-13] のEUC-JP版 のつもり.

追記 [2006-08-09]

結果は失敗.
文字化け発生.

Source

function replaceText($str){
	$arr = array(
		// ADA0 - ADB4
		"\xAD\xA1" => "(1)",
		"\xAD\xA2" => "(2)",
		"\xAD\xA3" => "(3)",
		"\xAD\xA4" => "(4)",
		"\xAD\xA5" => "(5)",
		"\xAD\xA6" => "(6)",
		"\xAD\xA7" => "(7)",
		"\xAD\xA8" => "(8)",
		"\xAD\xA9" => "(9)",
		"\xAD\xAA" => "(10)",
		"\xAD\xAB" => "(11)",
		"\xAD\xAC" => "(12)",
		"\xAD\xAD" => "(13)",
		"\xAD\xAE" => "(14)",
		"\xAD\xAF" => "(15)",
		"\xAD\xB0" => "(16)",
		"\xAD\xB1" => "(17)",
		"\xAD\xB2" => "(18)",
		"\xAD\xB3" => "(19)",
		"\xAD\xB4" => "(20)",
		
		// ADB5 - ADBF
		"\xAD\xB5" => "I",
		"\xAD\xB6" => "II",
		"\xAD\xB7" => "III",
		"\xAD\xB8" => "IV",
		"\xAD\xB9" => "V",
		"\xAD\xBA" => "VI",
		"\xAD\xBB" => "VII",
		"\xAD\xBC" => "VIII",
		"\xAD\xBD" => "IX",
		"\xAD\xBE" => "X",
		"\xAD\xBF" => "?",
		
		"\xAD\xC0" => "ミリ",
		"\xAD\xC1" => "キロ",
		"\xAD\xC2" => "センチ",
		"\xAD\xC3" => "メートル",
		"\xAD\xC4" => "グラム",
		"\xAD\xC5" => "トン",
		"\xAD\xC6" => "アール",
		"\xAD\xC7" => "ヘクタール",
		"\xAD\xC8" => "リットル",
		"\xAD\xC9" => "ワット",
		"\xAD\xCA" => "カロリー",
		"\xAD\xCB" => "ドル",
		"\xAD\xCC" => "セント",
		"\xAD\xCD" => "パーセント",
		"\xAD\xCE" => "ミリバール",
		"\xAD\xCF" => "ページ",
		
		"\xAD\xD0" => "mm",
		"\xAD\xD1" => "cm",
		"\xAD\xD2" => "km",
		"\xAD\xD3" => "mg",
		"\xAD\xD4" => "kg",
		"\xAD\xD5" => "cc",
		"\xAD\xD6" => "m2",
		
		"\xAD\xDF" => "平成",
		
		"\xAD\xE0" => "``",
		"\xAD\xE1" => "''",
		"\xAD\xE2" => "No.",
		"\xAD\xE3" => "K.K.",
		"\xAD\xE4" => "",
		
		"\xAD\xE5" => "(上)",
		"\xAD\xE6" => "(中)",
		"\xAD\xE7" => "(下)",
		"\xAD\xE8" => "(左)",
		"\xAD\xE9" => "(右)",
		
		"\xAD\xEA" => "(株)",
		"\xAD\xEB" => "(有)",
		"\xAD\xEC" => "(代)",
		
		"\xAD\xED" => "明治",
		"\xAD\xEE" => "大正",
		"\xAD\xEF" => "昭和",
		
		"\xAD\xF0" => "",
		"\xAD\xF1" => "",
		"\xAD\xF2" => "",
		"\xAD\xF3" => "",
		"\xAD\xF4" => "",
		"\xAD\xF5" => "",
		"\xAD\xF6" => "",
		"\xAD\xF7" => "",
		"\xAD\xF8" => "",
		"\xAD\xF9" => "",
		"\xAD\xFA" => "",
		"\xAD\xFB" => "",
		"\xAD\xFC" => "",
		
		"\xFC\xF1" => "i",
		"\xFC\xF2" => "ii",
		"\xFC\xF3" => "iii",
		"\xFC\xF4" => "iv",
		"\xFC\xF5" => "v",
		"\xFC\xF6" => "vi",
		"\xFC\xF7" => "vii",
		"\xFC\xF8" => "viii",
		"\xFC\xF9" => "ix",
		"\xFC\xFA" => "x",
	);
	return strtr($str,$arr);
}


Reference

文字コード表
http://ash.jp/code/codetbl2.htm

StarLogo TNG - フリーのモデリングとシミュレーションソフト

Summary

Quake3などで使用されているMD3形式と一般的なOBJ形式に対応
地形エディタが付属
ジョイスティックとキーボードによる操作が可能
1人称視点と3人称視点に変更可能
吹き出しを出してコミュニケーションが可能
プログラミング言語を使って制御が可能

Reference

StarLogo TNG
http://education.mit.edu/starlogo-tng/

via

GIGAZINE - フリーのモデリングとシミュレーションソフト「StarLogo TNG」
http://gigazine.net/index.php?/news/comments/20060808_starlogo_tng/

HTMLエンティティから元の文字に戻す

Summary

文字列中のHTML特殊文字を元に戻す.
htmlspecialchars()の逆の操作.
function unhtmlspecialchars( $str )
{
	$entry = array_flip( get_html_translation_table( HTML_SPECIALCHARS ) );
	return strtr( $str, $entry );
}


function unhtmlentities($string)
{
	// 数値エンティティの置換
	$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);
	$string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);

	// 文字エンティティの置換
	$trans_tbl = get_html_translation_table(HTML_ENTITIES);
	$trans_tbl = array_flip($trans_tbl);
	return strtr($string, $trans_tbl);
}

Reference

マイクロチップス - PHP Tips
http://www.sound-uz.jp/php/tips/micro.html#c01

A Handy CSS Debugging Snippet

Summary

 * { outline: 2px dotted red }
 * * { outline: 2px dotted green }
 * * * { outline: 2px dotted orange }
 * * * * { outline: 2px dotted blue }
 * * * * * { outline: 1px solid red }
 * * * * * * { outline: 1px solid green }
 * * * * * * * { outline: 1px solid orange }
 * * * * * * * * { outline: 1px solid blue }


Reference

A Handy CSS Debugging Snippet
http://homepage.mac.com/chrispage/iblog/C42511381/E20060806095030/