0

I have characters that use spanish characters such as in the word Rosé. I need to store this into my (wordpress) database and store it so I can display it later. How can I store/encode these characters so I can display the text correctly when needed on the site?

This question is different than the one suggested as this pertains to a Wordpress database. I have limited control over what I can do from a server level with the host. The suggested questions deals with setting up Apache and PHP to a custom level, something that I won't have access to on production.

dcp3450
  • 10,959
  • 23
  • 58
  • 110
  • 1
    Possible duplicate of [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – Marc B Feb 03 '16 at 19:12

1 Answers1

0

You should use UTF8 encoding in your site.

ericpap
  • 2,917
  • 5
  • 33
  • 52
  • the database and tables are all UTF8 – dcp3450 Feb 03 '16 at 19:24
  • If I do `mb_convert_encoding($str,'UTF-8')` it stores the values but the characters are converted incorrectly. – dcp3450 Feb 03 '16 at 19:25
  • Have you ser UTF encoding on your site? something like " " – ericpap Feb 03 '16 at 19:31
  • It's not an issue of how it's displayed in the page, it's issue of saving to the database. – dcp3450 Feb 03 '16 at 19:35
  • Try this: open your wordpress wp-config.php file and remove this two lines define(‘DB_CHARSET’, ‘utf8′); define(‘DB_COLLATE’, ”); – ericpap Feb 03 '16 at 19:43
  • Also ensure that your text editor does not save your file with ANSI encoding – ericpap Feb 03 '16 at 19:44
  • I removed those lines, and I get the same thing: nothing insert to the database. If I use `mb_convert_encoding($str,'UTF-8')` it inserts but the wrong characters are used. If I use `htmlentities` it inserts but anything converted is blank. – dcp3450 Feb 03 '16 at 19:49
  • I'm not using the editor. This text is coming from a CSV file. – dcp3450 Feb 03 '16 at 19:49
  • For example `Extra Añejo` is being stored and displayed as `A¤ejo` the "ñ" is being encoded wrong. – dcp3450 Feb 03 '16 at 20:00