This is basically a two step problem.
- Generate a unique combination of symbols. Don't repeat the same combination twice.
- Decide whether or not the substitution generates meaningful output. This can either be done by manual inspection, or frequency analysis. If you choose to use frequency analysis, you'll need a decent set of frequencies to compare it against.
As far as your existing code is concerned, it might help if you put it in <CODE> tags.