如何“剪切和粘贴”影响字符编码和什么可能出错? [英] How does "cut and paste" affect character encoding and what can go wrong?

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

问题描述

我有一个在工具A中显示的编码A中的文档A和在工具B中显示的编码B中的文档B.如果我将B的一部分剪切并粘贴到一个可能是结果字符编码?我意识到这取决于工具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表示形式放到剪贴板上(在Windows中,Unicode通常作为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天全站免登陆