@@ -247,10 +247,12 @@ void Extension::actionNew(TCHAR const *file, int flag)
247247void Extension::actionLoad (TCHAR const *file, int flag)
248248{
249249 data->ReadOnly = (flag? true : false );
250- std::basic_ifstream<TCHAR> ifs (file);
250+ std::ifstream ifs (file);
251251 if (ifs)
252252 {
253- return loadIni (ifs);
253+ // load entire file and convert it to unicode
254+ std::basic_istringstream<TCHAR> iss {utf16from8 (std::string (std::istreambuf_iterator<char >(ifs), {}))};
255+ return loadIni (iss);
254256 }
255257 else
256258 {
@@ -265,7 +267,11 @@ void Extension::actionSave()
265267
266268void Extension::actionSaveAs (TCHAR const *file)
267269{
268- // CHRILLEY
270+ // TODO: optionally create folders if they don't exist
271+ std::basic_ostringstream<TCHAR> oss;
272+ saveIni (oss);
273+ auto str = utf8from16 (oss.str ());
274+ std::ofstream{file} << str;
269275}
270276
271277void Extension::actionBackupTo (TCHAR const *file, int flag, TCHAR const *key)
@@ -482,16 +488,15 @@ void Extension::actionLoadChangeFile(TCHAR const *file, paramExt *settings) //TO
482488
483489 if (lt == LoadType::Load)
484490 {
485- loadIni (std::basic_ifstream<TCHAR>{file});
486- data->ReadOnly = readOnly;
491+ actionLoad (file, readOnly);
487492 }
488493 if (ft == FNameType::Change || (ft == FNameType::ChangeIfOk && exists))
489494 {
490495 data->autoSavePath = file;
491496 }
492497 if (saveNow)
493498 {
494- saveIni (std::basic_ofstream<TCHAR>{file} );
499+ actionSave ( );
495500 }
496501}
497502
0 commit comments