“剪切和粘贴"是如何进行的?影响字符编码,会出现什么问题? [英] How does "cut and paste" affect character encoding and what can go wrong?

查看:16
本文介绍了“剪切和粘贴"是如何进行的?影响字符编码,会出现什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在工具 A 中显示的编码 A 的文档 A 和在工具 B 中显示的编码 B 的文档 B.如果我将 B 的(部分)剪切并粘贴到 A 中,可能会产生什么字符编码?我意识到这取决于工具 A 和工具 B 以及粘贴缓冲区中保存的信息(可能包含编码?)和操作系统.

I have a document A in encoding A displayed in tool A and a document B in encoding B displayed in tool B. If I cut and paste (part of) B into A what might be the resultant character encoding? I realise this depends on tool A and tool B and the information held in the paste buffer (which presumably can contain an encoding?) and the operating system.

高质量的工具应该做什么?在实践中,有多少常用工具(例如 Word、TextPad、各种 IDE 等)做得很好?

What should high-quality tools do? and in practice how many of the common tools (e.g. Word, TextPad, various IDEs, etc.) do a good job?

推荐答案

首先,文本编辑器的内部文本表示与保存文件时文本的编码(序列化)方式无关.所以文档不是在"编码中;它是一系列抽象字符.当文档被保存到一个文件(或通过网络传输)然后它被编码.

First of all, a text editor's internal representation of text has no bearing on how the text is encoded (serialized) when you save the file. So a document is not "in" an encoding; it's a sequence of abstract characters. When the document is saved to a file (or transmitted over the network) then it gets encoded.

由每个应用程序决定它在剪贴板上放什么.通常,知道自己在做什么的 Windows 应用程序会在剪贴板上放置许多不同的表示.当您粘贴其他应用时,该应用会寻找最适合其需要的表示.

It's up to each application to decide what it puts on the clipboard. Typically, a windows app that knows what it's doing will put a number of different representations on the clipboard. When you paste in the other app, the app will look for the representation that best suits its need.

在您的情况下,文本编辑器(知道它在做什么)会将所选字符串的 Unicode 表示放到剪贴板上(其中 Unicode 在 Windows 中通常作为 UTF-16 移动,但这并不重要).当您粘贴另一个应用程序时,它会在选择点处将该 Unicode 字符序列插入到文档中.

In your case, a text editor (that knows what it's doing) will put a Unicode representation of a selected string onto the clipboard (where Unicode, in Windows, is typically moved around as UTF-16, but that's not important). When you paste in the other app, it will insert that sequence of Unicode characters into the document at the selection point.

有一个名为ClipSpy"的应用程序可以帮助您以交互方式查看我在说什么.

There's an app floating around called "ClipSpy" that will help you see what I'm talking about, interactively.

这篇关于“剪切和粘贴"是如何进行的?影响字符编码,会出现什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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