Author Topic: cbEditor::SetEncoding - what's going on?  (Read 4223 times)

Offline froff

  • Multiple posting newcomer
  • *
  • Posts: 16
cbEditor::SetEncoding - what's going on?
« 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 !!!
« Last Edit: April 06, 2009, 02:00:41 pm by froff »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: cbEditor::SetEncoding - what's going on?
« Reply #1 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 and http://forums.codeblocks.org/index.php/topic,10311.msg71178.html#msg71178.

Offline froff

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: cbEditor::SetEncoding - what's going on?
« Reply #2 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

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: cbEditor::SetEncoding - what's going on?
« Reply #3 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 ).

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: cbEditor::SetEncoding - what's going on?
« Reply #4 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.
Be a part of the solution, not a part of the problem.

Offline froff

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: cbEditor::SetEncoding - what's going on?
« Reply #5 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]