使用jdk1.8.0时<?xml version =“ 1.0” encoding =“ cp850” standalone =“ no”?>变为<?xml version =“ 1.0” encoding =“ 850” standalone =“ no”?>

在jdk1.6.0中,“ cp850”可以显示在xml声明中

<?xml version="1.0" encoding="cp850" standalone="no"?>

但是当我使用jdk1.8.0时,编码类型变为“ 850”,而没有“ cp”

<?xml version="1.0" encoding="850" standalone="no"?>

使用jdk1.8.0时如何使编码变为“ cp850”?

我尝试对xml声明进行硬编码。尽管编码变为“ cp850”,但似乎不是正确的方法。

transformer.setOutputProperty(OutputKeys.OMIT_XML_DeclARATION,"yes");  
writer.write("<?xml version=\"1.0\" encoding=\""+encoding+"\" standalone=\"no\"?>"); 

我还比较了两个Java版本库,发现它们都具有rt.jar。 在Java SE 8中,https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html Cp850有一个新的别名或别名为“ 850”的别名吗?

原始代码

 String encoding = "cp850";
 transformer.setOutputProperty(OutputKeys.ENCODING,encoding);

提前,Neko

hellokitys 回答:使用jdk1.8.0时<?xml version =“ 1.0” encoding =“ cp850” standalone =“ no”?>变为<?xml version =“ 1.0” encoding =“ 850” standalone =“ no”?>

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3140373.html

大家都在问