How to convert string encoding of a keyword field

Considering if it may be better to convert hardwired input string encoding to ie. UTF8 for possible better displaying a long the way, eg. like:

if (ctx.containsKey('epj.role')) {
  String utf8String = new String(ctx.epj.role.getBytes("ISO-8859-1"), "UTF-8");
  ctx.epj.role = utf8String;
}

only this code wont compile and thus can't be save and tested, wondering what is wrong with this painless code that ChatGPT hinted me at, any better hints much appreciated, TIA!