Cygwin编码困难 [英] Cygwin encoding difficulties

查看:143
本文介绍了Cygwin编码困难的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不确定这是否是编程问题。我开始怀疑......但是我在Windows控制台而不是Cygwin中运行了Java程序(可执行jar)......它运行良好:输出重音很好,重音输入接受很好。所以以下内容仅适用于Cygwin控制台。

Not sure whether this is a programming problem. I began to suspect so... but then I ran the Java program (executable jar) in question in a Windows console instead of a Cygwin one... and it ran fine: output accents fine, accented input accepted fine. So what follows applies only to the Cygwin console.

我正在处理一些法语文本。当打印重音字符( System.out )时,会打印一种哈希框。我在这里看到了另一个问题,但是没有给出解决方案或正确的解释。

I'm processing some French text. When accented characters are printed (System.out) a sort of "hashed box" is printed instead. I saw another question here about this but there was no solution or proper explanation given.

当我输入重音字符时,这些字符被错误地读取(Java System.in ),例如然后打印出bénéfice(在正确处理编码的日志中)为bénéfice。

And when I enter accented characters these are read in incorrectly (Java System.in), e.g. "bénéfice" is then printed out (in the log which is handling encoding correctly) as "bénéfice".

令人费解的(或许)是我我能在控制台中键入bénéfice。根据我的理解,字体Deja Vu Sans Mono可以很好地处理Unicode。所以...这可能与Java System.in System.out 流有关。

What is puzzling (perhaps) is that I am able to type "bénéfice" in the console. The font Deja Vu Sans Mono is meant to handle Unicode well, as I understand it. So... might this be something to do with the Java System.in and System.out streams???

为避免疑问,这是Windows平台上的Cygwin(有没有人在非Windows操作系统上使用Cygwin?)。

For the avoidance of doubt, this is Cygwin on a Windows platform (does anyone use Cygwin on a non-Windows OS?).

我尝试通过选项 - >文本更改区域设置和字符集和字体。没有什么能改变这些盒子。
目前设置是默认设置:

字体:Deja Vu Sans Mono

区域设置:en_GB

字符集:UTF-8 < br>

I have tried changing the "Locale" and Character set and Font, by going Options --> Text. Nothing changes these boxes. At the moment settings are the default ones:
Font: Deja Vu Sans Mono
Locale: en_GB
Character set: UTF-8

在命令提示符下,当我去的时候

At the command prompt, when I go

$ locale

我得到

LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_ALL=

任何人都知道我应该做什么?

Anyone know what I should do?

推荐答案

感谢Paul和Zhong Yu的回答。

Thanks to Paul and Zhong Yu for the answers here.

要打印到Cygwin做这样的事情:

To print to Cygwin do this sort of thing:

PrintStream out = new PrintStream(System.out, true, "UTF-8");
out.print( outputString );

从Cygwin读取这类事情:

To read from Cygwin do this sort of thing:

BufferedReader br = new BufferedReader( new InputStreamReader(System.in, "UTF-8") );
String nextInputLine = br.readLine();

在重新获得Cygwin之前,这个问题还没有出现,我感到很惊讶。

Slightly amazed that this question has not come up before re Cygwin.

这篇关于Cygwin编码困难的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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