improve backslash escape detection in TextFormatter