Proper character conversion, the code is surprisingly pretty :)