Current time: 04-24-2014, 12:43 PM Hello There, Guest! (LoginRegister)

Post Reply 
Problems with characters in php
06-27-2007, 02:48 AM
Post: #1
Problems with characters in php
Hi everybody.

When I have a simple php file with something like this:

echo "español"

it prints in the screen:

"espa?ol"

the same with accents like áéíóú and other characters.

Do you know how to solve this?

I have this meta:
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/>

in the HTML so I think that the problem is because other things...

In the server the files are fine, but when I execute the php it doesn't return the expected result.

Any idea about how to solve?
Visit this user's website Find all posts by this user
Quote this message in a reply
06-27-2007, 03:30 AM
Post: #2
Problems with characters in php
Easiest way is just to use the ascii code for it, try this one: ń

JagaLaw
Find all posts by this user
Quote this message in a reply
06-27-2007, 03:43 AM
Post: #3
Problems with characters in php
I know, this is good & ntilde ;

but what about when I receive data from the user with no format?

And is really really weird, because I have a file with this code:
<?php
echo "áéñ";
?>

and for instance is I call this way:
file.php?id=4

It display fine, but if I call
file.php?id=2

is not fine, and there is no treatment at all of the parameters (as you can see, one line of code...).
Visit this user's website Find all posts by this user
Quote this message in a reply
06-27-2007, 06:20 AM
Post: #4
Problems with characters in php
Use PHP to set the character encoding. Put this line at the beginning of each page:
Code:
<?php header("Content-Type: text/html; charset=utf-8"); ?>
You can also force all PHP files to be UTF-8 by default by adding this line to your .htaccess file:
Code:
AddCharset UTF-8 .php
--------
si-blog | Keystone Websites
Save $97 on yearly plans with promo code SCJESSEY97
Visit this user's website Find all posts by this user
Quote this message in a reply
06-27-2007, 08:09 AM
Post: #5
Problems with characters in php
are you sure your files are utf8? the default on windows systems is windows-1252

track7 - my dream-hosted site
Visit this user's website Find all posts by this user
Quote this message in a reply
06-27-2007, 09:45 AM
Post: #6
Problems with characters in php
As you say, that was the problem, files were not in UTF-8 format. Now everything works fine.

And there were also a cache problem, when the browser saw a page in a specified format it always used it from that moment.

Thank you all Wink
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: