i am new to augeas, and i am getting plenty of errors like:
Could not evaluate: invalid byte sequence in UTF-8
in special i expect augeas to honor the encoding declaration in a XML-file
<?xml version="1.0" encoding="ISO-8859-1"?>
but in the source code of the lens i can not see that this is taken into account, but i could be wrong sense i do not understand much of the lenses format: https://github.com/hercules-team/augeas/blob/master/lenses/xml.aug
or that Java-Properties-File are always treated as ISO-8859-1
, and again no traces of any encoding in the source code of the lens:
https://github.com/hercules-team/augeas/blob/master/lenses/properties.aug
my first question is: does augeas infer the right encoding for XML and properties-Files?
my second question is: is there any way to tell augeas which encoding to use?
to repoduce
assuming systems default encoding is UTF-8:
vi testUTF.properties
# Käse
abc=test
# tèté
persona=niño
And everything is fine:
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"
Now converting the file into iso-8859-1:
iconv --from-code UTF-8 --to-code ISO-8859-1 -o testIso.properties testUTF.properties
and
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"
and now every thing is still ok, arghhh, should not be...
So, it is then for sure NOT an augeas problem, but a puppet problem
Refomulating my question:
is there any way to tell the Puppet augeas resource which encoding to use?
Many thanks in advance