Compare commits
3 Commits
ecbae3f79b
...
v2.0.13
Author | SHA1 | Date | |
---|---|---|---|
60ac1365a5 | |||
57027e234e | |||
887d5db635 |
14
.github/workflows/pypi-deploy.yml
vendored
14
.github/workflows/pypi-deploy.yml
vendored
@@ -40,16 +40,12 @@ jobs:
|
||||
with:
|
||||
name: wheel-config
|
||||
path: python/
|
||||
- name: Install iconv for Windows
|
||||
- name: Install libiconv for windows
|
||||
if: matrix.os == 'windows-2019'
|
||||
steps:
|
||||
- name: Get vcpkg repo
|
||||
run: git clone https://github.com/Microsoft/vcpkg.git
|
||||
- name: Install vcpkg
|
||||
run: .\vcpkg\bootstrap-vcpkg.bat
|
||||
working-directory: vcpkg/
|
||||
- name: Install required package libiconv
|
||||
run: vcpkg install libiconv
|
||||
run: |
|
||||
git clone https://github.com/Microsoft/vcpkg.git
|
||||
.\vcpkg\bootstrap-vcpkg.bat
|
||||
vcpkg install libiconv
|
||||
- name: Build wheels
|
||||
run: python -m cibuildwheel --output-dir wheelhouse
|
||||
working-directory: python/
|
||||
|
@@ -233,3 +233,6 @@ can be found in the `python/examples` folder.
|
||||
- https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
||||
- https://github.com/pypa/cibuildwheel/blob/main/examples/github-deploy.yml
|
||||
- https://cibuildwheel.readthedocs.io/en/stable/deliver-to-pypi/
|
||||
- https://www.gnu.org/software/libiconv/
|
||||
- https://vcpkg.io/en/packages.html
|
||||
- https://vcpkg.io/en/getting-started
|
||||
|
@@ -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
|
||||
|
@@ -5,6 +5,16 @@ from IMCtermite cimport cppimctermite
|
||||
|
||||
import json as jn
|
||||
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:
|
||||
|
||||
@@ -22,7 +32,7 @@ cdef class imctermite:
|
||||
# get JSON list of channels
|
||||
def get_channels(self, bool 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
|
||||
|
||||
# print single channel/all channels
|
||||
|
@@ -1 +1 @@
|
||||
2.0.9
|
||||
2.0.12
|
||||
|
Reference in New Issue
Block a user