fix encoding problems in code generation