note 108700 modified in function.ucfirst by danbrown
| From: | danbrown@php.net | Date: | Fri, 18 May 2012 16:38:49 +0000 |
| Subject: | note 108700 modified in function.ucfirst by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-188059@lists.php.net to get a copy of this message | ||
In case you need a French version of ucfirst: "été
indien" => "Eté indien" "ça
va?" => "Ãa
va?" <?php function
frenchUcfirst($v) { $lowCase =
"\\xE0\\xE1\\xE2\\xE3\\xE4\\xE5\\xE7\\xE8\\xE9\\xEA\\xEB\\xEC\\xED\\xEE\\xEF";
$lowCase .=
"\\xF1\\xF2\\xF3\\xF4\\xF5\\xF6\\xF8\\xF9\\xFA\\xFB\\xFC\\xFD\\xFF\\u0161";
$upperCase = "AAAAAA\\xC7EEEEIIIINOOOOOOUUUUYYS"; return
strtoupper(strtr(substr($v, 0, 1), $lowCase, $upperCase)) . substr($v,
1); } ?> Note: -
Latin non french accented characters follow the same
rule: "ändå" =>
"Andå" - Non ASCII characters in the function are in HEX format
to avoid encoding issue...
--was--
In case you need a French version of ucfirst:
"été indien" => "Eté indien"
"ça va?" => "Ãa va?"
function frenchUcfirst($v) {
$lowCase = "\xE0\xE1\xE2\xE3\xE4\xE5\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF";
$lowCase .= "\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFF\u0161";
$upperCase = "AAAAAA\xC7EEEEIIIINOOOOOOUUUUYYS";
return strtoupper(strtr(substr($v, 0, 1), $lowCase, $upperCase)) . substr($v, 1);
}
Note:
- Latin non french accented characters follow the same rule:
"ändå" => "Andå"
- Non ASCII characters in the function are in HEX format to avoid encoding issue...
http://php.net/manual/en/function.ucfirst.php