X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=banana%2Ftext.func.inc.php;fp=banana%2Ftext.func.inc.php;h=483d281e423a1cfb61d73e8bdc7d4fd113fe5d9a;hb=52d7843e9f91ee0350fbab92a924b365ea32d9cf;hp=822fd1f5ab8e46e06d5120037c51b6335198b19b;hpb=3958da5df280bd8b4125ca6013c3fda9f538ae96;p=banana.git diff --git a/banana/text.func.inc.php b/banana/text.func.inc.php index 822fd1f..483d281 100644 --- a/banana/text.func.inc.php +++ b/banana/text.func.inc.php @@ -1,114 +1,114 @@ -= 240) && ($asciiPos <= 255)) // 4 chars representing one unicode character - $i=4; - else if (($asciiPos >= 224) && ($asciiPos <= 239)) // 3 chars representing one unicode character - $i=3; - else if (($asciiPos >= 192) && ($asciiPos <= 223)) // 2 chars representing one unicode character - $i=2; - else // 1 char (lower ascii) - $i=1; - $thisLetter = substr($source, $pos, $i); - $pos += $i; - - // process the string representing the letter to a unicode entity - $thisLen = strlen($thisLetter); - $thisPos = 0; - $decimalCode = 0; - while ($thisPos < $thisLen) - { - $thisCharOrd = ord(substr($thisLetter, $thisPos, 1)); - if ($thisPos == 0) - { - $charNum = intval($thisCharOrd - $decrement[$thisLen]); - $decimalCode += ($charNum << $shift[$thisLen][$thisPos]); - } - else - { - $charNum = intval($thisCharOrd - 128); - $decimalCode += ($charNum << $shift[$thisLen][$thisPos]); - } - - $thisPos++; - } - - $encodedLetter = '&#'. str_pad($decimalCode, ($thisLen==1)?3:5, '0', STR_PAD_LEFT).';'; - $encodedString .= $encodedLetter; - } - - return $encodedString; -} - -// vim:set et sw=4 sts=4 ts=4 enc=utf-8: -?> += 240) && ($asciiPos <= 255)) // 4 chars representing one unicode character + $i=4; + else if (($asciiPos >= 224) && ($asciiPos <= 239)) // 3 chars representing one unicode character + $i=3; + else if (($asciiPos >= 192) && ($asciiPos <= 223)) // 2 chars representing one unicode character + $i=2; + else // 1 char (lower ascii) + $i=1; + $thisLetter = substr($source, $pos, $i); + $pos += $i; + + // process the string representing the letter to a unicode entity + $thisLen = strlen($thisLetter); + $thisPos = 0; + $decimalCode = 0; + while ($thisPos < $thisLen) + { + $thisCharOrd = ord(substr($thisLetter, $thisPos, 1)); + if ($thisPos == 0) + { + $charNum = intval($thisCharOrd - $decrement[$thisLen]); + $decimalCode += ($charNum << $shift[$thisLen][$thisPos]); + } + else + { + $charNum = intval($thisCharOrd - 128); + $decimalCode += ($charNum << $shift[$thisLen][$thisPos]); + } + + $thisPos++; + } + + $encodedLetter = '&#'. str_pad($decimalCode, ($thisLen==1)?3:5, '0', STR_PAD_LEFT).';'; + $encodedString .= $encodedLetter; + } + + return $encodedString; +} + +// vim:set et sw=4 sts=4 ts=4 enc=utf-8: +?>