<?
/**
* Get the superset of UTF-8 characters for ASCII characters.
*
* @param string $ascii If set, return a one dimensional array for the given ASCII character. If empty (default), return a two dimensional array with all mappings.
* @return array
*/
function browsableUtf8Characters( $ascii = "" )
{
// Convert to ISO-8859-1 to ensure a 1-byte string
$myString = utf8_decode( "0123456789abcdefghijklmnopqrstuvwxyzàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿß" );
$charArray = array();
for( $i=0; $i<strlen($myString) ; ++$i )
{
// Transliterate to ASCII and trim anything but a-z.
$charSimple = trim( iconv( "ISO-8859-1", "ASCII//TRANSLIT", $myString[$i] ), "?!<>~^`'\"" );
if ( strlen($charSimple) )
{
$intVal = (int)$charSimple[0];
$charKey = ("$intVal" == "$charSimple[0]") ? "0" : $charSimple[0];
if ( $ascii!="" && $charKey != $ascii )
continue;
if ( $ascii != "" )
$charArray[] = utf8_encode( $myString[$i] );
else
$charArray[$charKey][] = utf8_encode( $myString[$i] );
}
}
// print_r( $charArray );
return $charArray;
}
?>