Grab items from an array by converting to UTF8

Asked

Viewed 53 times

0

Hello! My problem is this: I have a list of values in an external php file and when I use a include to call the values in my template the accented characters are replaced by queries. I wonder if there is a function or another way to get the values encoding them to UTF8.

Example:

$lang = array();
$lang['LANGUAGE'] = 'português';
$lang['HOME'] = 'início';

and within the template call so:

include 'lista.php';
echo $lang['HOME'];

Hence appears Inic? the

NOTE: I used Notepad++ to format them in UTF-8 without good and solved in most words, however in texts from inside buttons did not work. See in the image:

inserir a descrição da imagem aqui

  • tried to save the file with utf-8 without good? I saved so, I stopped having problems with accent a long time after I started saving everything with utf-8 no good

  • Yes I used Notepad++ to format them and it worked in most sentences, however for the words inside buttons did not work.

  • inside the buttons? you say, input type button? tried to use this in the header of your <meta charset='utf-8 file' /> ?

  • I put the image in the question, see. In the header of my site the charset is ok. the error only occurs with words pulled from the external array of the.php list file, the words inside the template works normally.

  • Could you show me the link to your website? and try to put this code in include to see if it works <?php header('Content-Type: text/html; charset=utf-8'); include 'list.php'; ?>

  • Dude, I found a guy with a problem very similar to yours on this link http://forum.imasters.com.br/topic/283085-solved-accentucao-utf-8-e-iso/

  • Use wordpress. I will try this code there that you passed to see.

  • 1

    Try this on the link if you do not post the other http://br.phptherightway.com/#php_e_utf8 files

  • Usually it is server conflict with encoding, already solved this with ANSI instead of UTF-8 in the meta tag, another alternative is to encode the output example: utf8_encode($output);

  • Felipe already tried those two options there that you mentioned, also did not give. I’m trying locally with easy php and you said it might be server conflict, is that why it’s not working?

Show 5 more comments

1 answer

0


Solved. As I had said earlier, I used Notepad++ to format them in UTF-8 without good and solved in most words, except in words inside buttons.

I went back and formatted again in Notepad++, this time in UTF-8 and it worked. Why I do not know, but the important thing is that I solved.

I thank everyone who gave me strength and opted in this complicated process that takes the peace of many people. Thanks guys!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.