如何指定Java源文件的编码? [英] How can I specify the encoding of Java source files?
本文介绍了如何指定Java源文件的编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Python中,我可以指定文件顶部的编码:
# - * - 编码:utf-8 - * -
Java中有一个等价物吗?如何检测/指定.java文件的编码?
解决方案
您可以在使用参数编译文件时进行设置-encoding
http://docs.oracle.com/javase/6/docs/technotes/tools/windows/javac.html
I use weird Unicode strings in my Java test cases. The compiler seemingly interprets the file as iso-8859-1, causing JUnit to complain.
In Python I can specify the encoding at the top of the file:
# -*- coding: utf-8 -*-
Is there an equivalent in Java? How can I detect / specify the encoding of .java files?
解决方案
You can set it when you compile the file with the parameter "-encoding"
http://docs.oracle.com/javase/6/docs/technotes/tools/windows/javac.html
这篇关于如何指定Java源文件的编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文