你能定义什么问题吗? [英] Could you define what is the problem?

查看:74
本文介绍了你能定义什么问题吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。



我试图将剪贴板中的一些文本粘贴到某个应用程序中的特定字段。该应用程序在Windows 7上,非Unicode程序的语言设置为该西里尔语。



我已将西里尔字符复制到剪贴板,类似于Петър。当我粘贴它们时,文本字段显示如下:??????



然后我测试复制一些通过键盘字符输入的字段副本通过鼠标或键盘取得了成功。



应用程序是否具有ASCII可比性?



我尝试过:



我已将西里尔字符复制到剪贴板,类似于Петър。当我粘贴它们时,文本字段显示如下:??????





然后我测试复制一些通过鼠标或键盘在该字段副本中通过键盘字符输入并且成功。

Hello.

I am trying to paste some text form the clipboard to a specific field that is in some application. The application is on Windows 7, the Language for non-Unicode programs is set to that Cyrillic language.

I have copied Cyrillic characters to the clipboard, something like "Петър". When I paste them the text field is displayed like this: "??????"

Then I test to copy some inputted via keyboard characters in that field copy via mouse or keyboard and there is a success.

Can it be that the application is made with ASCII comparability?

What I have tried:

I have copied Cyrillic characters to the clipboard, something like "Петър". When I paste them the text field is displayed like this: "??????"


Then I test to copy some inputted via keyboard characters in that field copy via mouse or keyboard and there is a success.

推荐答案

这是非Unicode文本实际应该发生的事情。它很可能是过时的西里尔特定编码之一。可能是Windows 1251或KOI8-R:

Windows-1251 - 维基百科,免费的百科全书 [ ^ ],

KOI8-R - 维基百科,免费的百科全书 [ ^ ]。



太糟糕了,有一个过去人们用于西里尔语的编码更多。



找到它的一个简单方法是以过时的编码读取文件并写一个新文件在UTF(更好的是UTF-8)。您可以使用以下构造函数使用 StreamReader 打开文件: StreamReader构造函数(字符串,编码)(System.IO) [ ^ ];

参见:编码类(System.Text) [ ^ ]。







在我用链接写完答案后,我记得你没有注明你的平台和语言。我提供了.NET(或任何其他CLR实现)的答案。如果你真的需要别的东西,请澄清。



[结束编辑]



你可以做一个通过代码页猜测并构造一种受支持的编码:编码构造函数(Int32)(System.Text) [ ^ ]。



您可以参考代码页表来查找所需内容:附录H代码页 [ ^ ]。



但是如何快速找出编码做什么你有?如果我不能立即看到它,我使用以下技巧:将文件重命名为* .html以在某些浏览器中打开它。现代浏览器具有文本编码功能,通过语言功能自动检测。您可以快速尝试不同的编码,并且自动检测很可能立即显示正确的结果。



在最坏的情况下,您会发现什么是编码但是默认情况下不支持它,您可以使用此编码的引用,并将您自己的代码转换为Unicode代码点。你需要做的就是创建一个转码表并使用它。



当然,你不应该再编写非Unicode软件,即使你只是使用美式英语,除了一些罕见的情况。远离麻烦。



-SA
This is what actually should happen to non-Unicode text. It's very likely that it's one of the obsolete Cyrillic-specific encodings. It could be Windows 1251 or KOI8-R:
Windows-1251 — Wikipedia, the free encyclopedia[^],
KOI8-R — Wikipedia, the free encyclopedia[^].

Too bad, there are a lot more encodings people used for Cyrillic in the past.

One of the simple ways to find it out is to read a file in that obsolete encoding and write a new file in UTF (better be UTF-8). You can open the file with a StreamReader using this constructor: StreamReader Constructor (String, Encoding) (System.IO)[^];
see also: Encoding Class (System.Text)[^].



After I already wrote my answer with links, I remembered that you did not indicate your platform and language. I provided the answer for .NET (or any other CLR implementation). If you really need something else, please clarify.

[END EDIT]

You can make a guess and construct one of supported encodings by the "code page": Encoding Constructor (Int32) (System.Text)[^].

You can refer to the table of code pages to find what you need: Appendix H Code Pages[^].

But how to quickly find out what encoding do you have? If I cannot see it immediately, I use the following trick: rename the file as *.html to open it in some browser. Modern browsers have the "text-encoding" feature with "auto-detect" by language feature. You can quickly try out different encodings, and auto-detect is very likely to show correct result right away.

In worst case, you find out what is the encoding but it is not supported by default, you can use the reference on this encoding and write you own transcoding from those codes to Unicode code points. All you need to do is to create a transcoding table and use it.

And of course, you should not write non-Unicode software any longer, even if you only use American English, except some rare cases. Stay out of trouble.

—SA


这篇关于你能定义什么问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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