Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Comment problem (charset)
10-23-2011, 10:05 PM
Post: #1
Comment problem (charset)
Hello! Thank you for cool gallery script!
I've got a problem: when I'm posting comments in russian language and then try to read it, I get it in wrong charset.
Your demo works well, russian language is accepted correctly.
I did a little investigation: comment is saved in .txt file in utf-8 charset, but when it is read to display it is in cp1251. So if I manually convert saved comment to ANSI then comment is displayed correctly.

Please, tell how to fix this.
Thank you!
Find all posts by this user
Quote this message in a reply
10-24-2011, 08:38 AM
Post: #2
RE: Comment problem (charset)
Your html-document where the gallery is inserted has to be utf-8 saved. Also don't forget to add the metatag about the correct doctype:
PHP Code:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

KoschtIT Image Gallery developer
Visit this user's website Find all posts by this user
Quote this message in a reply
10-24-2011, 04:22 PM
Post: #3
RE: Comment problem (charset)
All of my files are saved in utf-8.
Here is the code of the php page:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?php
header('Content-Type: text/html; charset=utf-8');
// здесь контейнер для содержимого
include_once("ki_include.php");
$text = "<div class='koschtitgallery' title='sample'></div>";
$text .= "<div class='koschtitgallery' title='test'></div>";
$text .= "<div class='koschtitgallery' title='gal1'></div>";
echo $text;
?>
Comments are saved in utf-8 (checked with notepad++), but when it is read, it is read like ANSI. When I converted comment file to ANSI with notepad++ - comments looks correctly.
What problem it can be?
Find all posts by this user
Quote this message in a reply
10-24-2011, 06:16 PM
Post: #4
RE: Comment problem (charset)
What "default_charset" is set in your PHP configuration? Mine is either not set at all or UTF-8. Both configurations are working correctly with the example-page you provided. My comments are also saved in utf-8.

KoschtIT Image Gallery developer
Visit this user's website Find all posts by this user
Quote this message in a reply
10-24-2011, 09:35 PM (This post was last modified: 10-24-2011 10:19 PM by Destroyer.)
Post: #5
RE: Comment problem (charset)
Here is my php.ini part:
Code:
; PHP's built-in default is text/html
default_mimetype = "text/html"
;default_charset = "iso-8859-1"
So no default charset is set and if I add
Code:
default_charset = "utf-8"
nothing changes (I didn't forget to restart apache).

I even tried to put .htaccess file with "AddDefaultCharset utf-8" near index.php (I showed the code of this file above), but nothing helps.

But when I uploaded sample script to the hosting - it works well, charset is correct.
After adding "ini_set("default_charset", "utf-8");" to index.php phpinfo();
on local server, it shows - default_charset local val.:utf-8 Master val.: windows-1251.
On hosting server it shows - default_charset local val.:no value Master val.: no value
I've got windows server and default charset is cp1251 here, even if I change it in php.ini.

Any suggestions what is wrong in my local server configuration?

[/code]
Finally I found, that I was editing wrong php.ini file. I changed to default_charset = "utf-8" and the problem is solved.

Thanks!
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)