-- [email protected] <[email protected]> wrote
(on Friday, 05 February 2010, 08:23 AM +0100):
> My problem is with ajax requests that must return html and not JSON.
> So, if i receive a string from POST like "La vita è bella" and save
> it into DB without apply utf8_decode i'll get a string like "La vita
> ù bella".
> 
> I'm looking for an automatically method or best practise to deal with it.

Your application should be using UTF-8 throughout -- that means all
files should be in utf-8, you should be declaring utf-8 as the charset
in your HTML headers and/or via meta tags, and your _database_ should be
using UTF-8 as its encoding. This will ensure consistency throughout all
aspects of your application and prevent exactly the issue you're
describing.


> Citando Nicolas Grevet <[email protected]>:
> 
> >Yeah, that's what we did.
> >But it would be great if Zend_Json_Encoder could automate the process.
> >Auto-encode in the encoder, auto-decode in the decoder. But well,
> >there's much more important things to do for the moment.
> >
> >Dmitry Dulepov a écrit :
> >>Hi!
> >>
> >>On 4 Feb 2010, at 11:03, Nicolas Grevet wrote:
> >>>We have the same problem in french, we're using ISO/IEC
> >>>8859-15.  By the way, I've yet to hear about a way to change
> >>>string encoding  in javascript.
> >>
> >>Theoretically you can but practically you can't. PHP expects
> >>UTF-8  in json_decode and json_encode. UTF-8 is a default
> >>encoding for  JSON in all browsers. And MSIE fails if you append
> >>"charset" header  to content type for JSON. So you are much
> >>safer with UTF-8 in json.
> >>
> >>----
> >>Dmitry Dulepov
> >>Twitter: http://twitter.com/dmitryd/
> >>Web: http://dmitry-dulepov.com/
> >>
> >>
> >>
> >>
> 
> 

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

Reply via email to