UpperToLowerR.t

From TORI
Jump to: navigation, search

UpperToLowerR.t is PHP routine that converts capital Russian caharacters to the lower case, except the first letter of each word.
Characters of other languages are not converted.

UpperToLowerR.t конвертирует только русские буквы, да и то лишь тогда, когда они представлены в кодировке Utf8 (see SomeU).
Латинские буквы, как буквы иных алфавитов (Греческие, Китайские, корейские и т.п.), а также всевозможные пьяные ёжики при этом столь же неконвертируемы, как советские рубли во время СССР: доллар стоил не 60 копеек, как врала советская пропаганда, а тюремного заключения или даже жизни.

Code

Routines uni.t should be loaded in order to php the code below:


<?php
include "uni.t";
$a=file_get_contents('input.txt');
$b=mb_str_split($a);
$N=count($b);
#echo $N, "\n";
for($i=0; $i<$N; $i++){$c[$i]=uniord($b[$i]);}

for($i=1; $i<$N; $i++)
{
        $A=$c[$i-1];
        $B=$c[$i];
        if(       $A>= hexdec("400") && $A< hexdec("460") )
        {
               if($B>= hexdec("410") && $B< hexdec("430") )  { $c[$i]+=32; }
          else if($B>= hexdec("400") && $B< hexdec("410") )  { $c[$i]+=80; }
        }
}

for($i=0; $i<$N; $i++)
{
        $D=unichr($c[$i]); 
        echo $D;
}

?>

Example of input.txt

The ENGLISH characters are not converted.

日本の カタカナ、ひたがな、 かんじ は おなじ でしょう。

РУССКИЕ СИМВОЛЫ долЖны быть приведены в соответстви с грамматикой. Чтобы если где бОльше, то НАФИГ.

Output

The ENGLISH characters are not converted.

日本の カタカナ、ひたがな、 かんじ は おなじ でしょう。

Русские Символы должны быть приведены в соответстви с грамматикой. Чтобы если где больше, то Нафиг.

Historic context

Some operational systems easy confuse the lowercase letters with the UPPERCASE LETTERS, especially if appear in filenames, and especially if the filename contains non-ascii characters. This makes difficult the automatic analysis of the texts. The stupid robots get confused, and, instead of to arrange the articles, do horrible things, especially with texts in foreign languages.

The Editor failed to program the conversion in some convenient language, like sed, as the Regular expression conversion. So, the complicated routine is suggested above.

References


Unfortunately, no analogy of this routine is found at the free-access sites.

Keywords

PHP, uni.t, Unicode, Utf8, SomeU