Skip to content

Instantly share code, notes, and snippets.

@naoa
Last active September 1, 2023 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naoa/7858360 to your computer and use it in GitHub Desktop.
Save naoa/7858360 to your computer and use it in GitHub Desktop.
from kanji to katakana convert
<?php
$input_file = $argv[1];
if($argc >= 3){
$output_file = $argv[2];
}
else{
$output_file = "";
}
$conv = "./converter-main -i";
$dict = "dict/bccwj4";
$fp = fopen($input_file, 'r');
if($output_file != ""){
$fw = fopen($output_file, 'a+');
}
while (!feof($fp)){
$line = fgets($fp);
$line = str_replace(array("\r\n","\r","\n"),'',$line);
$cmd = 'echo ' . $line . ' | ' . $conv . ' ' . $dict;
$af_str = exec($cmd);
if($af_str != ""){
$af_str = mb_convert_kana($af_str, "C", "UTF-8");
if($output_file != ""){
fwrite($fw,$af_str . "\n");
}
else{
echo $af_str . "\n";
}
}
}
fclose($fp);
if($output_file != ""){
fclose($fw);
}
echo "Done.\n";
?>
@Bobikv
Copy link

Bobikv commented Sep 1, 2023

シルバ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment