fix #4177: TextUtils.getMatch ignores last parameter
Use an explicit charset when encoding a string
Code and parameter naming cleanup
Use lesser-arguments form of getMatch when possible