Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

cbEditor::SetEncoding - what's going on?

(1/2) > >>

froff:
hello
I'm new to c::b so be tolerant please :)

According to encoding detection issue i made small code investigation.
I found something interesting:


--- Code: ---void cbEditor::SetEncoding( wxFontEncoding encoding )
{
    if (!m_pData)
        return;

    if ( encoding == wxFONTENCODING_SYSTEM )
        encoding = wxLocale::GetSystemEncoding();

    if ( encoding == GetEncoding() )
        return;

    m_pData->m_encoding = encoding;
    SetModified(true);

    /* NOTE (Biplab#1#): Following method is wrong. The file is still in old encoding
    *  So if you try to load it with new encoding, you'll get garbage*/
    /*wxString msg;
    msg.Printf(_("Do you want to reload the file with the new encoding (you will lose any unsaved work)?"));
    if (cbMessageBox(msg, _("Reload file?"), wxYES_NO) == wxID_YES)
        Reload(false);
    else
        SetModified(true);*/
}

--- End code ---

Why the code at the end is commented ???
If encoding detector fails (it was happened to me :( ) I have _NO_WAY_ to repair its mistake by reloading file with proper encoding !!!

Jenna:
You are on ubuntu 8.10 (Intrepid Ibex) is that right ?

Do you use te C::B shipped with ubuntu (8.02-release, not 8.02svnxxx) ?

If yes you should update to a recent nightly build, and you have more possibilities to chose from in "Settings -> Editor... -> General settings -> Encoding", even overwriting C::B's autodetection.

You can download it either from my repo (it's for debian, but also works with ubuntu) see signature,

or from Xaviou's or pasgui's repo, see http://forums.codeblocks.org/index.php/topic,10311.msg71169.html#msg71169 and http://forums.codeblocks.org/index.php/topic,10311.msg71178.html#msg71178.

froff:
Thanks. :)
Snapshot works good for me, but:

Don't You agree that there should be possibility to change file encoding without converting it (cbEditor::SetEncoding()) ?
Having fixed default encoding I may would like sometimes to open special file with different one.
Having automatically detected encodings I may change encoding when detector fails.
Full flexibility. Doesn't it make sense?

Best Regards

Jenna:
I think the most important thing is, that encoding detection works.

It would be really nice, if you can send me the both cpp-files (or at least the "bad" one).
I'm currently working on or better testing a patch to enhance encoding detection and I am therefore interested in files with not so common encodings, or encodings whre the detection fails in current C::B (see this thread: http://forums.codeblocks.org/index.php/topic,10191.0.html ).

Biplab:

--- Quote from: froff on April 06, 2009, 09:40:34 pm ---Don't You agree that there should be possibility to change file encoding without converting it (cbEditor::SetEncoding()) ?
Having fixed default encoding I may would like sometimes to open special file with different one.
Having automatically detected encodings I may change encoding when detector fails.
Full flexibility. Doesn't it make sense?

--- End quote ---

Makes sense. I do agree with you that we should give more flexibility. I'll make that change.

Navigation

[0] Message Index

[#] Next page

Go to full version