转换为垃圾字符 - 在文本框中复制粘贴时
每当我在文本框中复制并粘贴任何下面提及的字符时
,下面都是复制的字符(在记事本中测试此字符)
...
”
'
下面是输入的字符
...
”
'
然后它被转换为垃圾字符。我怎样才能阻止这个。 当我从键盘输入这些字符时,它可以工作,但是当复制粘贴时,它会转换为垃圾邮件。
我如何在处理之前检测并删除所有这些字符,因为..用户不知道这个问题..
我想在用户按“提交”按钮时删除该字符。
Whenever i Copy and paste any Below Mention CHARACTER in text Box
Below are Copied character ( test this in notepad )
…
”
‘
Below are Typed Character
...
"
'
then that was converted to Junk Character. How can i Block this .
When i Type those character from keybord then it works but when copy paste it converted to Junk.
How can i detect and delete all this character before processing because ..user dont know about this issue ..
I want to delete that character wen user press Submit button.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
”
和'
不是垃圾字符。它们是完美的 Unicode 字符(U+201C 左双引号和 U+2018 左单引号)。现代应用程序应该能够处理所有 Unicode 字符;如果您无法处理智能引号,您可能也无法处理重音、希腊语、西里尔语、中文或用户可能想要使用的任何其他字符。您应该集中精力确保您的应用程序支持 Unicode,而不是尝试修复这一明显的症状。将
'
和"
(ASCII 直引号)字符粘贴到文本框中不应将它们变成非 ASCII“智能”引号。它们通常来自 Microsoft Word 的误导性“自动替换”功能会在您键入时将直引号替换为智能引号,这很烦人,但最终它仅限于 Office,而且对此您无能为力。通过执行简单的字符串替换,手动将“
和”
替换为"
(具体操作方式取决于您所讨论的语言/环境),您还将删除这些字符的正确用法,并且您不会修复 MS Office 所做的所有其他令人遗憾的损坏的自动替换。…
单字符省略号的情况略有不同,可以说是“垃圾”:对于 Unicode,U+2026 水平省略号是一个“兼容字符”,仅用于很好地往返于现有的字符将其作为单独字符包含的编码。通常应使用三个点字符代替。您可以使用 Unicode 标准化(特别是范式 KC)来替换兼容性字符。同样,如何访问规范化取决于您的编程语言/环境。例如,在 Python 中,unicodedata.normalize('NFKC', u'...')
为您提供u'...'
。”
and’
are not junk characters. They are perfectly good Unicode characters (U+201C LEFT DOUBLE QUOTATION MARK and U+2018 LEFT SINGLE QUOTATION MARK). Modern applications should be capable of dealing with all Unicode characters; if you can't handle the smart quotes you probably also can't handle accents, Greek, Cyrillic, Chinese or any of the other characters users are likely to want to use. You should concentrate on ensuring that your application supports Unicode, rather than trying to fix this one visible symptom.Pasting
'
and"
(ASCII straight quote) characters into a text box should not turn them into non-ASCII ‘smart’ quotes. Where they typically tend to come from is Microsoft Word's misguided ‘AutoReplace’ feature, which replaces straight quotes with smart quotes as you type. This is an annoyance, but ultimately it's limited to Office and there's not really much you can do about it. Whilst you can manually replace“
and”
with"
by doing a trivial string replacement (and how you do that depends on what language/environment you are talking about), you'll also be removing correct usage of those characters, and you won't be fixing all the other sad broken auto-replacements that MS Office does.The
…
single-character ellipsis is a slightly different case, and arguably ‘junk’: to Unicode, U+2026 HORIZONTAL ELLIPSIS is a ‘compatibility character’ which is only intended to round-trip nicely to existing encodings that include it as a separate characters. Normally three dot characters should be used instead. You can replace compatibility characters by using Unicode normalisation, in particular Normal Form KC. Again, how you access normalisation is something that depends on your programming language/environment. For example in Python,unicodedata.normalize('NFKC', u'…')
gives youu'...'
.您的 vnc 客户端/服务器是否已打开,请尝试退出(关闭)所有 vnc 服务器/客户端,然后重试 - 如果您的复制粘贴有效。
Is your vnc client / server ON, try to exit (shutdown) all vnc server / clients and try again - if your copy paste works.