[svn r21394] FS#306 - The multi-byte string library: Corrections in the comments about the transliteration function. Renaming a variable according to our rules.

skala
Ivan Tcholakov 16 years ago
parent 0c742d9a17
commit 511972892f
  1. 17
      main/inc/lib/multibyte_string_functions.lib.php

@ -1715,12 +1715,12 @@ function api_in_array_nocase($needle, $haystack, $strict = false, $encoding = nu
//----------------------------------------------------------------------------
// Transliteration, converting UTF-8 strings to ASCII strings
// Transliteration, converting ANSI and UTF-8 strings to ASCII strings
//----------------------------------------------------------------------------
/**
* Transliterates a UTF-8 input string to a plain ASCII string.
* Transliterates a string to a plain ASCII string.
*
* Example:
* echo api_transliterate(api_html_entity_decode(
@ -1730,8 +1730,9 @@ function api_in_array_nocase($needle, $haystack, $strict = false, $encoding = nu
* ENT_QUOTES, 'UTF-8'), 'UTF-8');
* The output should be: Fyodor Mihaylovich Dostoevkiy
*
* @param string $string The UTF-8 text input.
* @param string $string The input string.
* @param string $unknown Replacement character for unknown characters and illegal UTF-8 sequences.
* @param string $from_encoding The encoding of the input string. If it is omited, the platform character set is assumed.
* @return string Plain ASCII output.
*
* Based on Drupal's module "Transliteration", version 6.x-2.1, 09-JUN-2009:
@ -1761,12 +1762,12 @@ function api_transliterate($string, $unknown = '?', $from_encoding = null) {
return $string;
}
static $tailBytes;
static $tail_bytes;
if (!isset($tailBytes)) {
if (!isset($tail_bytes)) {
// Each UTF-8 head byte is followed by a certain
// number of tail bytes.
$tailBytes = array();
$tail_bytes = array();
for ($n = 0; $n < 256; $n++) {
if ($n < 0xc0) {
$remaining = 0;
@ -1788,7 +1789,7 @@ function api_transliterate($string, $unknown = '?', $from_encoding = null) {
} else {
$remaining = 0;
}
$tailBytes[chr($n)] = $remaining;
$tail_bytes[chr($n)] = $remaining;
}
}
@ -1821,7 +1822,7 @@ function api_transliterate($string, $unknown = '?', $from_encoding = null) {
for ($i = -1; --$len; ) {
$c = $str{++$i};
if ($remaining = $tailBytes[$c]) {
if ($remaining = $tail_bytes[$c]) {
// UTF-8 head byte!
$sequence = $head = $c;
do {

Loading…
Cancel
Save