aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/utils/file.cpp11
-rw-r--r--src/utils/file.hpp4
-rw-r--r--src/utils/locale_independent_float.cpp18
-rw-r--r--src/utils/locale_independent_float.hpp8
4 files changed, 24 insertions, 17 deletions
diff --git a/src/utils/file.cpp b/src/utils/file.cpp
index 3aeb4fc5..a7fc87e8 100644
--- a/src/utils/file.cpp
+++ b/src/utils/file.cpp
@@ -25,11 +25,18 @@
*/
#include "file.hpp"
+#include <string>
+#include <locale>
+
+#include <boost/program_options/detail/utf8_codecvt_facet.hpp>
namespace usdx
{
- File::File(const std::string& filename) : file(filename.c_str(), std::ifstream::in)
+ File::File(const std::string& filename) : file(filename.c_str(), std::wifstream::in)
{
+ std::locale global_loc = std::locale();
+ std::locale loc(global_loc, new boost::program_options::detail::utf8_codecvt_facet());
+ file.imbue(loc);
}
File::~File(void)
@@ -37,7 +44,7 @@ namespace usdx
file.close();
}
- std::istream &File::stream(void)
+ std::wistream &File::stream(void)
{
return file;
}
diff --git a/src/utils/file.hpp b/src/utils/file.hpp
index ed1ec14e..d08d7eb5 100644
--- a/src/utils/file.hpp
+++ b/src/utils/file.hpp
@@ -35,12 +35,12 @@ namespace usdx
class File
{
private:
- std::ifstream file;
+ std::wifstream file;
public:
File(const std::string& filename);
virtual ~File(void);
- std::istream &stream(void);
+ std::wistream &stream(void);
};
};
diff --git a/src/utils/locale_independent_float.cpp b/src/utils/locale_independent_float.cpp
index e0015cee..606ec998 100644
--- a/src/utils/locale_independent_float.cpp
+++ b/src/utils/locale_independent_float.cpp
@@ -38,7 +38,7 @@ namespace usdx
{
}
- LocaleIndependentFloat::LocaleIndependentFloat(std::string& value)
+ LocaleIndependentFloat::LocaleIndependentFloat(std::wstring& value)
{
this->operator=(value);
}
@@ -65,27 +65,27 @@ namespace usdx
return *this;
}
- LocaleIndependentFloat& LocaleIndependentFloat::operator= (std::string& value)
+ LocaleIndependentFloat& LocaleIndependentFloat::operator= (std::wstring& value)
{
- std::size_t found = value.find(',');
- if (found != std::string::npos) {
- value[found] = '.';
+ std::size_t found = value.find(L',');
+ if (found != std::wstring::npos) {
+ value[found] = L'.';
}
- std::istringstream str(value);
+ std::wistringstream str(value);
str >> this->value;
return *this;
}
- std::istream& operator>> (std::istream& is, LocaleIndependentFloat& float_value)
+ std::wistream& operator>> (std::wistream& is, LocaleIndependentFloat& float_value)
{
return is >> &float_value;
}
- std::istream& operator>> (std::istream& is, LocaleIndependentFloat* float_value)
+ std::wistream& operator>> (std::wistream& is, LocaleIndependentFloat* float_value)
{
- std::string str_value;
+ std::wstring str_value;
is >> str_value;
*float_value = str_value;
diff --git a/src/utils/locale_independent_float.hpp b/src/utils/locale_independent_float.hpp
index 82801868..f3674695 100644
--- a/src/utils/locale_independent_float.hpp
+++ b/src/utils/locale_independent_float.hpp
@@ -37,7 +37,7 @@ namespace usdx
float value;
public:
LocaleIndependentFloat();
- LocaleIndependentFloat(std::string& value);
+ LocaleIndependentFloat(std::wstring& value);
virtual ~LocaleIndependentFloat();
@@ -46,11 +46,11 @@ namespace usdx
LocaleIndependentFloat& operator= (const LocaleIndependentFloat& value);
LocaleIndependentFloat& operator= (const float& vaule);
- LocaleIndependentFloat& operator= (std::string& vaule);
+ LocaleIndependentFloat& operator= (std::wstring& vaule);
};
- std::istream& operator>> (std::istream& is, LocaleIndependentFloat& float_value);
- std::istream& operator>> (std::istream& is, LocaleIndependentFloat* float_value);
+ std::wistream& operator>> (std::wistream& is, LocaleIndependentFloat& float_value);
+ std::wistream& operator>> (std::wistream& is, LocaleIndependentFloat* float_value);
};