I wasn't using HTML entities directly because that data that I'm
working with has already been imported from an XLS file into MySQL. I
initially noticed this problem when I was pulling the data from MySQL,
and found myself where I am now after troubleshooting those issues.
Rather than processing every string one at a time as the import
utility pulls data from XLS files uploaded by users, I was looking for
a higher-level solution by just resolving the issue at the level of
the Form helper.

Sure enough, you were right about the htmlspecialchars() method that
the form helper was calling. By disabling the 'escape' option when
calling the input method, the function now returns a textarea with the
correct value inside of it.

What adverse effects might I see by disabling the escape option?

On Dec 5, 11:58 am, grigri <[EMAIL PROTECTED]> wrote:
> If you're using utf-8 then you can't use chr(135) because it's not a
> valid utf-8 value. The php function chr() doesn't return a character,
> it returns a 1-byte character - utf-8 uses 2 bytes to encode this
> character. You'd need to handle the bytes individually - chr(135)
> represents unicode character U+0087, represented in utf-8 as 0xC2 0x87
> (hex) - or `chr(0xC2).chr(0x87)` using chr().
>
> If it works in plain php then it's probably the htmlspecialchars()
> call that's messing it up - try using
>
> $form->input('field', array('value' => ..., 'escape' => false));
>
> In any case, why not use html entities directly?
>
> $form->input('field', array('value' => '&#x87;', 'escape' =>
> false)); // hex
> $form->input('field', array('value' => '&#135;', 'escape' =>
> false)); // dec
>
> hth
> grigri
>
> On Dec 5, 4:36 pm, Renesistemic <[EMAIL PROTECTED]> wrote:
>
> > grigri,
>
> > Thanks for the prompt reply. Unfortunately, that didn't help me. My
> > core.php file already has the line
> > Configure::write('App.encoding', 'UTF-8');
>
> > and the MySQL tables for Cake are running a utf8_general collation...
> > the MySQL table collation isn't even an issue at this point, however,
> > as I'm still experiencing problems with this issue by simply coding
> > the extended ASCII characters inline (see below example reprinted from
> > original post)
>
> > $this->Form->input($datavalue, array('value'=>chr(105).chr(110).chr
> > (115).chr(130).chr(135)));
>
> > What's interested is, if I just print the following: <input type=text
> > value="<?php echo chr(105).chr(110).chr(115).chr(130).chr(135); ?>">,
> > it outputs completely fine. It's definitely an issue with the CakePHP
> > Form helper, and I initially thought it might be an encoding issue,
> > but I feel like I have everything set up correctly.
>
> > Am I missing something?
>
> > On Dec 5, 11:22 am, grigri <[EMAIL PROTECTED]> wrote:
>
> > > If you're using UTF-8, this shouldn't be a problem - just use UTF-8
> > > characters directly.
>
> > > I just tried with
>
> > > <?php echo $form->input('test', array('value' => '☃♠♣♥♦')); ?>
>
> > > And it worked fine (that's `snowman`, `spades`, `clubs`, `hearts`,
> > > `diamonds` in case the font you're using doesn't have them).
>
> > > If you're not using UTF-8, then you should be!
>
> > > hth
> > > grigri
>
> > > On Dec 5, 3:44 pm, Renesistemic <[EMAIL PROTECTED]> wrote:
>
> > > > I've isolated some problems I've been having down to the CakePHP Form
> > > > helper. It seems that the form helper is unable to create HTML form
> > > > objects with correct values when the $form->input( ) method is called
> > > > while passing in extended ASCII characters.
>
> > > > For example, this code creates a text box with the value : insx}
> > > > $this->Form->input($datavalue, array('value'=>chr(105).chr(110).chr
> > > > (115).chr(120).chr(125)));
>
> > > > This code creates a text box with a blank value:
> > > > $this->Form->input($datavalue, array('value'=>chr(105).chr(110).chr
> > > > (115).chr(130).chr(135)));
>
> > > > The difference is the last two characters. Anytime I submit a value to
> > > > the form helper with a character of over 127, the form helper fails to
> > > > populate the HTML form element it creates with the value I pass in.
>
> > > > Thoughts / Suggestions? Thanks!
>
> > > > PS: I'm running the latest version of RC3.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to