Hi there
This is a simpler application of the idea I mentioned in my previous post. It uses the fact that $0 is the name of the command issued. Save this as "f8t16" in a folder in your path:
Then make a link (soft or hard, both work, but not an alias) to this file with the numbers you want to convert to and fro. A couple of examples:Code:#!/bin/bash name=$(basename $0) # extract just the name from the absolute name to=${name#*t} # get rid of everything up to and including the first "t" from=${name#f} # get rid of the first "f" from=${from%t*} # and then everything after (and including) the first "t" iconv -f utf${from} -t utf${to} "$*" # finally issue the iconv with the proper flags to the arguments
The idea can be exploited for other kinds of encoding, but that is left as an exercise to the reader.Code:pabloa$ ln f8t16 f16t8 pabloa$ ln f16t8 f16bet16le # from utf16 big endian to utf16 little endian
Cheers.
P.




LinkBack URL
About LinkBacks





Reply With Quote
