optimized escaping of special charactes