I would do this:

    if (arg.hasArray) {
      new String(arg.array, arg.arrayOffset, arg.readableBytes, charset)
    } else {
      arg.toString(charset)
    }