* imc_channel.hpp: usage of iconv for unix only
* IMCtermite.pyx: add codepage conversion for windows * bump VERSION
This commit is contained in:
@@ -10,7 +10,9 @@
|
||||
#include <chrono>
|
||||
#include <ctime>
|
||||
#include <time.h>
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
#include <iconv.h>
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------//
|
||||
|
||||
@@ -147,8 +149,10 @@ namespace imc
|
||||
// convert encoding of any descriptions, channel-names, units etc.
|
||||
class iconverter
|
||||
{
|
||||
std::string in_enc_, out_enc_;
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
iconv_t cd_;
|
||||
#endif
|
||||
std::string in_enc_, out_enc_;
|
||||
size_t out_buffer_size_;
|
||||
|
||||
public:
|
||||
@@ -156,6 +160,7 @@ namespace imc
|
||||
iconverter(std::string in_enc, std::string out_enc, size_t out_buffer_size = 1024) :
|
||||
in_enc_(in_enc), out_enc_(out_enc), out_buffer_size_(out_buffer_size)
|
||||
{
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
// allocate descriptor for character set conversion
|
||||
// (https://man7.org/linux/man-pages/man3/iconv_open.3.html)
|
||||
cd_ = iconv_open(out_enc.c_str(), in_enc.c_str());
|
||||
@@ -169,10 +174,12 @@ namespace imc
|
||||
throw std::runtime_error(errmsg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void convert(std::string &astring)
|
||||
{
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
if ( astring.empty() ) return;
|
||||
|
||||
std::vector<char> in_buffer(astring.begin(),astring.end());
|
||||
@@ -214,6 +221,7 @@ namespace imc
|
||||
std::string outstring(out_buffer.begin(),out_buffer.end()-outbytes);
|
||||
astring = outstring;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
// channel
|
||||
|
Reference in New Issue
Block a user