Safe unicode encoding and decoding dance