Sorry, encoding of a string is a thing that has to be made explicit, and refPrint returns byte strings with no encoding information instead of Unicode strings containing wide characters that Mojolicious seems to be expecting. Are you allowed to change refPrint to return wide strings? Write a wrapper like sub refPrintW { decode utf8 => refPrint(@_) }?