Added a function to check whether a (UTF-8) string is a valid token.