Sagewire Logo

character set problems

4 Message(s) by 3 Author(s) originally posted in php language


From: Ian Hobson Date:   Friday, October 19, 2007
Hi guys,

I have a problem that I believe is related to character sets.

I'm in the UK and I need to store £ (GBP currency symbol) in a MySQL
data base, using php, pull it out again and put it into a .pdf file.

On my test machine everythign work fine - the text can be input in a
text or textarea field , gets processed via mysql_real_escape_string on
its way to the MySQl database, get stored as the single character
according to phpMyAdmin. When the data is sent back to the screen both
display and edit field contents appear correct. The code also create a
dynamic dpf file, which contains the correct symbol and prints correctly.

On the production machine things are slightly different. The character
is altered as it is stored - an "A with a hat" character is stored
before the pound symbol. Although this displays correctly on show and
edit in the browser, the pdf has the "A with hat" symbol prepended, and
this is also printed.

Although there are small differences in versions between php, and apache
between the two machines, there are no differences I can see in the
character sets of database setup, my.ini/cnf , php.ini or httpd.conf files.

They both have the database in Latin1 and connection as utf-8.

The production machine is Ubuntu Server LTS "out of the box" (running as
a VM). The test machine is Win2K with Apache 2, PHP5 and MySQl
5.0.24a-community-nt - all fairly "out of the box".

Anyone have an idea how I can trace the problem, or how to fix it?

Thanks for your input.

Ian


From: ED Date:   Friday, October 19, 2007
Hi guys,
I have a problem that I believe is related to character sets.
I'm in the UK and I need to store £ (GBP currency symbol) in a MySQL
database, using php, pull it out again and put it into a .pdf file.
On my test machine everythign work fine - the text can be input in a
text or textarea field, gets processed via mysql_real_escape_string on
its way to the MySQl database, get stored as the single character
according to phpMyAdmin. When the data is sent back to the screen both
display and edit field contents appear correct. The code also create a
dynamic dpf file, which contains the correct symbol and prints
correctly.
On the production machine things are slightly different. The character
is altered as it is stored - an "A with a hat" character is stored
before the pound symbol. Although this displays correctly on show and
edit in the browser, the pdf has the "A with hat" symbol prepended,
and this is also printed.
Although there are small differences in versions between php, and
apache between the two machines, there are no differences I can see in
the character sets of database setup, my.ini/cnf , php.ini or
httpd.conf files.
They both have the database in Latin1 and connection as utf-8.
The production machine is Ubuntu Server LTS "out of the box" (running
as a VM). The test machine is Win2K with Apache2, PHP5 and MySQl
5.0.24a-community-nt - all fairly "out of the box".
Anyone have an idea how I can trace the problem, or how to fix it?
Thanks for your input.
IanHi Ian,


Have you tried utf8_decode() on the text prior to inserting into the DB?
http://uk.php.net/manual/en/function.utf8-decode.php

cheers
ED


From: Ian Hobson Date:   Saturday, October 20, 2007
wrote in message:
Hi guys,

I have a problem that I believe is related to character sets.

I'm in the UK and I need to store £ (GBP currency symbol) in a MySQL
database, using php, pull it out again and put it into a .pdf file.

On my test machine everything work fine - the text can be input in a
text or textarea field, gets processed via mysql_real_escape_string on
its way to the MySQl database, get stored as the single character
according to phpMyAdmin. When the data is sent back to the screen both
display and edit field contents appear correct. The code also create a
dynamic pdf file, which contains the correct symbol and prints
correctly.

On the production machine things are slightly different. The character
is altered as it is stored - an "A with a hat" character is stored
before the pound symbol. Although this displays correctly on show and
edit in the browser, the pdf has the "A with hat" symbol prepended,
and this is also printed.

Although there are small differences in versions between php, and
apache between the two machines, there are no differences I can see in
the character sets of database setup, my.ini/cnf , php.ini or
httpd.conf files.

They both have the database in Latin1 and connection as utf-8.

The production machine is Ubuntu Server LTS "out of the box" (running
as a VM). The test machine is Win2K with Apache2, PHP5 and MySQl
5.0.24a-community-nt - all fairly "out of the box".

Anyone have an idea how I can trace the problem, or how to fix it?

Thanks for your input.

Ian
Hi Ian,
Have you tried utf8_decode() on the text prior to inserting into the DB?
http://uk.php.net/manual/en/function.utf8-decode.php
cheers
Thanks Ed.



That does get the data stored correctly (as reported by phpMyAdmin).

It (still) works correctly on the test machine but £ displays as a blank
square on the production machine, yet it is now correct in the .pdf. So
I have made progress - but it is still not right.

On the save to database, the data is processed by first utf8_decode and
then mysql_real_escape_string. There isn'thing to strip these slashes
on read, nor to convert to URF-8 in the output buffering.

And I have an old bug to fix about text that includes single quotes is
not handled correctly. 'x' becomes \\'x\\' becoems \\\\'x\\\\\' etc on
each edit I think.

Ideally I'd like to get the connection to use Latin1 and avoid all
conversion. What should I do to achieve this? (I do have the ability
to alter the production server ).

Regards

Ian


From: Casper Date:   Saturday, October 20, 2007
wrote in message:
wrote in message:
Hi guys,
I have a problem that I believe is related to character sets.
I'm in the UK and I need to store =A3 (GBP currency symbol) in a MySQL
database, using php, pull it out again and put it into a .pdf file.
On my test machine everything work fine - the text can be input in a
text or textarea field, gets processed via mysql_real_escape_string on
its way to the MySQl database, get stored as the single character
according to phpMyAdmin. When the data is sent back to the screen both
display and edit field contents appear correct. The code also create a
dynamic pdf file, which contains the correct symbol and prints
correctly.
On the production machine things are slightly different. The character
is altered as it is stored - an "A with a hat" character is stored
before the pound symbol. Although this displays correctly on show and
edit in the browser, the pdf has the "A with hat" symbol prepended,
and this is also printed.
Although there are small differences in versions between php, and
apache between the two machines, there are no differences I can see in
the character sets of database setup, my.ini/cnf , php.ini or
httpd.conf files.
They both have the database in Latin1 and connection as utf-8.
The production machine is Ubuntu Server LTS "out of the box" (running
as a VM). The test machine is Win2K with Apache2, PHP5 and MySQl
5.0.24a-community-nt - all fairly "out of the box".
Anyone have an idea how I can trace the problem, or how to fix it?
Thanks for your input.
Ian
> Hi Ian,
> Have you tried utf8_decode() on the text prior to inserting into the DB?
>http://uk.php.net/manual/en/function.utf8-decode.php
> cheers
Thanks Ed.
That does get the data stored correctly (as reported by phpMyAdmin).
It (still) works correctly on the test machine but =A3 displays as a blank
square on the production machine, yet it is now correct in the .pdf. So
I have made progress - but it is still not right.
On the save to database, the data is processed by first utf8_decode and
then mysql_real_escape_string. There isn'thing to strip these slashes
on read, nor to convert to URF-8 in the output buffering.
And I have an old bug to fix about text that includes single quotes is
not handled correctly. 'x' becomes \\'x\\' becoems \\\\'x\\\\\' etc on
each edit I think.
Ideally I'd like to get the connection to use Latin1 and avoid all
conversion. What should I do to achieve this? (I do have the ability
to alter the production server).
Regards
Ian



Sounds like the font you are using on the test machine does not have a
'=A3' character.
Try changing the font



Next Message: OT:Recommend a php webform Script?


Blogs related to character set problems

Scalix Server :: Encoding error in calender
charset="us-ascii" seems to indicate that the listview is supposed to contain only us-ascii but it contains several iso-8859-1 diacritical charakters (öäü). This is as far as I figured it out by myself. I think the "listview message" ...

character set and the alfred rig
i have actually managed to get all the curves into a character set, only problem is when i try to set a keygrame on all the curves at frame 1 (by pressing the 's' key), maya pauses then says an error along the lines of: ...

Huge error when changing the site title….
DBA Varien (http://www.varien.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ --> Punk Shirts text/html <charset>utf8charset> ...

image display php code problem
Untitled Document php $con = mysql_connect("localhost","root","longstand") or die('Damn!, the crazy guinea pigs must have started ...

Hey guys I personal have a database field which holds the ...
there is a difference in converting something and intepret something different my that’sa tongue breaker kinda has a catchy tune to it though but as TehSausage said. “Hello” is probably valid in almost every character set, but theres no ...

PHP Soap
Automatically add files before or after any PHP document. auto_prepend_file = auto_append_file = ; As of 4.0b4, PHP always outputs a character encoding by default in ; the Content-type: header. To disable sending of the charset, simply ...


Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional