Hi predrag,

One separate task for my site in Cyrillic will be IDN encoding

I just wanted to point out the power of CPAN. Perl and CPAN have been around for a long time and two of several areas where Perl excels is text processing and web development. I've already linked you to several HTML and XML processing modules, and a quick search on CPAN for "translit" is what gave me, among other things, Lingua::Translit, and a quick search for "IDN" shows me Net::IDN::Encode, again just one module among several.

use warnings; use strict; use open qw/:std :utf8/; use Lingua::Translit; my $tr = new Lingua::Translit("ISO/R 9"); my $txt = "\x{0441}\x{0440}\x{043F}\x{0441}\x{043A}\x{0438}"; my $latin = $tr->translit($txt); my $cyrillic = $tr->translit_reverse($latin); die "text mismatch" unless $txt eq $cyrillic; print "$latin <-> $cyrillic\n"; use Net::IDN::Encode qw/domain_to_ascii domain_to_unicode/; my $idn = "\x{0442}\x{0435}\x{0441}\x{0442}.\x{0441}\x{0440}\x{0431}"; my $asc = domain_to_ascii($idn); my $dom = domain_to_unicode("xn--e1aybc.xn--90a3ac"); die "domain mismatch" unless $idn eq $dom; print "$asc <-> $dom\n";

Output:

srpski <-> српски
xn--e1aybc.xn--90a3ac <-> тест.срб

Note: I did not verify that the "ISO/R 9" transliteration table is identical to the Serbian / Cyrillic transliteration table you're using, but at least Wikipedia says it's suitable.

Regards,
-- Hauke D


In reply to Re^8: Begginer's question: If loops one after the other. Is that code correct? by haukex
in thread Begginer's question: If loops one after the other. Is that code correct? by predrag

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.