Fixes #1474.  Strange encoding differences with UTF-8 strings.  Fix from jkl1337