Properly encode topic strings.