Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: froff on April 06, 2009, 01:44:32 pm

Title: cbEditor::SetEncoding - what's going on?
Post by: froff on April 06, 2009, 01:44:32 pm
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);*/
}

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 !!!
Title: Re: cbEditor::SetEncoding - what's going on?
Post by: Jenna on April 06, 2009, 02:02:07 pm
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 (http://forums.codeblocks.org/index.php/topic,10311.msg71169.html#msg71169) and http://forums.codeblocks.org/index.php/topic,10311.msg71178.html#msg71178 (http://forums.codeblocks.org/index.php/topic,10311.msg71178.html#msg71178).
Title: Re: cbEditor::SetEncoding - what's going on?
Post by: froff on April 06, 2009, 09:40:34 pm
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
Title: Re: cbEditor::SetEncoding - what's going on?
Post by: Jenna on April 06, 2009, 10:29:28 pm
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 (http://forums.codeblocks.org/index.php/topic,10191.0.html) ).
Title: Re: cbEditor::SetEncoding - what's going on?
Post by: Biplab on April 07, 2009, 09:32:22 am
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?

Makes sense. I do agree with you that we should give more flexibility. I'll make that change.
Title: Re: cbEditor::SetEncoding - what's going on?
Post by: froff on April 08, 2009, 08:30:35 pm
hello

This is fragment of file on which  detector fails.
8859-2; some comments in Polish.


[attachment deleted by admin]