Extract UTF-8 decode to a function.