Hi there. I'm having a problem with encoding detection on certain files. The files in question are written in ISO-8859-1. But when opening, C::B claims they were written in ISO-8859-7.
The lines in question are:
if(this.fundamentos_legales[j].descripcion.indexOf(this.nombre_legislaciones[k].legislacion) != -1
|| this.fundamentos_legales[j].descripcion.indexOf(this.nombre_legislaciones[k].legislacion.replace(/[áéíóúñ]/gi,'')) != -1
|| this.fundamentos_legales[j].descripcion.indexOf(this.nombre_legislaciones[k].legislacioncorto) != -1
|| this.fundamentos_legales[j].descripcion.indexOf(this.nombre_legislaciones[k].legislacioncorto.replace(/[áéíóúñ]/gi,'')) != -1)
{
See the accented characters there? They throw off the auto-detection (C::B changes them to "αινσϊρ". I can't tell C::B to use exclusively ISO-8859-1 because I have utf-8 files elsewhere. How can I tell C::B to use either ISO-8859-1,Windows-1252 *OR* utf-8?
Please help! :(
EDIT: Bug reported in https://developer.berlios.de/bugs/?func=detailbug&bug_id=18316&group_id=5358
I have an idea of what C::B should do. You could specify in the project settings (or the global settings, maybe both) what encodings can be autodetected. If an opened file is detected to be in another encoding, a confirmation dialog should open.
"This file was detected as ISO-8859-7, but we could be mistaken. Do you wish to use ISO-8859-7 as the encoding, or open it with another encoding?"
Then you choose the other encoding, with the option to [ ] Always open as _______ (encoding goes here).
The problem with encoding-detection, is that it works better if it has more text to test, the greatest problem are single characters.
It should work better, if you add some spanish (or other ISO-8859-1) comments.
We could also give the latin1-detection more precedence over the other detections, but this will most likely break the detection of other encodings.
The mozilla-developers have lowered the confidence of the latin1-prober, to make detection more accurate:
// lower the confidence of latin1 so that other more accurate detector
// can take priority.
confidence *= 0.50f;
With the following comment (italian as far as I know), I took from a file used to test encoding-detection, your sample works here:
//L'albero è sul comò e perciò chissà perché non sarà più lì!!