[TxMt] Bundles, stdin and encoding

Hans-Jörg Bibiko bibiko at eva.mpg.de
Tue Dec 11 21:58:43 UTC 2007


On 11.12.2007, at 20:45, Álex Bueno wrote:
> I've been trying to make a TM command to convert text encodings  
> (with a nice little tm_dialog that took a while to figure out but  
> now works very well).
>
> But for some reason, it won't read the file correctly using stdin.
>
> So that this works:
> iconv -f $ENC -t UTF8 "$TM_FILEPATH"
>
> But this does not (nor do other variations on the theme using stdin):
> iconv -f $ENC -t UTF8 < /dev/stdin
>

Please note that if you try to pipe a text from TM à la

echo "$TM_SELECTED_TEXT" | iconv -f $ENC -t UTF8

and the text was written in SJIS or what ever, that TM already read  
this text! That means you will loose the original coding if the  
encoding was not supported by TM. In your case – TM doesn't support  
SJIS ergo it tries to read the text as UTF-8 and the result is  
mojibake - cryptic things.

A way would be:

cat YOURFILE | iconv -f $ENC -t UTF8

and insert this output into TM.

> TM seems to do something to the text to change its encoding, so  
> that iconv cannot convert properly.

--Hans






More information about the textmate mailing list