This doesn't appear to be a Cake issue. I suspect what you're seeing
is the dreaded "paste from Word" conundrum. Yes, you're talking about
Excel here but it's all the same problem: bizarre and convoluted
formatting and other metadata coming along for the ride.

Also, you should first ensure that you don't have a character set
mismatch somewhere. This page has some good information, including a
couple of ways you can test things (and some Java stuff that's
irrelevant): https://blogs.oracle.com/shankar/entry/how_to_handle_utf_8

You should also test in various browsers to see if the same character
shows up. In Firefox, if you have Firebug installed (if you don't
you're missing out on a lot) paste into the textarea, then right-click
on it and choose "Inspect with Firebug" to see what content is there.

On Tue, Apr 17, 2012 at 12:45 PM, jcrens8392 <runner1...@gmail.com> wrote:
> I have a form that allows people to copy & paste from Excel into a textarea.
> The textarea is then parsed and the data is saved one line at a time.
>
> I've noticed a weird issue that I can't seem to resolve to the point I'm
> confident in it's reliability.
>
> When pasting data from excel, where there is an empty cell with a space in
> it, cake appears to be converting that empty cell to the ASCII character 182
> ('A' with circumflex accent) followed by one character of whitespace.
>
> The problem is, I don't believe the conversion is happening exactly as I've
> described. That's what I see when I print the data, however, any attempts to
> use preg_replace or str_replace to strip that character(s) have failed.
>
> The only solution I've been able to find so far is to convert the import
> data to html entities, which converts the offending characters to
> "&Acirc;&nbsp;" and then strip out those using str_replace. However, I'm not
> too confident this won't corrupt other, valid import data that I haven't yet
> considered.
>
> I have not been able to reproduce this problem outside of Cake on the same
> machine. Even with character encoding on the page and accept-encoding attr
> on the form matching Cake's.
>
> Here's how to reproduce the problem:
>
> * Create textarea using cake form helper (nothing non-standard).
> * Create excel spreadsheet with 1 empty cell
> * In that empty cell, add a space
> * Copy that empty cell and paste into the textarea
> * Use debug($this->request->data['ModelName']['fieldName']) to print out the
> submitted data.
> * You should see a ASCII character 182 followed by a space
> * Try and strip that character <-- I haven't been able to do this at all
> without converting using htmlentities
>
> -John
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at
> http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to