Line 22 | Line 22 |
---|
setlocale(LC_CTYPE, 'C');
/**
|
setlocale(LC_CTYPE, 'C');
/**
|
* Setup the UTF-8 portability layer
| * UTF-8 portability layer is provided by * symfony/polyfill-mbstring, symfony/polyfill-intl-normalizer, symfony/polyfill-php72
|
*/
|
*/
|
Patchwork\Utf8\Bootup::initUtf8Encode(); Patchwork\Utf8\Bootup::initMbstring(); Patchwork\Utf8\Bootup::initIntl();
| |
/** * UTF-8 tools
| /** * UTF-8 tools
|
Line 71 | Line 69 |
---|
else { return mb_strpos($str, $needle, $offset);
|
else { return mb_strpos($str, $needle, $offset);
|
| } }
/** * UTF-8 aware alternative to stripos * @ignore */ function utf8_stripos($str, $needle, $offset = null) { if (is_null($offset)) { return mb_stripos($str, $needle); } else { return mb_stripos($str, $needle, $offset);
|
} }
| } }
|
Line 171 | Line 185 |
---|
* Make a string's first character uppercase * * @author Harry Fuecks
|
* Make a string's first character uppercase * * @author Harry Fuecks
|
* @param string
| * @param string $str
|
* @return string with first character as upper case (if applicable) */ function utf8_ucfirst($str)
| * @return string with first character as upper case (if applicable) */ function utf8_ucfirst($str)
|
Line 415 | Line 429 |
---|
// Trigger an error?! Fow now just give bad data :-( trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR);
|
// Trigger an error?! Fow now just give bad data :-( trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR);
|
| }
/** * Replace some special UTF-8 chars that are not in ASCII with their UCR. * using their Numeric Character Reference's Hexadecimal notation. * * Doesn't interfere with Japanese or Cyrillic etc. * Unicode character visualization will depend on the character support * of your web browser and the fonts installed on your system. * * @see https://en.wikibooks.org/wiki/Unicode/Character_reference/1F000-1FFFF * * @param string $text UTF-8 string in NFC * @return string ASCII string using NCR for non-ASCII chars */ function utf8_encode_ucr($text) { return preg_replace_callback('/[\\xF0-\\xF4].../', 'utf8_encode_ncr_callback', $text);
|
}
/** * Replace all UTF-8 chars that are not in ASCII with their NCR
|
}
/** * Replace all UTF-8 chars that are not in ASCII with their NCR
|
| * using their Numeric Character Reference's Hexadecimal notation.
|
* * @param string $text UTF-8 string in NFC * @return string ASCII string using NCRs for non-ASCII chars
| * * @param string $text UTF-8 string in NFC * @return string ASCII string using NCRs for non-ASCII chars
|
Line 429 | Line 462 |
---|
}
/**
|
}
/**
|
* Callback used in encode_ncr()
| * Callback used in utf8_encode_ncr() and utf8_encode_ucr()
|
* * Takes a UTF-8 char and replaces it with its NCR. Attention, $m is an array *
| * * Takes a UTF-8 char and replaces it with its NCR. Attention, $m is an array *
|