Flex textArea remove/replace invalid little square

2019-08-29 09:05发布

问题:

This is related to my previous Flex issue:

Flex TextArea - copy/paste from Word - Invalid unicode characters on xml parsing

But this is slightly different & seems to be the issue. So I had to create another thread for this.

When I copy/paste text from word to a text area, I do not see any invalid characters. But when I pasted the same text on this url:

http://blog.flexexamples.com/2008/03/07/preventing-line-feeds-in-a-textarea-control-in-flex/

I'm seeing a little square " ". Please paste this text into the URL:

Bring the user base between the two applications into sync.
 
2.    Requirements

and you should be able to see the same. Now I want to remove this invalid character/symbol. Is there any way to do it. I think this is the problem for my xml parser issue.

Thanks

回答1:

I was able to handle it by using the textArea changingHandler to allow only certain characters:

    if (event.operation is PasteOperation)
        {
            event.preventDefault();
            var txt:String = Clipboard.generalClipboard.getData(ClipboardFormats.TEXT_FORMAT).
                            toString().replace(/[^A-Za-z0-9\s$%&*!@-_().]/ig, "");
                 ......
        }