Page 1 of 1

UTF-8 and session problem.

Posted: Thu Jun 24, 2004 1:08 pm
by dethron
Hi guys;

I'm sure that there are many who were faced the problem that i m gonna specify.

I'm using Dreamweaver as my PHP editor. Until now, I haven't use the UTF-8 encoding. But now I'm working on a project that is in my native language. And since I want to display some special characters I changed the encoding type of some of my files from win-1254 to utf-8.

But then i got the following error :
Warning: Cannot send session cache limiter - headers already sent (output started at c:\apache\htdocs\adven\cadmin\cadmin_main.php:1) in session.php on line 2

When i open the file in Homesite, or phpEdit I just find a special hidden character at the beginning of the file, the character is .

I have no information about these set of chars but when i deleted these and save the file, the "headers sent" error was gone. However the characters like "çşğöı" are gone, too.

I think this is very interesting and caused me more than 6 hours. Do you know anything about what happened to me? Any help would be great.

Good Luck..

Posted: Thu Jun 24, 2004 1:59 pm
by feyd

Posted: Thu Jun 24, 2004 2:20 pm
by dethron
feyd probably you did not understand my problem.
here is the session.php

Code: Select all

<?php
	session_start();
?>
How can i send anything on line 1 :)
The character is hidden, it doesn't shown using Dreamweaver.
I edit the file using vi after I upload it to server.
vi displays the hidden characters.
The problem is not about session.
It stems from some hidden characters.
When I delete these hidden chars, then any browser is unable to select UTF-8 encoding even if I placed following line in my HTML.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

Posted: Thu Jun 24, 2004 2:28 pm
by feyd
your code should be prior to all text output, including these special characters.

Posted: Thu Jun 24, 2004 2:32 pm
by dethron
But the characters are not shown....
The editor puts them when i select UTF-8.

since I get this error, after hours of digging I found them. In windows they are not shown.
however when you edit the file via "vi" in linux, you are able to see them.

Posted: Thu Jun 24, 2004 2:35 pm
by feyd
how about seperating your code from your html?

Posted: Thu Jun 24, 2004 2:37 pm
by dethron
The code is already seperated,
do you want to see the file?
I can send it via email to you, and explain the problem in more detailed.
Thnx.

Posted: Thu Jun 24, 2004 2:48 pm
by feyd
You can post it here.. could be useful to someone else..

Posted: Thu Jun 24, 2004 2:56 pm
by dethron
i'm sure you didn't understand the problem. :(
the "" are the hidden characters.
they are invisible if your using dreamweaver.
i saw them when i tried to edit the file in my linux server. :)
Any windows editor except homesite are not able to display this chars.
I thing they are some kind of flags that tells the operating system, the file is UTF-8 encoded.
thnx.

Posted: Thu Jun 24, 2004 3:17 pm
by feyd
how does removing the characters, and calling [php_man]header[/php_man]('Content-type: text/html; charset=UTF-8') at the beginning of the file go? (you may need to fiddle with the string a bit)

Posted: Thu Jun 24, 2004 3:25 pm
by dethron
i did this before, and surprisingly some characters are changed.
by the way, if I upload this file to another server, server displayed characters(şöçğ) very well.
i know it is strange but this is the way it is :(

one of friends told me he had same problem once, and he thinks
converting win1252 file to utf8 in dreamweaver causes this problem.

now, when your last suggestion is applied the situation is that,
since the chars are removed the session error is solved,
however, any browser(I tried 5 of them) tries to set the encoding to the default encoding (although the file has
header('Content-type: text/html; charset=UTF-8') ; line.).

thnx.

Posted: Thu Jun 24, 2004 3:41 pm
by feyd
you may need to set the DTD too.. Here's specific info on the character set UTF-8

Code: Select all

Name: UTF-8                                                    &#1111;RFC3629]
MIBenum: 106
Source: RFC 3629
Alias: None

Posted: Thu Jun 24, 2004 3:42 pm
by dethron
Hmmm, i do not know about these things, can you explain?

Posted: Thu Jun 24, 2004 3:52 pm
by feyd
ignore the DTD idea.. I did some further checking.. it doesn't appear to have character encoding controls