Comment 16 for bug 1411404

Revision history for this message
Rimas Kudelis (rq) wrote :

> Ir vis tik perkoduoti tiesiogiai negalima.

Klysti, galima. :)

> O tai reiškia, kad taisyklėse (ir kiek matau, kad būtent taisyklių skaičiukuose: pradžia ir ilgis) įsiūta koduotės specifika, o konkrečiai multibaitiniai reikalai.

Ne, skaičiukai reiškia tai, ką aš sakiau. Hyphen distribucijoje doc aplanke yra failas tb87nemeth.pdf. Jo antrame puslapyje tai aiškiai aprašyta. Štai grafinis paaiškinimas:
http://images.devs-on.net/Image/hNdDGcyJOUwiZyF2-Region.png

O štai – tekstinis:
The hyphenation patterns can allow and prohibit hyphenation breaks on multiple levels. Figure 1 shows the pattern matching on the word ‘algorithm’. The T E X English hyphenation patterns 4l1g4, lgo3, 1go, 2ith and 4h1m match this word and determine its
hyphenation. Only odd numbers mean hyphenation breaks. If two (or more) patterns have numbers in the same place, the highest number wins.

> hyphen substrings.pl:
> # 8 bit or UTF-8 character length (calculating right start position for discretionary hyphenation)
> sub enclen {
> my $nonchar = 0;
> my $len = length($_[0]);
> if ($encoding eq "UTF-8") {
> # length of an UTF-8 string equals to the count of the characters not started with '10' bits
> for ($i = 0; $i < $len; $i++) {
> if ((ord(substr($_[0], $i, 1)) >> 6) == 2) { $nonchar++; }
> }
> }
> return $len - $nonchar;
> }

Nežinau, kam šita funkcija naudojama, bet ji skaičiuoja UTF-8 eilutėje esančių simbolių kiekį, remdamasi UTF-8 koduotės struktūra – pirmasis simbolio baitas niekada neprasideda bitais 10, tuo tarpu visi tolesni simbolio baitai visada prasideda būtent šiais bitais: https://en.wikipedia.org/wiki/UTF-8#Description . Remiantis šia savybe, simbolių kiekį eilutėje galima apskaičiuoti, suskaičiuojant visus baitus, kurie prasideda kitokia nei 10 bitų seka.