Last week I wanted to convert some simplified Chinese characters into traditional ones. I found a deceptively nice looking shell one-liner, which today I found out was 20% error prone.
So I did some research. The mediawiki codebase contains conversion tables that take the idiosyncratic nature of simplified orthography into account, and someone already wrote a nice helper library full of dummy classes and functions, called mediawiki-zhconverter. So it appeared I could have my one-liner, which I would prefer looked something like this, stconvert being the name of the script I'm writing:
$cat simplifiedstory | stconvert > traditionalstory
However, mediawiki is entirely PHP, and I have never written any PHP, so I don't know how it deals with shell variables. As you can see below, simply putting '$argv' where a string would go does not achieve my goal.
#!/usr/bin/php <?php define("MEDIAWIKI_PATH", "/home/a1/mediawiki-1.13.0/"); require_once "mediawiki-zhconverter.inc.php"; echo MediaWikiZhConverter::convert($argv, "zh-tw") , ","; ?>