Re: Quickform & Foreign Text
| From: | Justin Patrin | Date: | Thu, 18 Nov 2004 18:05:12 +0000 |
| Subject: | Re: Quickform & Foreign Text | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-15645@lists.php.net to get a copy of this message | ||
On 18 Nov 2004 13:05:33 -0000, PHPDiscuss - PHP Newsgroups and mailing
lists <ericbusch@yahoo.com> wrote:
> I am using HTML_Quickform to process a form that will use primarily
> English but should be able to deal with Korean characters. The Korean
> characters are INSERTed into my database as they should be, represented by
> html entities(ex. & #50516;).
>
> The problem arises when a user goes to edit their submission and I have to
> setDefaults to place what they have written into a <textarea>. Quickform
> is turning all ampersands into (& amp;) Therefore the Korean text is
> turned into unreadable html entities which look like this: (& amp#50516;).
>
> Is there a way I can make sure that HTML_Quickform does not convert the
> ampersand that appears on Korean text into & amp;?
>
> Here is an example of the code i am experimenting on:
> // Instantiate the QuickForm class
> $form = new HTML_QuickForm('example', 'POST');
>
> // textarea attributes
> $attrs = array("rows"=>"10", "cols"=>"50");
>
> // Translates to 2 korean characters with an apostrophe in the middle
> $DESC = html_entity_decode ("& #50516; & #48317; & #39; & #46321; &
> #48152;");
>
> // Set defaults for the form elements
> $form->setDefaults(array('textareaExample' => $DESC));
>
> // The textarea field
> $form->addElement('textarea','textareaExample','Text',
> $attrs);
>
> Thanks in advance. I have been struggling with this problem for a few
> days now.
>
I would suggest using unicode, as Alexey suggested. You may also be
able to run html_entity_decode() on the string before you put it into
the DB, but this also may require unicode.
--
Justin Patrin