Perl 全角ひらがなから全角カタカナへの変換
sub hiragana2katakana {
local($_) = @_;
s/\xa5\xa4/`/g;
s/\xa4([\xa1-\xfe])/\xa5$1/g;
s/`/\xa5\xa4/g;
$_;
}
$katakana = hiragana2katakana($hiragana);
« 2007年03月 | メイン | 2007年05月 »
sub hiragana2katakana {
local($_) = @_;
s/\xa5\xa4/`/g;
s/\xa4([\xa1-\xfe])/\xa5$1/g;
s/`/\xa5\xa4/g;
$_;
}
$katakana = hiragana2katakana($hiragana);
Applet内部デバッグで使っています。
Appletからのログ出力はできないっぽいのでCGIに値を渡してログを出しています。
Getメソッドの場合
public void debug( String str ){
String _str = str;
String debug_url = "http://デバッグ用CGIのURL?str=";
try {
URL _url = new URL( debug_url + _str );
HttpURLConnection urlconn = (HttpURLConnection)_url.openConnection();
urlconn.setRequestMethod("GET");
urlconn.setInstanceFollowRedirects(false);
urlconn.setRequestProperty("Accept-Language", "ja;q=0.7,en;q=0.3");
urlconn.connect();
BufferedReader reader = new BufferedReader(new InputStreamReader(urlconn.getInputStream()));
while (true){
String line = reader.readLine();
if ( line == null ){
break;
}
}
reader.close();
urlconn.disconnect();
}
catch(Throwable e){
}finally{
try{
}catch(Exception e){}
}
}
Postメソッドの場合
public void debug( String str ){
String _str = str;
String debug_url = "http://デバッグ用CGIのURL?str=";
try{
URL _url = new URL( debug_url );
HttpURLConnection conn = (HttpURLConnection)_url.openConnection();
conn.setUseCaches(false);
conn.setRequestMethod("POST"); /* GET or POST */
conn.setDoOutput(true); /* GET:false / POST:true */
conn.connect();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(conn.getOutputStream()));
StringBuffer outBuf = new StringBuffer();
/* GET の場合は URL にくっつける。 */
outBuf.append("&str=").append(URLEncoder.encode(_str,"UTF-8"));
writer.write(outBuf.toString());
writer.close();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(),"UTF-8"));
StringBuffer inBuf = new StringBuffer();
String line;
while((line = reader.readLine()) != null){
inBuf.append(line).append('\n');
}
System.out.println(inBuf.toString());
reader.close();
conn.disconnect();
}catch(Exception ex){
ex.printStackTrace();
}
}
VNCはLinuxのデスクトップ環境をWindows上で遠隔操作できるツール
http://www.realvnc.com
ここからvnc-4_1_2-x86_linux[1].tar.gzをダウンロードする
展開後、インストールディレクトリをしていしてvncinstallを起動する
./vncinstall /usr/local/bin
vncviewer vncserver vncpasswd Xvnc が /usr/local/bin にコピーされる
/usr/local/bin をPATHに加える
起動 vncserver :1
初回はパスワードを聞かれるので 適当に設定する
You will require a password to access your desktops.
Password:
Verify:
起動したユーザーのホームディレクトリに .vncというディレクトリができて
この下に設定ファイルやログができる
停止する場合は vncserver -kill :1
Windows 側はvnc-4_1_2-x86_win32_viewer.exeをダウンロードしてダブルクリックで起動する
サーバー指定は (サーバーのIP):1 と入力する
この数字は vncserver を起動した際に指定した数字になる
その後、パスワードを聞いてくるので
最初に設定したパスワードを入力する
パスワードを変更したいときは vncpasswd で変更可能
Notice: Only variable references should be returned by reference in MDB/Common.php on line 415
こんなエラーメッセージを消したい場合、error_reporting(E_ALL);をコメントにする。
もしくはレベルを変えておく。
*Maple,Ethnaの場合
前回の続き
$this->_tpl_vars[Smartyでの変数名] でPHPのほうへ渡せるようです
こんな風に
{foreach from=$action.tags|smarty:nodefaults item=tag}
{php}print urlencode($this->_tpl_vars['tag']);{/php}
{/foreach}
$tags = "bikini wet girl model swimsuit camera photoshoot outdoors Array Swimsuit Japanese";
これを半角スペースで区切って配列にする場合は
$as = split(" ",$tags);
foreach ($as as $a){
$this->tags[] = $a;
}
Smartyの受け側では
{foreach from=$action.tags|smarty:nodefaults item=tag}
{$tag}
{/foreach}
{$var|smarty:nodefaults}
こんな風にすれば回避できるようです