detect character encoding detection and handle conversion