You are here: Re: character set problems « PHP Language « IT news, forums, messages
Re: character set problems

Posted by Casper on 10/20/07 15:56

On Oct 20, 4:09 pm, Ian Hobson <ian.hob...@ntlworld.com> wrote:
> ED wrote:
> > "Ian Hobson" <ian.hob...@ntlworld.com> wrote in message
> >news:ZA0Si.9934$7a2.3102@newsfe3-gui.ntli.net...
> >> 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 is nothing 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 would 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 doesn't have a
'£' character.
Try changing the font

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация