Re: Character Encoding Problem

From: Date: Mon, 23 Feb 2004 14:06:54 +0000
Subject: Re: Character Encoding Problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-178526@lists.php.net to get a copy of this message
Try multibyte functions (http://www.php.net/manual/en/ref.mbstring.php): mb_decode_numericentity mb_encode_numericentity mb_convert_encoding See below: <?php function n_to_c($str) { return mb_decode_numericentity($str, array(0x0, 0x2FFFF, 0, 0xFFFF), 'UTF-8'); } function c_to_n($strt) { return mb_encode_numericentity($strt, array(0x0, 0x2FFFF, 0, 0xFFFF), 'UTF-8'); } echo n_to_c('&#8220;'); echo '<br/>'; echo c_to_n(n_to_c('&#8220;')); ?> Hope it helps, Lucian "Roland" <roland.swingler@transversal.com> wrote in message news:20040223122602.83842.qmail@pb1.pair.com... > Hi > > I'm trying to encode text entered into an html form. In dreamweaver, > special characters seem to be encoded as &#8220; (a curly quote) for > example, which I assume is utf-8. > > Here is my code snippet: > > htmlentities(html_entity_decode(strip_tags(stripslashes(trim($data)))), > ENT_QUOTES), ENT_QUOTES, "utf-8") > > but this does not seem to return the encoded value. I've tried all the > character sets, but none of them seem to do anything apart from the windows > specific character set, which doesn't return the value I want. > > I've tried using html_entity_decode with uft-8, but it throws an error > saying that the function doesn't support MBCS (Multibyte character sets???) > > I've also tried using utf8_encode() before trying to html encode, but this > doesn't work either. > > Any help gratefully appreciated > > Thanks In Advance > Roland

« previous php.general (#178526) next »