Flex TextArea - 从 Word 复制/粘贴 - xml 解析中的 unicode 字符无效 [英] Flex TextArea - copy/paste from Word - Invalid unicode characters on xml parsing

查看:20
本文介绍了Flex TextArea - 从 Word 复制/粘贴 - xml 解析中的 unicode 字符无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请访问这里:

Flex textArea 移除/替换无效的小方块

似乎是问题所在需要为此找到解决方案.

Seems to be the issue & need to find a solution for this.

原文:

我们有一个应用程序,用户可以在其中创建电子邮件消息 &发送给不同的用户.我们将电子邮件消息创建为 XML 消息(发件人、目的地、主题、正文等)&把它放在队列中.

We have an application where users can create an email message & send it to different users. We create the email message as an XML message (sender, destination, subject, body, etc.) & put it on the queue.

另一个应用程序接收消息,解析它&发送电子邮件.我们无法控制它.

Another application picks up the message, parses it & sends out the emails. We have no control over it.

现在的问题是在测试过程中,我们的测试人员从 Word & 复制/粘贴了一些文本.使用了它.现在可能有一些无效字符(在新行或选项卡上)在解析器中失败.错误是:

Now the problem is during testing, our tester copied/paste some text from Word & used it. Now that probably has some invalid characters (on new line or tab) that is failing in the parser. The error is :

Invalid character in attribute value BODY (Unicode: 0x1A) 

所以现在我们需要防止发送这些无效字符.所以我尝试使用 textArea 限制.在 creationComplete 上是这样的:

So now we need to prevent sending these invalid chars. So I tried using textArea restrict. Something like this on creationComplete:

contentTextArea.restrict = "A-Z a-z 0-9 .,!@#$%*-+[]{}()/' \u2424\\";

但是不起作用.当我删除 \u2424\ 它可能工作,但它取出所有新行.那么我需要使用正则表达式替换吗?

But does not work. When i remove \u2424\ it probably works, but it takes out all new lines. So do I need to use regex replace?

对此的任何帮助将不胜感激.

Any help on this would be appreciated.

尝试的文本是:

One area where the applications differ greatly is security.  Adding or removing a Permission within a Role does not require a deployment, simply a ‘data fix’.

During development it was communicated that the audience of users .  As such there was no mechanism constructed to migrate between the two systems.  The purpose of this document is to outline two strategies for bring the user base between the two applications into sync.
 

此文本上有制表符/换行符等.

There are tabs/new lines, etc. on this text.

非常感谢

苦涩

推荐答案

我能够通过使用 textArea changedHandler 来处理它,只允许某些字符:

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, "");
             ......
    }

这篇关于Flex TextArea - 从 Word 复制/粘贴 - xml 解析中的 unicode 字符无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆