Problems with charset UTF8

I have a problem with charset UTF8. When I set this charset for my page - I can use only english letters and can’t use cyrillic letters. But in datas from MySQL cyrillic letters display normal on web page. When I change charset to windows-1251 - cyrillic letters display normal on web site but cyrillic letters in data from MySQL don’t display normal.
In data from MySQL charset = UTF8, I can’t use Windows-1251 there.

Here a code, that displays data from MySQL on web page:

<!DOCTYPE html>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<p><a href="?addjoke">Press this link and you can add joke</a></p>
		<p> <?php 
                   $jok = "Jokes from database: ";
                   echo $jok; ?>

		<p>	<?php 
			foreach ($jokes as $joke): ?>
<form action="?deletejoke" method="post">
				<p><?php htmlout($joke['text']); ?> 
<input type="hidden" name="id" value="<?php echo $joke['id']; ?>"><input type="submit" value="Delete"> (author: <a href="mailto:<?php htmlout($joke['email']);?>"><?php
htmlout ($joke['name']); ?> </a> )
			</blockquote> </form>
			<?php endforeach; ?>

I will be very thankful for any help.

Make sure that the encoding you save the file with is also UTF-8.
If it is not you may have problems.
What editor do you use for code? That is where you will set the file encoding.

Editor that I use is Aptana studio. Files in folder in “notebook” from windows. I just set an expansion when create file - f.e. jokes.html.php.

If the file was created using Notepad then it is most likely using Windows encoding. Perhaps you can see if Aptana allows you to change the file encoding.

Thanks for your help, in Aptana file encoding was windows-1251, I set to utf8 and now it works.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.