Fixed endless loop on utf8 characters in names

fixes mantis issue 4331