what do you mean, "in your code"?
The tr examples that are given are to be used from the command line, i.e. independently of the shell script.
They are, in fact, one-liners. A one-liner generally is a sequence of commands that are all on one line, and don't need a script.
It's really surprising tr doesn't work for you. It's one of the legendary *nix commands.
Thank god no Perlhacker got sight of this question, they see oneliners as Art!