java平台默认字符集,Java:平台的默认字符集在不同的平台?

这篇博客探讨了在不同操作系统中,如Windows、Linux和Mac上,系统默认字符集的问题。在西方平台通常是UTF-8或CP1250/1252,但在俄罗斯和亚洲平台则可能是UTF-16或其他特定的字符集。作者提醒,这些设置是用户可自定义的,并建议在启动应用程序时通过设置系统属性`file.encoding`来指定编码,以确保一致性。
摘要由CSDN通过智能技术生成

Some legacy code relies on the platform's default charset for translations. For Windows and Linux installations in the "western world" I know what that means. But thinking about Russian or Asian platforms I am totally unsure what their platform's default charset is (just UTF-16?).

Therefore I would like to know what I would get when executing the following code line:

System.out.println("Default Charset=" + Charset.defaultCharset());

Edit:

I don't want to discuss the problems of charsets and their difference to unicode here. I just want to collect what operating systems will result in what specific charset. Please post only concrete values!

解决方案

That's a user specific setting. On many modern Linux systems, it's UTF-8. On Macs, it’s MacRoman. In the US on Windows, it's often CP1250, in Europe it's CP1252. In China, you often find simplified chinese (Big5 or a GB*).

But that’s the system default, which each user can change at any time. Which is probably the solution: Set the encoding when you start your app using the system property file.encoding

See this answer how to do that. I suggest to put this into a small script which starts your app, so the user default isn't tainted.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值