/aspell6-sr-0.02/misc/cyr2lat.php
PHP | 55 lines | 26 code | 11 blank | 18 comment | 2 complexity | a50b067103f4dbdbc3af98fc0589e16e MD5 | raw file
Possible License(s): LGPL-2.1
- #!/usr/local/bin/php
- <?php
-
- /*
- Author: Goran Rakic, 09/29/2005
-
- Known bug:
-
- This simple tool does not handle transliteration of capital
- Cyrillic characters that are written as two characters in Latin
- script correctly. For example, word "?????" should be converted
- to "NJEGOV" (this tool will do that correctly), but word "?????"
- should be converted to "Njegov" and script will convert it to
- "NJegov".
-
- You can find more robust solutions at URL:
- http://www.cirilica.org/programi.html
-
- */
- if (!function_exists('file_get_contents')) require_once('file_get_contents.php');
- if (!function_exists('file_put_contents')) require_once('file_put_contents.php');
- $small = array('?' => 'a', '?' => 'b', '?' => 'v', '?' => 'g', '?' => 'd',
- '?' => '?', '?' => 'e', '?' => '', '?' => 'z', '?' => 'i',
- '?' => 'j', '?' => 'k', '?' => 'l', '?' => 'lj', '?' => 'm',
- '?' => 'n', '?' => 'nj', '?' => 'o', '?' => 'p', '?' => 'r',
- '?' => 's', '?' => 't', '?' => '?', '?' => '?', '?' => 'f',
- '?' => 'h', '?' => 'c', '?' => 'u', '?' => 'd', '?' => '');
-
- $capital = array('?' => 'A', '?' => 'B', '?' => 'V', '?' => 'G', '?' => 'D',
- '?' => '?', '?' => 'E', '?' => '', '?' => 'Z', '?' => 'I',
- '?' => 'J', '?' => 'K', '?' => 'L', '?' => 'LJ', '?' => 'M',
- '?' => 'N', '?' => 'NJ', '?' => 'O', '?' => 'P', '?' => 'R',
- '?' => 'S', '?' => 'T', '?' => '?', '?' => '?', '?' => 'F',
- '?' => 'H', '?' => 'C', '?' => 'U', '?' => 'D', '?' => '');
- echo "\nSerbian Cyrillic to Serbian Latin transliteration tool\n\n";
- echo "Enter input filename: ";
- $in = trim(fgets(STDIN));
-
- echo "Enter output filename: ";
- $out = trim(fgets(STDIN));
-
- $input = file_get_contents($in);
- $rep = array_merge($small, $capital);
- $output = strtr($input, $rep);
- file_put_contents($out, $output);
- echo "Done.\n";
-
- ?>