rcrowley / mustache.sh

Mustache in POSIX shell
Other
81 stars 8 forks source link

Encoding problems #1

Closed malk closed 11 years ago

malk commented 11 years ago

Hello there,

awesome to see that mustache.sh exists

While using it as a library in an UTF-8 system (vanilla debian Wheezy) it has the strange tendency of borking characters

as in

echo "télétransmettre" | mustache
# => tltransmettre

So, initially I assumed that mustache.sh, just has a "favourite" encoding I searched the github page and found no information on the subject

So I tried

echo "télétransmettre" | mustache > /tmp/what-is-mustache.sh-encoding
file -bi /tmp/what-is-mustache.sh-encoding 
# => text/plain; charset=iso-8859-1

and supposed it was iso-8859-1, but no such luck

echo "télétransmettre" | iconv -f utf-8 -t iso-8859-1 | mustache | iconv -f iso-8859-1 -t utf-8
# => tééransmettre

So I tried "brute-guessing" what would be mustache.sh's encoding

iconv --list | while read ENCODING
do
    echo $ENCODING
    echo "télétransmettre" | iconv -f utf-8 -t $ENCODING | mustache | iconv -f $ENCODING -t utf-8
done 

which gave-me surprisingly UTF7 as a working encoding for mustache!? (I did not even know that UTF7 exist at all)

echo "télétransmettre" | iconv -f UTF7 -t iso-8859-1 | mustache | iconv -f iso-8859-1 -t UTF7
# => "télétransmettre"

While this works on Debian, my production machine (AIX) has no UTF7 support, so currently I am more inclined to seek an alternative (mustache.pl probably)

So this issue is for 3 purposes

1) Can mustache.sh please support UTF8? 2) Failing that Can you at least confirm if my guess of UTF7 is correct or just dumb luck? 3) Can you please at least put on the project page a note stating that mustache.sh is encoding dependent and stating the encoding?

Have a nice day!

malk commented 11 years ago

Actually, UTF7 does not work either, because at UTF7 mustache does not replace anything (it does nothing, in fact)

after some tests it seems that the only thing that works is ISO-2022-JP-2 (or ISO-2022-JP-3)

Strangely you are not Japanese?

malk commented 11 years ago

this is solved by my pull-request already merged (thanks!) so one may as well close this issue