• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ General Support (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

[FIX] Encoding Problem

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
21 posts • Page 1 of 2 • 1, 2

Postby pixelpeter » Mon Feb 27, 2006 10:44 pm

As mentioned earlier I take my nicknames from the database, but when there're names containing special chars like ä,ö,ü the chat won't work.

Is set
Code: Select all
$params["output_encoding"] = "ISO-8859-1";

and also
Code: Select all
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />

setting the nickname by
Code: Select all
$params["nick"] = 'äöü'

wont work :-(

I also had no luck by using the php functions
- urlencoding
- rawurlencoding
- htmlspecialchars
- htmlentities

Then I resaved the file with Zend Studio as UTF-8 and tried the above combination, but nothing seems to work

Any idea ?!?!??

Thanx in advance !!!!
pixelpeter
New member
 
Posts: 7
Joined: Sun Feb 26, 2006 6:10 pm
Top

Postby phpfreechat » Mon Feb 27, 2006 11:20 pm

The nickname must be UTF-8 encoded, are you sure this line is UTF-8 encoded ?
$params["nick"] = 'äöü';

If this comme from a BDD where nicknames are ISO-8859-1 encoded, try this :
$params["nick"] = iconv("ISO-8859-1", "UTF-8", $bdd_nickname);
(just change $bdd_nickname with your nickname variable)

Keep me informed
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby pixelpeter » Tue Feb 28, 2006 5:58 am

O.K: This fix works so far as you can now log in with a nickname containing spaces and special chars.
The display of the name is correct in the chat window, the user list, but not on the submit buttom (for sending the message). This is true for FF1.5.1 and IE6SP2
pixelpeter
New member
 
Posts: 7
Joined: Sun Feb 26, 2006 6:10 pm
Top

Postby phpfreechat » Tue Feb 28, 2006 9:37 am

What is your webpage encoding ??
Have you a public url to illustrate what you say ?
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby motosdeagua.es » Tue May 09, 2006 4:25 pm

Thus I have the code, but with himself not to cause that it works thus with nicknames: (ramón, cigüeña, angüila, vía, ...)

Code: Select all
<?php
require_once dirname(__FILE_b_)."/src/phpfreechat.class.php";
$pnnick = $_REQUEST['user'];
$params =  array("title"          => "Chat",
                 "max_msg"        => 21,
                 "prefix"         => "blune_",
                 "clock"          => false,
                 "serverid"       => md5(__FILE__),
                 "theme"          => "blune",
                 "frozen_nick"    => true,
                 "nick"           => iconv("ISO-8859-1", "UTF-8", $pnnick),
                 "output_encoding"           => "ISO-8859-1",
                 );
                 
$chat = new phpFreeChat( $params );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Chat</title>
    <?php $chat->printJavascript(); ?>
    <?php $chat->printStyle(); ?>
    </head>
    <body>
            <?php $chat->printChat(); ?>

    </body>
</html>

I cannot either have the language thus:
Code: Select all
// line 398 in phpfreechat.class.php
$GLOBALS["i18n"]["%s is connected"] = "%s está conectado";

Error in "está"
Last edited by motosdeagua.es on Tue May 09, 2006 4:25 pm, edited 1 time in total.
My challenge is make working to phpfreechat with postnuke!
Moving phpfreechat to Spain!
- www.motosdeagua.es -
motosdeagua.es
Member
 
Posts: 35
Joined: Tue May 02, 2006 12:24 pm
Location: SPAIN
  • Website
Top

Postby motosdeagua.es » Tue May 09, 2006 4:36 pm

watch here: [url=http://www.motosdeagua.es/modules/chat/pn.php?user=SÍäA]DEMO[/url] :(
My challenge is make working to phpfreechat with postnuke!
Moving phpfreechat to Spain!
- www.motosdeagua.es -
motosdeagua.es
Member
 
Posts: 35
Joined: Tue May 02, 2006 12:24 pm
Location: SPAIN
  • Website
Top

Postby phpfreechat » Tue May 09, 2006 9:13 pm

if you put :
Code: Select all
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

You must not convert the ISO-8859-1 nickname and output !
Remove :
"output_encoding" => "ISO-8859-1",
And change :
"nick" => iconv("ISO-8859-1", "UTF-8", $pnnick),
by :
"nick" => $pnnick,
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby motosdeagua.es » Wed May 10, 2006 8:42 am

Code: Select all
<?php
require_once dirname(__FILE_b_)."/src/phpfreechat.class.php";
$pnnick = $_REQUEST['user'];
$params =  array("title"          => "Chat",
                 "max_msg"        => 21,
                 "prefix"         => "blune_",
                 "clock"          => false,
                 "serverid"       => md5(__FILE__),
                 "theme"          => "blune",
                 "frozen_nick"    => true,
                 "nick"           => $pnnick,
                 );
                 
$chat = new phpFreeChat( $params );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Chat</title>
    <?php $chat->printJavascript(); ?>
    <?php $chat->printStyle(); ?>
    </head>
    <body>
            <?php $chat->printChat(); ?>

    </body>
</html>

Also it fails.... :(
Last edited by motosdeagua.es on Wed May 10, 2006 8:44 am, edited 1 time in total.
My challenge is make working to phpfreechat with postnuke!
Moving phpfreechat to Spain!
- www.motosdeagua.es -
motosdeagua.es
Member
 
Posts: 35
Joined: Tue May 02, 2006 12:24 pm
Location: SPAIN
  • Website
Top

Postby phpfreechat » Wed May 10, 2006 8:56 am

??? what is that : dirname(__FILE_b_)
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby motosdeagua.es » Wed May 10, 2006 9:02 am

I don't know
My challenge is make working to phpfreechat with postnuke!
Moving phpfreechat to Spain!
- www.motosdeagua.es -
motosdeagua.es
Member
 
Posts: 35
Joined: Tue May 02, 2006 12:24 pm
Location: SPAIN
  • Website
Top

Postby phpfreechat » Wed May 10, 2006 9:11 am

Why don't you take this demo as a starting point ?
http://www.phpfreechat.net/demo/pfc/dem ... panish.php
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby motosdeagua.es » Wed May 10, 2006 9:27 am

Ok, using the demo as a starting point...
I do the necessary changes in order that to use the nicksnames of postnuke and we come to the same error...

Code: Select all
<?php

require_once dirname(__FILE__)."/../src/phpfreechat.class.php";
$pnnick = $_REQUEST['user'];
$params =  array("serverid"       => md5(__FILE__),
             "language"      => "es_ES",
                 "theme"          => "blune",
                 "frozen_nick"    => true,
                 "nick"           => $pnnick,
                 );

$chat = new phpFreeChat( $params );

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Chat</title>

    <?php $chat->printJavascript(); ?>
    <?php $chat->printStyle(); ?>

  </head>

  <body>
    <?php $chat->printChat(); ?>

<?php
  // print the current file
  echo "<h2>The source code</h2>";
  $filename = __FILE__;
  echo "<p><code>".$filename."</code></p>";
  echo "<pre style="margin: 0 50px 0 50px; padding: 10px; background-color: #DDD;">";
  $content = file_get_contents($filename);
  echo htmlentities($content);
  echo "</pre>";
?>

  </body>
</html>

Only I have changed this:
Code: Select all
require_once dirname(__FILE__)."/../src/phpfreechat.class.php";
$pnnick = $_REQUEST['user'];
$params =  array("serverid"       => md5(__FILE__),
             "language"      => "es_ES",
                 "theme"          => "blune",
                 "frozen_nick"    => true,
                 "nick"           => $pnnick,
                 );

$chat = new phpFreeChat( $params );
Last edited by motosdeagua.es on Wed May 10, 2006 9:31 am, edited 1 time in total.
My challenge is make working to phpfreechat with postnuke!
Moving phpfreechat to Spain!
- www.motosdeagua.es -
motosdeagua.es
Member
 
Posts: 35
Joined: Tue May 02, 2006 12:24 pm
Location: SPAIN
  • Website
Top

Postby phpfreechat » Wed May 10, 2006 10:05 am

what is the $pnnick encoding ?
does it work if you force $pnnick to "guest" ?
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby motosdeagua.es » Wed May 10, 2006 10:27 am

$pnnick = $_REQUEST['user']; // It uses the variable of the URL

http://www.motosdeagua.es/modules/chat/ ... r=yourname <- HERE
Last edited by motosdeagua.es on Wed May 10, 2006 10:28 am, edited 1 time in total.
My challenge is make working to phpfreechat with postnuke!
Moving phpfreechat to Spain!
- www.motosdeagua.es -
motosdeagua.es
Member
 
Posts: 35
Joined: Tue May 02, 2006 12:24 pm
Location: SPAIN
  • Website
Top

Postby phpfreechat » Wed May 10, 2006 2:01 pm

motosdeagua.es wrote:$pnnick = $_REQUEST['user']; // It uses the variable of the URL

http://www.motosdeagua.es/modules/chat/ ... r=yourname <- HERE

But WHY did you change the meta to ISO-8859-15 ?
By default output_encoding is UTF-8 so if you change the webpage meta, it will not match the output encoding ...

if you setup
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15" />
you must use
$params["output_encoding"] = "ISO-8859-15";
and you must pray your php support encoding convertion with iconv extention ...

Is suggest you to keep utf8 default encoding everywhere ... I don't understand why you want to make things more complicated...
The default demo works so don't change anything on encoding ! Keep things simple !
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Next

Post a reply
21 posts • Page 1 of 2 • 1, 2

Return to General Support (v1.x)

Who is online

Users browsing this forum: No registered users and 14 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
cron
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub