如何获取控制台字符集? [英] How to get console charset?

查看:82
本文介绍了如何获取控制台字符集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取控制台(cmd.exe在Windows,linux shell或eclipse控制台输出)字符集编码?
java.nio.charset.Charset.defaultCharset()似乎只适用于输入/输出文件,而不是控制台。

How to get console (cmd.exe in windows, linux shell, or eclipse console output) charset encoding? java.nio.charset.Charset.defaultCharset() seems to be only for input/output files, not console.

推荐答案

一般来说:你必须询问 shell 当前用来显示字符的字符集。

In general: you'd have to ask the shell what charset it is currently using to display characters.

猜测不知道:在Java中没有标准的方式(我想)没有标准的控制台报告实际的字符集。我们必须检测实际操作系统或控制台提供程序(eclipse,...),并使用它们的特定功能来获取实际字符集的名称。

Guessing not knowing: there is no standard way in Java as (I guess) there's no standard for consoles to report the actual charset. We'll have to detect the actual operating system or console provider (eclipse, ...) and use their specific functionalities to get the name of the actual charset.

这篇关于如何获取控制台字符集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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