| Lingua-Cyrillic-Translit-ICAO documentation | Contained in the Lingua-Cyrillic-Translit-ICAO distribution. |
Lingua::Cyrillic::Translit::ICAO -- Cyrillic characters transliteration into ICAO Doc 9303
use Lingua::Cyrillic::Translit::ICAO qw/ cyr2icao /;
print cyr2icao('ukrainian', 'koi8-r');
Lingua::Cyrillic::Translit::ICAO can be used for transliteration of Cyrillic characters in conformance with ICAO Doc 9303 Recommendations.
This method converts $string from Cyrillic character set to ICAO transliteration.
Optional $language parameter allow to specify $string's language. Valid values are:
Other values are accepted but do not affect anything.
Optional $encoding parameter allows to specify $string's encoding (default is 'utf-8')
Serguei Trouchelle <stro@railways.dp.ua>
Copyright (c) 2007 Serguei Trouchelle. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Lingua::RU::Translit - Transliteration of Russian text to Latin symbols.
Lingua::UK::Translit - Transliteration of Ukrainian text to Latin symbols.
| Lingua-Cyrillic-Translit-ICAO documentation | Contained in the Lingua-Cyrillic-Translit-ICAO distribution. |
# Lingua/Cyrillic/Translit/ICAO.pm # # $Id: ICAO.pm 7 2009-09-16 15:41:34Z stro $ # # Copyright (c) 2007-2009 Serguei Trouchelle. All rights reserved. # # This program is free software; you can redistribute it and/or modify it # under the same terms as Perl itself. # History: # 1.05 2009/09/16 Changed 5.8.0 to 5.008 # 1.04 2007/07/07 use Encode in preference of Text::Iconv (thanks to Nikita Dedik) # Rate Text::Iconv Encode # Text::Iconv 13243/s -- -41% # Encode 22386/s 69% -- # 1.03 2007/07/05 use 5.8.0 added # 1.02 2007/07/04 POD fixes # 1.01 2007/07/02 Initial revision
package Lingua::Cyrillic::Translit::ICAO; require Exporter; use Config; use strict; use warnings; use 5.008; use utf8; use Encode; our @EXPORT = qw/ /; our @EXPORT_OK = qw/ cyr2icao /; our %EXPORT_TAGS = qw / /; our @ISA = qw/Exporter/; our $VERSION = '1.05'; my $table = q!1 1 Ð A Ð B Ð V Ð G Ð D Ð E Ð E Ð ZH Ð Z Ð I Ð I Ð I Ð K Ð L Ð M Ð N Ð O Ð P Ð R С S Т T У U Ф F Ð¥ KH Ц TS Ч CH Ш SH Щ SHCH Ы Y Ñ¢ IE Ð E Ю IU Я IA Ñ´ Y Ò G Ð U Ѫ U Ð G Ð D Ð DZ Ð J Ð K Ð LJ Ð NJ Òº C Ð DZ Ð IE Ð I а a б b в v г g д d е e Ñ e ж zh з z и i Ñ i й i к k л l м m н n о o п p Ñ r Ñ s Ñ t Ñ u Ñ f Ñ kh Ñ ts Ñ ch Ñ sh Ñ shch Ñ y Ñ£ ie Ñ e Ñ iu Ñ ia ѵ y Ò g Ñ u Ñ« u Ñ g Ñ d Ñ dz Ñ j Ñ k Ñ lj Ñ nj Ò» c Ñ dz Ñ ie Ñ i 2 2!; our %cyr2icao = split /\s+/, $table; # skip hard and soft signs $cyr2icao{'Ъ'} = ''; $cyr2icao{'Ñ'} = ''; $cyr2icao{'Ь'} = ''; $cyr2icao{'Ñ'} = '';
sub cyr2icao { my $val = shift; my $lang = shift; my $enc = shift; if ($enc) { $val = Encode::decode($enc, $val); } # else think of utf-8 utf8::decode($val); my $res = ''; foreach (0 .. length $val) { $_ = substr($val, $_, 1); $_ = 'H' if $_ eq 'Ð' and ($lang eq 'by' or $lang eq 'mk'); $_ = 'h' if $_ eq 'г' and ($lang eq 'by' or $lang eq 'mk'); $_ = 'IO' if $_ eq 'Ð' and $lang eq 'by'; $_ = 'io' if $_ eq 'Ñ' and $lang eq 'by'; $_ = 'Z' if $_ eq 'Ð' and $lang eq 'mk'; $_ = 'z' if $_ eq 'ж' and $lang eq 'mk'; $_ = 'Y' if $_ eq 'Ð' and $lang eq 'uk'; $_ = 'y' if $_ eq 'и' and $lang eq 'uk'; $_ = 'H' if $_ eq 'Ð¥' and $lang eq 'mk'; $_ = 'h' if $_ eq 'Ñ ' and $lang eq 'mk'; $_ = 'C' if $_ eq 'Ц' and $lang eq 'mk'; $_ = 'c' if $_ eq 'Ñ' and $lang eq 'mk'; $_ = 'C' if $_ eq 'Ч' and $lang eq 'mk'; $_ = 'c' if $_ eq 'Ñ' and $lang eq 'mk'; $_ = 'S' if $_ eq 'Ш' and $lang eq 'mk'; $_ = 's' if $_ eq 'Ñ' and $lang eq 'mk'; $_ = 'SHT' if $_ eq 'Щ' and $lang eq 'bg'; $_ = 'sht' if $_ eq 'Ñ' and $lang eq 'bg'; $_ = $cyr2icao{$_} if defined $cyr2icao{$_}; $res .= $_; } return $res; } 1;