Skip to content

Commit

Permalink
Merge pull request #48 from ChrisHal/always-use-C-locale-for-Igor
Browse files Browse the repository at this point in the history
use locale manager to set "C" locale for igor wavenote creation
  • Loading branch information
ChrisHal authored Aug 21, 2024
2 parents 75d3ca3 + 121d0d5 commit 4f98f6b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
13 changes: 1 addition & 12 deletions QtPMbrowser/pmbrowserwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,17 +793,6 @@ void PMbrowserWindow::on_actionExport_All_as_IBW_triggered()
}
}

class locale_manager {
std::locale old_locale{};
public:
void setLocale(const char* name){
old_locale = std::locale::global(std::locale(name));
}
~locale_manager() {
std::locale::global(old_locale);
}
};

void PMbrowserWindow::on_actionExport_Metadata_as_Table_triggered()
{
if (!assertDatFileOpen()) {
Expand All @@ -812,7 +801,7 @@ void PMbrowserWindow::on_actionExport_Metadata_as_Table_triggered()
DlgExportMetadata dlg(this);
if (dlg.exec()) {
try {
locale_manager lm;
hkLib::locale_manager lm;
if (dlg.useSystemLocale()) {
lm.setLocale(""); // set default locale
}
Expand Down
2 changes: 2 additions & 0 deletions hekatoolslib/exportIBW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ namespace hkLib {

std::string MakeWaveNote(hkTreeNode& TrRecord)
{
locale_manager lm;
lm.setLocale("C"); // always use C locale for Igor wavenotes
std::stringstream note;
formatParamListExportIBW(*TrRecord.getParent()->getParent()->getParent()->getParent(), parametersRoot, note);
formatParamListExportIBW(*TrRecord.getParent()->getParent()->getParent(), parametersGroup, note);
Expand Down
12 changes: 12 additions & 0 deletions hekatoolslib/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,17 @@ namespace hkLib {
/// <param name="count">count of trace (starting from 1)</param>
/// <returns>string containing canonical trace-name</returns>
std::string formTraceName(const hkTreeNode& tr, int count);


class locale_manager {
std::locale old_locale{};
public:
void setLocale(const char* name) {
old_locale = std::locale::global(std::locale(name));
}
~locale_manager() {
std::locale::global(old_locale);
}
};
}
#endif // !HELPERS_H

0 comments on commit 4f98f6b

Please sign in to comment.