Hello to all,
I have a question about writing a wxTextfile: I can not find a way to let my file be saved with iso 8859-2 encoding.
In practice, I would like to force the encoding of the file in the way I exposed it.
It's possible?
text file and 8859-2 encoding [SOLVED]
text file and 8859-2 encoding [SOLVED]
Last edited by Berico3 on Wed Sep 27, 2017 9:48 pm, edited 3 times in total.
OS: Windows XP Pro & Debiam Linux COMPILER: MingW, Version: wxWidgets 2.8.0, IDE: wx-Devcpp
Re: text file and 8859-2 encoding
My understanding is that the string is iso 8859-2 encoded in memory and then written to file
Thanks
Best Regards
Ellan
Best Regards
Ellan
Re: text file and 8859-2 encoding
Using wxCSConv with wxTextFile::Write works as expected for me:
I tested the code with "Příliš žluťoučký kůň úpěl ďábelské ódy." and checked the actual character values (for š and ž in particular) displaying the resulting file with a hex viewer.
But I am using wxWidgets 3 in Unicode mode, your signature hints that you are not?
Code: Select all
#include <wx/wx.h>
#include <wx/textdlg.h>
#include <wx/textfile.h>
class MyApp : public wxApp
{
public:
bool OnInit()
{
wxTextEntryDialog dlg(NULL, "Input text");
if ( dlg.ShowModal() != wxID_OK || dlg.GetValue().empty() )
return false;
wxTextFile textFile;
if ( textFile.Create("test.txt") )
{
textFile.AddLine(dlg.GetValue());
textFile.Write(wxTextFileType_None, wxCSConv("iso8859-2"));
}
return false;
}
}; wxIMPLEMENT_APP(MyApp);
But I am using wxWidgets 3 in Unicode mode, your signature hints that you are not?
Re: text file and 8859-2 encoding
Thank you for your answers.
I also normally use unicode encoding, but I'm working on a software that modifies text files (that is Gcode), since the files will then have to be read by a CNC machine, I would prefer that they keep the original encoding.
Thanks again.
I also normally use unicode encoding, but I'm working on a software that modifies text files (that is Gcode), since the files will then have to be read by a CNC machine, I would prefer that they keep the original encoding.
Thanks again.
OS: Windows XP Pro & Debiam Linux COMPILER: MingW, Version: wxWidgets 2.8.0, IDE: wx-Devcpp