Jump to content

Recommended Posts

see http://www.ivoiresondage.com/index.php and select a region from the drop down box. for any department that comes from a database with special characters (accent marks), ? will show up instead of the character. It doesn't do this for the regions...but I don't think it's related to the AJAX. Anyone?

Link to comment
https://forums.phpfreaks.com/topic/93358-help-help-help/
Share on other sites

PHP supports a few different ways of converting the data. iconv tends to work best for most.

 


  • mbstring extension: mb_convert_encoding(string, to, from)

  • iconv extension: iconv(from, to, string)

  • recode extension: recode_string(request, string)

  • built-in function: utf8_encode(string) (converts from ISO-8859-1 to UTF-8)

 

So handling input might look something like this:

 

<?php
$test  = $_REQUEST['charset_check']; /* our test field */
$field = $_REQUEST['field']; /* the data field */

if (bin2hex($test) == "c3a4e284a2c2ae") { /* UTF-8 for "ä™®" */
  /* Nothing to do: it's UTF-8! */
} elseif (bin2hex($test) == "e499ae") { /* Windows-1252 */
  $field = iconv("windows-1252", "utf-8", $field);
} else {
  die("Sorry, I didn't understand the character set of the data you sent!");
}

mysql_query("INSERT INTO table SET field = _utf8'" . addslashes($field) . "'")
  or die("INSERT failed: " . mysql_error());

 

Link to comment
https://forums.phpfreaks.com/topic/93358-help-help-help/#findComment-478209
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.