NMS-5281 handle non-ASCII UTF-8 properly (reimplemented)