I've got a string containing accented characters in a php
script. My script file is encoded in UTF-8
, without BOM
. But I can't manage to isolate the single accented characters without breaking them :
sample :
<!doctype html>
<html>
<head>
<meta charset='UTF-8'>
</head>
<body>
<?php
$myWord='Méditerranée'; // 12 characters long
echo strlen($myWord).'<br/>'; // shows 14
echo mb_strlen($myWord).'<br/>';// shows 12
$myWord=str_split($myWord);
echo count($myWord).'<br/>'; // shows 14
foreach($myWord as $rank=>$character) {
echo $character;
} // shows 'Méditerranée'
foreach($myWord as $rank=>$character) {
echo $character.' ';
} // shows 'M * * d i t e r r a n * * e '
/* each * is a black diamond with a question mark inside */