Dealing with both US alpha and French accentuated characters

I have a need to be able to enter in the same DB field both US characters and French accentuated char as the content could be in FR or US English.
 As is I tried to set my charset to utf-8
and DB field to utf-8 too

tried also before inserting utf8_encode($str) to no avail

here is the result for example I tried a 4 char words with accent on the 4th char
only the three first char are found in the field the last one is gone.
I thought it might be related to my CleanDb() safe insert function but that is not the case, so I have no idea.. any clue?
thanks
LVL 1
array007Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

eZovCommented:
Could you post or attach the results? Did you make test entering  values directly to DB?
0
array007Author Commented:
There are no results I can attach as it really is as explained
and YES the DB accepts direct insert with the accent
However the resulting output (site page) shows that "diamond" thing instead of the accentuated letter
but the page has a utf-8 charset so what could be wrong?
thanks
0
eZovCommented:
The best is to use example:http://www.vrelo.biz/testutf.php
Here you can see correct reading French accent from utf field.

I suppose you miss correct setting of character set of db connection:
mysql_set_charset('utf8',$link);

<?php
  $link = mysql_connect('mysql3.loosefoot.com', 'experts', 'experts')
or die("Unable to connect to server");

//echo 'Connected successfully';
mysql_select_db('expertsexchange', $link);

mysql_set_charset('utf8',$link);

//$re = mysql_query('SELECT * FROM testutf;')or die(mysql_error());
//while ($r = mysql_fetch_assoc($re)) {var_dump ($r); echo "<br />";};

?>

<html>
<!-- testutf.php
   Copyright (c) 2010 by Zov-Consulting  http://www.zov-consulting.biz/
-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<body>
<b>Read Test UTF</b><br/>
<?php
$re = mysql_query('SELECT testutf FROM testutf;',$link)or die(mysql_error());
while ($r = mysql_fetch_assoc($re)) { echo $r['testutf']."<br />";};    
?>
Here is var dump:<br/>
<?php
    $re = mysql_query('SELECT * FROM testutf;')or die(mysql_error());
while ($r = mysql_fetch_assoc($re)) {var_dump ($r); echo "<br />";};
?>
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

eZovCommented:
and DDL for table:
CREATE TABLE `testutf` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `testutf` VARCHAR(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MYISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
0
eZovCommented:
As I do not know which PHP version you use, this is older command to set connection charset:

mysql_query("SET NAMES 'utf8'",$link);

This is actually MySQL coomand.
0
array007Author Commented:
Thanks, well explained!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.