in reply to String to UTF-8
printf "%*vd\n", " ", $str; [download]
Update: you might want to chose some better title for your question, as the current one (String to UTF-8) has nothing to do with the question.