无法从java中的.properties资源文件中读取泰语字符
我有一个资源文件(.properties文件),其中包含泰语字符 当我使用下面的代码读取该文件时,它会显示垃圾字符,如“?” 请建议如何进行此操作 提前感谢,,无法从java中的.properties资源文件中读取泰语字符,java,properties,resourcebundle,thai,Java,Properties,Resourcebundle,Thai,我有一个资源文件(.properties文件),其中包含泰语字符 当我使用下面的代码读取该文件时,它会显示垃圾字符,如“?” 请建议如何进行此操作 提前感谢,, Sandy如果文件的编码正确,则必须注意,System.out将无法使用默认控制台设置打印UTF-8字符。确保用于显示输出的控制台也采用UTF-8编码 例如,在Eclipse中,您需要转到RunConfiguration>Common来执行此操作 属性文件通常以ISO 8859-1编码进行解释。如果需要此集合中未包含的其他字符,请使用u
Sandy如果文件的编码正确,则必须注意,
System.out
将无法使用默认控制台设置打印UTF-8字符。确保用于显示输出的控制台也采用UTF-8编码
例如,在Eclipse中,您需要转到RunConfiguration>Common来执行此操作
属性文件通常以ISO 8859-1编码进行解释。如果需要此集合中未包含的其他字符,请使用unicode转义,如
\uxxx
。还有一些工具可用于将具有不同编码的属性文件转换为此属性文件(请参见native2ascii
)。您对捆绑文件使用了什么编码?看见
package RD1.Common;
import java.util.Enumeration;
import java.util.Locale;
import java.util.ResourceBundle;
public class LabelManagerRD {
public static String[] getLabel(String ParamString1)
{
String NextEle = "";
String str2 = ParamString1;
int i = 1;
String Final[] = new String[1000];
ResourceBundle bundle =
ResourceBundle.getBundle("rd", Locale.US);
Enumeration<String> enumeration = bundle.getKeys();
while (enumeration.hasMoreElements())
{
NextEle = enumeration.nextElement();
if (NextEle.toLowerCase().contains(str2.toLowerCase()))
{
Final[i] = NextEle+"="+bundle.getString(NextEle);
i++;
}
}
return Final;
}
public static void main(String[] args)
{
try
{
String TestValue[] = getLabel("RD.RDRAPCEX");
for(int i=1;i<=TestValue.length;i++)
{
if (!(TestValue[i].length()==0))
{
System.out.println(i+" - "+TestValue[i]);
}
}
}
catch (Exception e)
{
}
}
}
BL_BLNG_GROUP.BL_BLNG_GRP.BLNG_GRP_ID.IP=รสสรืเ เพนีย รก~^PAGE_1~^Y~^N
BL_BLNG_GROUP.BL_BLNG_GRP.LONG_DESC.IP=Long Desc~^PAGE_1~^Y~^N
BL_BLNG_GROUP.BL_BLNG_GRP.SHORT_DESC.IP=Short Desc~^PAGE_1~^Y~^N
BL_BLNG_GROUP.BL_BLNG_GRP.DETAIL_DESC.IP=Explanatory Note~^PAGE_1~^Y~^N