重现

重现

我是 augeas 的新手,我遇到了很多错误,例如:

Could not evaluate: invalid byte sequence in UTF-8

我特别希望 augeas 能够遵守 XML 文件中的编码声明

<?xml version="1.0" encoding="ISO-8859-1"?>

但是在镜头的源代码中我看不到这一点被考虑到了,但我可能是错的,因为我不太了解镜头的格式: https://github.com/hercules-team/augeas/blob/master/lenses/xml.aug

或者 Java-Properties-File 始终被视为ISO-8859-1,并且镜头源代码中没有任何编码的痕迹: https://github.com/hercules-team/augeas/blob/master/lenses/properties.aug

我的第一个问题是:augeas 是否推断出 XML 和属性文件的正确编码?

我的第二个问题是:有什么办法可以告诉 augeas 使用哪种编码?

重现

假设系统默认编码是UTF-8:

vi testUTF.properties

# Käse
abc=test
# tèté
persona=niño

一切都很好:

puppet-test:~ # augtool --noautoload
augtool> set /augeas/load/Properties/lens Properties.lns
augtool> set /augeas/load/Properties/incl "/root/testUTF.properties"
augtool> load
augtool> print /augeas/files/root/testUTF.properties
/augeas/files/root/testUTF.properties
/augeas/files/root/testUTF.properties/path = "/files/root/testUTF.properties"
/augeas/files/root/testUTF.properties/mtime = "1491478421"
/augeas/files/root/testUTF.properties/lens = "Properties.lns"
/augeas/files/root/testUTF.properties/lens/info = "/usr/share/augeas/lenses/dist/properties.aug:25.20-.53:"
augtool> print /files/root/testUTF.properties
/files/root/testUTF.properties
/files/root/testUTF.properties/#comment[1] = "K\303\244se"
/files/root/testUTF.properties/abc = "test"
/files/root/testUTF.properties/#comment[2] = "t\303\250t\303\251"
/files/root/testUTF.properties/persona = "ni\303\261o"

现在将文件转换为 iso-8859-1:

iconv --from-code UTF-8 --to-code ISO-8859-1 -o testIso.properties testUTF.properties

puppet-test:~ # augtool --noautoload
augtool> set /augeas/load/Properties/lens Properties.lns
augtool> set /augeas/load/Properties/incl "/root/testIso.properties"
augtool> load
augtool> print /augeas/files/root/testIso.properties
/augeas/files/root/testIso.properties
/augeas/files/root/testIso.properties/path = "/files/root/testIso.properties"
/augeas/files/root/testIso.properties/mtime = "1491478512"
/augeas/files/root/testIso.properties/lens = "Properties.lns"
/augeas/files/root/testIso.properties/lens/info = "/usr/share/augeas/lenses/dist/properties.aug:25.20-.53:"
augtool> print /files/root/testIso.properties
/files/root/testIso.properties
/files/root/testIso.properties/#comment[1] = "K\344se"
/files/root/testIso.properties/abc = "test"
/files/root/testIso.properties/#comment[2] = "t\350t\351"
/files/root/testIso.properties/persona = "ni\361o"

现在一切都还好,啊,不应该...

所以,这肯定不是奥格斯问题,而是傀儡问题

重新表述我的问题:

有什么方法可以告诉 Puppet augeas 资源使用哪种编码?

提前谢谢了

相关内容