// // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Quick and dirty kana convertor function convert($input) { $table = array( 'KKYAA' => 18763838, 'SSHOO' => 18500158, 'TCHOO' => 18496574, 'TCHAA' => 18758718, 'SSHUU' => 18369086, 'TCHUU' => 18365502, 'PPYAA' => 18753854, 'SSHAA' => 18762302, 'KKYUU' => 18370622, 'PPYUU' => 18360638, 'KKYOO' => 18501694, 'PPYOO' => 18491710, 'ppyu' => 7899550, 'tcho' => 8035486, 'ppya' => 8292766, 'FYU' => 6184, 'kkyo' => 8040606, 'sshu' => 7907998, 'kkya' => 8302750, 'GYU' => 6227, 'ssho' => 8039070, 'ssha' => 8301214, 'kkyu' => 7909534, 'TU' => 22587, 'tcha' => 8297630, 'TCHU' => 1588286, 'KKYO' => 1724478, 'DU' => 22586, 'SSHU' => 1591870, 'KKYA' => 1986622, 'SSHO' => 1722942, 'TSUU' => 313, 'SSHA' => 1985086, 'KKYU' => 1593406, 'ppyo' => 8030622, 'SHII' => 330, 'PPYU' => 1583422, 'PPYA' => 1976638, 'PPYO' => 1714494, 'DI' => 24122, 'TCHA' => 1981502, 'TCHO' => 1719358, 'tchu' => 7904414, 'NYO' => 6710, 'SSHII' => 84542, 'TTSUU' => 80190, 'TCHII' => 80958, 'RYOO' => 72215, 'KKEE' => 85054, 'HYOO' => 72239, 'SHOO' => 72266, 'KKUU' => 86590, 'PYUU' => 71721, 'GYOO' => 72275, 'NYUU' => 71734, 'BYOO' => 72238, 'tchi' => 40094, 'TTSU' => 14654, 'SSOO' => 81982, 'SSAA' => 84030, 'TTEE' => 80702, 'MYAA' => 73250, 'sshi' => 43678, 'KKAA' => 87614, 'ttsu' => 39326, 'BYUU' => 71726, 'PPOO' => 73790, 'GYAA' => 73299, 'NYAA' => 73270, 'SSHI' => 19006, 'RYUU' => 71703, 'TTOO' => 79166, 'HYUU' => 71727, 'RYAA' => 73239, 'TTAA' => 82494, 'SSEE' => 83518, 'BYAA' => 73262, 'SSUU' => 83006, 'PYAA' => 73257, 'MYOO' => 72226, 'NYOO' => 72246, 'SHUU' => 71754, 'PPII' => 76094, 'KKII' => 86078, 'KYUU' => 71760, 'KKOO' => 85566, 'PPAA' => 76862, 'HYAA' => 73263, 'CHOO' => 72252, 'TCHI' => 15422, 'GYUU' => 71763, 'KYAA' => 73296, 'CHUU' => 71740, 'KYOO' => 72272, 'PPEE' => 75582, 'PPUU' => 76350, 'CHAA' => 73276, 'SHAA' => 73290, 'MYUU' => 71714, 'PYOO' => 72233, 'pya' => 32393, 'pyo' => 31369, 'pyu' => 30857, 'KWO' => 21586, 'KWI' => 24146, 'KWE' => 23122, 'KWA' => 23634, 'mya' => 32386, 'myo' => 31362, 'myu' => 30850, 'DUU' => 88122, 'gyu' => 30899, 'gyo' => 31411, 'gya' => 32435, 'JUU' => 71749, 'ppu' => 35486, 'ppo' => 32926, 'ppi' => 35230, 'ppe' => 34718, 'ppa' => 35998, 'SSA' => 18494, 'SSE' => 17982, 'SSO' => 16446, 'SSU' => 17470, 'SHE' => 23114, 'WOO' => 87131, 'sha' => 32426, 'nya' => 32406, 'kke' => 44190, 'kki' => 45214, 'CHE' => 23100, 'bya' => 32398, 'JAA' => 73285, 'byo' => 31374, 'byu' => 30862, 'tte' => 39838, 'nyu' => 30870, 'tta' => 41630, 'tto' => 38302, 'DII' => 89658, 'sso' => 41118, 'kya' => 32432, 'kka' => 46750, 'ryu' => 30839, 'PPU' => 10814, 'nyo' => 31382, 'kku' => 45726, 'rya' => 32375, 'PPI' => 10558, 'PPE' => 10046, 'PPA' => 11326, 'ryo' => 31351, 'kyu' => 30896, 'kyo' => 31408, 'JOO' => 72261, 'chu' => 30876, 'cho' => 31388, 'cha' => 32412, 'GWI' => 24141, 'GWO' => 21581, 'GWA' => 23629, 'GWE' => 23117, 'KKA' => 22078, 'KKE' => 19518, 'KKI' => 20542, 'KKO' => 20030, 'KKU' => 21054, 'TTE' => 15166, 'TTA' => 16958, 'TTO' => 13630, 'TSA' => 23609, 'TSE' => 23097, 'TSI' => 24121, 'TSO' => 21561, 'sho' => 31402, 'kko' => 44702, 'hyu' => 30863, 'hyo' => 31375, 'shu' => 30890, 'hya' => 32399, 'ssa' => 43166, 'ssu' => 42142, 'sse' => 42654, 'RYA' => 7703, 'SHO' => 6730, 'TYU' => 6203, 'PYA' => 7721, 'PYO' => 6697, '}' => 242, 'PYU' => 6185, 'CHU' => 6204, 'CHO' => 6716, 'TI' => 24123, 'u' => 187, 'CHA' => 7740, 'MYA' => 7714, 'MYO' => 6690, 'MYU' => 6178, 'm' => 110, 'VYU' => 6153, 'ju' => 30885, 'GYO' => 6739, 'GYA' => 7763, 'e' => 181, 'VO' => 21513, 'VI' => 24073, 'VE' => 23049, 'BYU' => 6190, ']' => 240, 'VA' => 23561, 'PPO' => 8254, 'DYU' => 6202, 'HYU' => 6191, 'XE' => 90, 'HYO' => 6703, 'YE' => 23129, 'HYA' => 7727, 'FO' => 21544, 'XA' => 92, 'FI' => 24104, 'FE' => 23080, 'CHII' => 316, 'FA' => 23592, 'XU' => 88, 'SHA' => 7754, 'ja' => 32421, 'jo' => 31397, 'RYU' => 6167, 'TA' => 66, 'SHU' => 6218, 'BYA' => 7726, 'BYO' => 6702, 'xtsu' => 158, 'TE' => 59, 'KYU' => 6224, 'KYA' => 7760, 'KYO' => 6736, 'NYA' => 7734, '5' => 200, 'JE' => 23109, 'NYU' => 6198, 'WI' => 24155, 'WE' => 23131, 'TO' => 53, 'WO' => 21595, 'RYO' => 6679, 'ROO' => 272, 'HOO' => 294, 'XTSU' => 62, 'DEE' => 314, 'DAA' => 317, 'DOO' => 308, 'xwa' => 115, 'ZEE' => 321, 'MEE' => 284, 'YAA' => 281, 'SEE' => 326, 'REE' => 273, 'SUU' => 324, 'xya' => 126, 'ZUU' => 327, 'MUU' => 285, 'KEE' => 332, 'xyo' => 122, 'ZAA' => 331, 'PEE' => 295, 'GOO' => 329, 'GII' => 339, 'FUU' => 296, 'YOO' => 277, 'KAA' => 342, 'HII' => 303, 'NEE' => 304, 'tsu' => 153, 'SAA' => 328, 'xyu' => 120, 'BOO' => 289, 'NAA' => 311, 'MII' => 290, 'BII' => 302, 'JII' => 325, 'GAA' => 337, 'MOO' => 287, 'SOO' => 320, 'BAA' => 301, 'TEE' => 315, 'PUU' => 298, 'HEE' => 293, 'WAA' => 274, 'TOO' => 309, 'KUU' => 338, 'chi' => 156, 'KOO' => 334, 'RUU' => 278, 'RAA' => 276, 'NUU' => 305, 'NOO' => 307, 'POO' => 288, 'ZOO' => 323, 'BEE' => 292, 'PII' => 297, 'GEE' => 335, 'BUU' => 299, 'GUU' => 333, 'shi' => 170, 'KII' => 336, 'MAA' => 291, 'NII' => 310, 'HAA' => 306, 'RII' => 279, 'TAA' => 322, 'JA' => 7749, 'JO' => 6725, 'PAA' => 300, 'YUU' => 283, 'JU' => 6213, 'ku' => 178, 'UU' => 347, "n'" => 110, 'ki' => 176, 'ke' => 172, 'n-' => 110, 'ka' => 182, 'AA' => 351, 'nu' => 145, 'ne' => 144, 'na' => 151, 'no' => 147, 'ni' => 150, 'ko' => 174, 'he' => 133, 'ha' => 146, 'ho' => 134, 'hi' => 143, 'pe' => 135, 'XWA' => 19, 'xu' => 184, 'xe' => 186, 'xa' => 188, 'xo' => 180, 'xi' => 190, 'XYO' => 26, 'pu' => 138, 'II' => 345, 'SHI' => 74, 'bu' => 139, 'bi' => 142, 'bo' => 129, 'EE' => 341, 'ba' => 141, 'be' => 132, 'ri' => 119, 'ro' => 112, 'ra' => 116, 're' => 113, 'fu' => 136, 'ru' => 118, 'OO' => 343, 'XYU' => 24, 'yu' => 123, 'CHI' => 60, 'ya' => 121, 'yo' => 117, '[[' => 237, '>>' => 246, 'se' => 166, 'so' => 160, 'su' => 164, '<<' => 247, 'mu' => 125, 'mi' => 130, 'mo' => 127, 'sa' => 168, 'ma' => 131, 'me' => 124, 'po' => 128, 'pi' => 137, 'pa' => 140, 'ji' => 165, 'wo' => 111, 'wa' => 114, 'TSU' => 57, 'zu' => 167, 'za' => 171, 'ze' => 161, ']]' => 236, 'zo' => 163, 'XYA' => 30, 'du' => 152, 'da' => 157, 'de' => 154, 'di' => 159, 'do' => 148, 'ta' => 162, 'te' => 155, 'to' => 149, 'gi' => 179, 'go' => 169, 'ga' => 177, 'ge' => 175, 'gu' => 173, 'XO' => 84, 'DA' => 61, 'DE' => 58, '-' => 1, 'DO' => 52, '>' => 244, 'KU' => 82, 'KO' => 78, 'KE' => 76, 'KA' => 86, "N'" => 14, 'N-' => 14, 'XI' => 94, 'a' => 191, 'NU' => 49, '2' => 207, 'NE' => 48, 'NA' => 55, 'NO' => 51, 'NI' => 54, '.' => 255, 'RE' => 17, 'o' => 183, '_' => 226, '?' => 194, '7' => 202, 'HE' => 37, 'HA' => 50, 'HO' => 38, 'HI' => 47, 'RI' => 23, 'RA' => 20, ',' => 252, 'RU' => 22, 'BU' => 43, 'BI' => 46, 'BO' => 33, 'BA' => 45, 'BE' => 36, '<' => 245, 'i' => 185, '9' => 196, '1' => 204, ')' => 212, '!' => 220, 'YU' => 27, 'YA' => 25, 'YO' => 21, '~' => 221, 'SE' => 70, 'SA' => 72, 'SO' => 64, 'n' => 110, 'SU' => 68, 'RO' => 16, '^' => 227, '4' => 201, '6' => 203, '0' => 205, 'FU' => 40, '{' => 243, 'MU' => 29, 'MI' => 34, 'MO' => 31, 'MA' => 35, 'ME' => 28, '[' => 241, 'ZU' => 71, 'ZA' => 75, 'ZE' => 65, 'ZO' => 67, 'PO' => 32, 'PI' => 41, 'PE' => 39, 'PA' => 44, '3' => 206, 'PU' => 42, 'KI' => 80, 'GI' => 83, 'GO' => 73, 'GA' => 81, 'GE' => 79, 'GU' => 77, '8' => 197, '(' => 213, ' ' => 253, 'JI' => 69, 'WA' => 18, 'U' => 91, 'M' => 14, 'O' => 87, 'E' => 85, 'VU' => 9, 'I' => 89, 'A' => 95, 'N' => 14, '*' => 6); $output = ""; $tries = array_unique(array_map("strlen", array_keys($table))); rsort($tries); while ($input) { $success = FALSE; foreach($tries as $length) { if (strlen($input) < $length) continue; $kana = $table[substr($input, 0, $length)]; if ($kana) { while ($kana) { $c = ($kana & 0xFF) ^ 253; $kana >>= 8; $c = ($c == 0x20 ? 0xFF5E : $c + (($c >= 0x1E && $c <= 0x3F) ? ($c <= 0x1F ? 0xFF20 : 0xFEE0) : 0x3000)); $output .= chr((($c & 0xF000) >> 12) | 0xE0); $output .= chr((($c & 0x0FC0) >> 6) | 0x80); $output .= chr( ($c & 0x003F) | 0x80); } $input = substr($input, $length); $success = TRUE; break; } } if (!$success) { $output .= substr($input, 0, 1); $input = substr($input, 1); } } return $output; } $romaji = $_REQUEST['r']; header('Content-Type: text/html; charset=utf-8'); echo "\n"; ?>
Kana ChameleonQuick and dirty kana conversion by Gary Benson |
|
Notes ยปUse lowercase for hiragana and uppercase for katakana: "watashihaGARII*BENSONdesu" converts to . Use apostrophes or hyphens to separate ambiguous 'n's; to get you must enter "ten'in" or "ten-in". This is not necessary for unambiguous ones: "konnichiha" and "kon'nichiha" both end up as . Send bug reports or comments to gary@inauspicious.org. |