I'm editing a site for someone, and they are using wordpress, which I really don't like, but hey, I didn't pick it. I need to change some text on their page to Portuguese characters such as Ç or Ã. I've read in a few places, that I need to change from ASCII to UTF-8, but I'm not sure where to do that, or how to do it across the whole site. Am I changing a database to UTF-8, or each individual php file? Hopefully somebody knows, thanks.

Thanks to the comments below, I have most of the site running correctly, but now I can't get the foreign characters in just certain spots, for example, anywhere I'm using code like this inside of a .php file.

$email_list = do_shortcode('[pl_modal title="Join our email list" label="<img class=\'\' title=\'Join our email list\' src=\'/wp-content/uploads/2013/02/email_icon.png\'  /><br /><span>INSCREVA-SE A NOSSA<br />LISTA DE E-MAILS</span>"][gravityform id=1 title=false][/pl_modal]');

The portugese in the above code, if I add non english characters, I get a constantly loading error. More code, that does the same thing.

'<div class="graphicbuttons_cont">' .
                                '<a href="https://maps.google.com/maps?saddr={19}&daddr={20}" target="_blank">
                                    <img title="Get Store Directions" src="/wp-content/uploads/2013/02/getdirection_icon.png"  /><br /><span>LOCALIZACOES <br><br /> </span>
                                </a>' .
                            '</div>' .

the LOCALIZACOES in above text, should have special characters, but it won't hold them. I have changed everything to UTF8 that I can find. But there is nothing inside this specific file that says utf8, should I add something?

有帮助吗?

解决方案

Alright, so, if you change everything to utf8, and on wordpress all of your html code is in php files, the way I've used to use special characters is this

thesauruslex.com/typo/eng/enghtml.htm

for example

<span>LOCALIZA&CcedilOES  </span>

will output LOCALIZAÇOES

Thanks to everyone for the help, I guess I could have been clearer on the original question.

其他提示

Everything in your application needs to be UTF-8.

  • Your MySQL string columns should be utf8_unicode_ci.
  • You need to ensure that your MySQL connection charset is set to UTF-8. You can do this via the query SET NAMES utf8 (run once after every connection) or you can modify your my.cnf file if you have access to it.
  • Your web pages should be served with <meta charset="utf-8">
  • You can check and validate what kind of input you're receiving by using the PHP function mb_check_encoding.
  • There's also a PHP ini setting called default-charset.

This can be changed two ways depending on your theme file. In the header.php file this should be near the top:

<meta charset="<?php bloginfo('charset'); ?>">

You use to be able to change this in the wordpress backend under settings -> reading. I believe now you have to manually change this in the wp-config.php file:

define('DB_CHARSET', 'utf8');
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top