Compare commits
7 Commits
v2.0.11
...
0799513ea2
Author | SHA1 | Date | |
---|---|---|---|
0799513ea2 | |||
effeee105c | |||
ed5b366341 | |||
9a520ddd9c | |||
2c43087d15 | |||
60ac1365a5 | |||
57027e234e |
9
.github/workflows/pypi-deploy.yml
vendored
9
.github/workflows/pypi-deploy.yml
vendored
@@ -40,15 +40,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: wheel-config
|
name: wheel-config
|
||||||
path: python/
|
path: python/
|
||||||
- name: Get vcpkg repo
|
|
||||||
if: matrix.os == 'windows-2019'
|
|
||||||
run: git clone https://github.com/Microsoft/vcpkg.git
|
|
||||||
- name: Build and install vcpkg and install libiconv for windows
|
|
||||||
if: matrix.os == 'windows-2019'
|
|
||||||
run: |
|
|
||||||
.\vcpkg\bootstrap-vcpkg.bat
|
|
||||||
vcpkg install libiconv
|
|
||||||
working-directory: vcpkg/
|
|
||||||
- name: Build wheels
|
- name: Build wheels
|
||||||
run: python -m cibuildwheel --output-dir wheelhouse
|
run: python -m cibuildwheel --output-dir wheelhouse
|
||||||
working-directory: python/
|
working-directory: python/
|
||||||
|
@@ -10,7 +10,11 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#if defined(__linux__) || defined(__APPLE__)
|
||||||
#include <iconv.h>
|
#include <iconv.h>
|
||||||
|
#elif defined(__WIN32__) || defined(_WIN32)
|
||||||
|
#define timegm _mkgmtime
|
||||||
|
#endif
|
||||||
|
|
||||||
//---------------------------------------------------------------------------//
|
//---------------------------------------------------------------------------//
|
||||||
|
|
||||||
@@ -144,12 +148,13 @@ namespace imc
|
|||||||
return sumstr;
|
return sumstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__linux__) || defined(__APPLE__)
|
||||||
// convert encoding of any descriptions, channel-names, units etc.
|
// convert encoding of any descriptions, channel-names, units etc.
|
||||||
class iconverter
|
class iconverter
|
||||||
{
|
{
|
||||||
std::string in_enc_, out_enc_;
|
std::string in_enc_, out_enc_;
|
||||||
iconv_t cd_;
|
iconv_t cd_;
|
||||||
size_t out_buffer_size_;
|
size_t out_buffer_size_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -215,6 +220,14 @@ namespace imc
|
|||||||
astring = outstring;
|
astring = outstring;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#elif defined(__WIN32__) || defined(_WIN32)
|
||||||
|
class iconverter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
iconverter(std::string in_enc, std::string out_enc, size_t out_buffer_size = 1024) {}
|
||||||
|
void convert(std::string &astring) {}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
// channel
|
// channel
|
||||||
struct channel
|
struct channel
|
||||||
@@ -483,28 +496,35 @@ namespace imc
|
|||||||
// convert any description, units etc. to UTF-8 (by default)
|
// convert any description, units etc. to UTF-8 (by default)
|
||||||
void convert_encoding()
|
void convert_encoding()
|
||||||
{
|
{
|
||||||
|
// actual input codepage
|
||||||
|
std::string cpn;
|
||||||
|
|
||||||
if ( !codepage_.empty() )
|
if ( !codepage_.empty() )
|
||||||
{
|
{
|
||||||
// construct iconv-compatible name for respective codepage
|
// construct iconv-compatible name for respective codepage
|
||||||
std::string cpn = std::string("CP") + codepage_;
|
cpn = std::string("CP") + codepage_;
|
||||||
|
|
||||||
// set up converter
|
|
||||||
std::string utf = std::string("UTF-8");
|
|
||||||
iconverter conv(cpn,utf);
|
|
||||||
|
|
||||||
conv.convert(name_);
|
|
||||||
conv.convert(comment_);
|
|
||||||
conv.convert(origin_);
|
|
||||||
conv.convert(origin_comment_);
|
|
||||||
conv.convert(text_);
|
|
||||||
conv.convert(language_code_);
|
|
||||||
conv.convert(yname_);
|
|
||||||
conv.convert(yunit_);
|
|
||||||
conv.convert(xname_);
|
|
||||||
conv.convert(xunit_);
|
|
||||||
conv.convert(group_name_);
|
|
||||||
conv.convert(group_comment_);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// assume codepage 1252 by default
|
||||||
|
cpn = std::string("CP1252");
|
||||||
|
}
|
||||||
|
|
||||||
|
// set up converter
|
||||||
|
std::string utf = std::string("UTF-8");
|
||||||
|
iconverter conv(cpn,utf);
|
||||||
|
|
||||||
|
conv.convert(name_);
|
||||||
|
conv.convert(comment_);
|
||||||
|
conv.convert(origin_);
|
||||||
|
conv.convert(origin_comment_);
|
||||||
|
conv.convert(text_);
|
||||||
|
conv.convert(language_code_);
|
||||||
|
conv.convert(yname_);
|
||||||
|
conv.convert(yunit_);
|
||||||
|
conv.convert(xname_);
|
||||||
|
conv.convert(xunit_);
|
||||||
|
conv.convert(group_name_);
|
||||||
|
conv.convert(group_comment_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get info string
|
// get info string
|
||||||
|
@@ -5,6 +5,16 @@ from IMCtermite cimport cppimctermite
|
|||||||
|
|
||||||
import json as jn
|
import json as jn
|
||||||
import decimal
|
import decimal
|
||||||
|
import platform
|
||||||
|
|
||||||
|
# auxiliary function for codepage conversion
|
||||||
|
def get_codepage(chn) :
|
||||||
|
if platform == 'Windows' :
|
||||||
|
chndec = jn.loads(chn.decode(errors="ignore"))
|
||||||
|
chncdp = chndec["codepage"]
|
||||||
|
return 'utf-8' if chncdp is None else chncdp
|
||||||
|
else :
|
||||||
|
return 'utf-8'
|
||||||
|
|
||||||
cdef class imctermite:
|
cdef class imctermite:
|
||||||
|
|
||||||
@@ -22,7 +32,7 @@ cdef class imctermite:
|
|||||||
# get JSON list of channels
|
# get JSON list of channels
|
||||||
def get_channels(self, bool include_data):
|
def get_channels(self, bool include_data):
|
||||||
chnlst = self.cppimc.get_channels(True,include_data)
|
chnlst = self.cppimc.get_channels(True,include_data)
|
||||||
chnlstjn = [jn.loads(chn.decode(errors="ignore")) for chn in chnlst]
|
chnlstjn = [jn.loads(chn.decode(get_codepage(chn),errors="ignore")) for chn in chnlst]
|
||||||
return chnlstjn
|
return chnlstjn
|
||||||
|
|
||||||
# print single channel/all channels
|
# print single channel/all channels
|
||||||
|
@@ -1 +1 @@
|
|||||||
2.0.9
|
2.0.16
|
||||||
|
Reference in New Issue
Block a user