Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/build-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ jobs:
arch: x86_64
test-bin-suffix: .md.exe

- identifier: windows-debug-mingw
os: windows-latest
name: 🏁 Windows Debug (MinGW)
target: template_debug
platform: windows
arch: x86_64
mingw: true
test-bin-suffix: .md.exe

- identifier: windows-debug-replace
os: windows-latest
name: 🏁 Windows Debug (Replace Error UTF Compliance)
Expand All @@ -39,6 +48,15 @@ jobs:
arch: x86_64
test-bin-suffix: .md.exe

- identifier: windows-release-mingw
os: windows-latest
name: 🏁 Windows Release (MinGW)
target: template_release
platform: windows
arch: x86_64
mingw: true
test-bin-suffix: .md.exe

- identifier: macos-debug
os: macos-latest
name: 🍎 macOS (universal) Debug
Expand Down Expand Up @@ -98,6 +116,10 @@ jobs:
submodules: recursive
persist-credentials: false

- name: Setup MinGW for Windows/MinGW build
if: matrix.platform == 'windows' && (matrix.mingw || false)
uses: egor-tensin/setup-mingw@ef0952fadae6794e225c0c1654887408bcadbf64

- name: Build
uses: ./.github/actions/openvic-dl-build
with:
Expand Down
14 changes: 8 additions & 6 deletions src/openvic-dataloader/detail/ConvertGbk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
#include <lexy/input/buffer.hpp>
#include <lexy/input/file.hpp>

#ifdef _WIN32
#if __has_include(<iconv.h>)
#include <iconv.h>
#elif defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#elif defined(__unix__) || defined(__APPLE__) || __has_include(<iconv.h>)
#include <iconv.h>
#elif defined(__unix__) || defined(__APPLE__)
#error "<iconv.h> not found on POSIX system"
#endif

namespace ovdl::convert::gbk {
Expand All @@ -42,7 +44,7 @@ namespace ovdl::convert::gbk {
default: break;
}

#if defined(__unix__) || defined(__APPLE__) || __has_include(<iconv.h>)
#if __has_include(<iconv.h>)
iconv_t cd = ::iconv_open("UTF-8", "WINDOWS-936");
if (cd == (iconv_t)-1) {
return lexy::buffer<Encoding, MemoryResource> { resource };
Expand Down Expand Up @@ -102,7 +104,7 @@ namespace ovdl::convert::gbk {
}
return false;
};
#if defined(_WIN32)
#if !__has_include(<iconv.h>) && defined(_WIN32)
auto iconv_mimic = [&]() -> int64_t {
static constexpr size_t CP_GBK = 936;
static constexpr size_t MB_CHAR_MAX = 16;
Expand Down Expand Up @@ -205,7 +207,7 @@ namespace ovdl::convert::gbk {
}
}
}
#elif defined(__unix__) || defined(__APPLE__) || __has_include(<iconv.h>)
#elif __has_include(<iconv.h>)
const auto end = in_buffer + size;
while (in_size > 0 && out_size > 0 && in_buffer != end) {
if (::iconv(cd, &in_buffer, &in_size, &out_buffer, &out_size) == -1) {
Expand Down