Compare commits
3 commits
3a2e8d05cb
...
e8db619e63
Author | SHA1 | Date | |
---|---|---|---|
e8db619e63 | |||
c4f2a99572 | |||
58d37d4cad |
4 changed files with 58 additions and 3 deletions
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -64,7 +64,8 @@
|
||||||
"cinttypes": "cpp",
|
"cinttypes": "cpp",
|
||||||
"condition_variable": "cpp",
|
"condition_variable": "cpp",
|
||||||
"mutex": "cpp",
|
"mutex": "cpp",
|
||||||
"hash_map": "cpp"
|
"hash_map": "cpp",
|
||||||
|
"future": "cpp"
|
||||||
},
|
},
|
||||||
"C_Cpp.clang_format_path": "/usr/bin/clang-format",
|
"C_Cpp.clang_format_path": "/usr/bin/clang-format",
|
||||||
"cmake.configureOnOpen": true,
|
"cmake.configureOnOpen": true,
|
||||||
|
|
|
@ -56,6 +56,8 @@ if (WIN32 AND NOT UNIX)
|
||||||
else(WIN32 AND NOT UNIX)
|
else(WIN32 AND NOT UNIX)
|
||||||
set(CPACK_SOURCE_GENERATOR "TBZ2")
|
set(CPACK_SOURCE_GENERATOR "TBZ2")
|
||||||
set(CPACK_GENERATOR "RPM;DEB")
|
set(CPACK_GENERATOR "RPM;DEB")
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64)
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5printsupport5 (>= 5.4), libjsoncpp1, libusb-1.0")
|
||||||
set(CPACK_STRIP_FILES "bin/kima2")
|
set(CPACK_STRIP_FILES "bin/kima2")
|
||||||
set(CPACK_SOURCE_STRIP_FILES "")
|
set(CPACK_SOURCE_STRIP_FILES "")
|
||||||
install(FILES ${CMAKE_SOURCE_DIR}/misc/kima2.desktop DESTINATION share/applications)
|
install(FILES ${CMAKE_SOURCE_DIR}/misc/kima2.desktop DESTINATION share/applications)
|
||||||
|
|
|
@ -13,9 +13,52 @@ std::string formatCentAsEuroString(const int cent, int width)
|
||||||
currStream << std::right << std::setw(width) << std::showbase
|
currStream << std::right << std::setw(width) << std::showbase
|
||||||
<< std::put_money(cent, false);
|
<< std::put_money(cent, false);
|
||||||
} catch (std::runtime_error& err) {
|
} catch (std::runtime_error& err) {
|
||||||
currStream << std::fixed << std::setw(width >= 4 ? width - 4 : width) << std::setprecision(2) << cent / 100.0L
|
currStream << std::fixed << std::setw(width >= 4 ? width - 4 : width)
|
||||||
<< " €";
|
<< std::setprecision(2) << cent / 100.0L << " €";
|
||||||
}
|
}
|
||||||
|
|
||||||
return currStream.str();
|
return currStream.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
// UTF-16 -> UTF-8 conversion
|
||||||
|
const std::string convert_to_utf8(const std::wstring& utf16_string)
|
||||||
|
{
|
||||||
|
// get length
|
||||||
|
int length =
|
||||||
|
WideCharToMultiByte(CP_UTF8, 0, utf16_string.c_str(), static_cast<int>(utf16_string.size()),
|
||||||
|
nullptr, 0, nullptr, nullptr);
|
||||||
|
if (!(length > 0))
|
||||||
|
return std::string();
|
||||||
|
else {
|
||||||
|
string result;
|
||||||
|
result.resize(static_cast<std::string::size_type>(length));
|
||||||
|
|
||||||
|
if (WideCharToMultiByte(CP_UTF8, 0, utf16_string.c_str(),
|
||||||
|
static_cast<int>(utf16_string.size()), &result[0],
|
||||||
|
static_cast<int>(result.size()), nullptr, nullptr) == 0)
|
||||||
|
throw error("Failure to execute convert_to_utf8: call to WideCharToMultiByte failed.");
|
||||||
|
else
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// UTF-8 -> UTF-16 conversion
|
||||||
|
const std::wstring convert_to_utf16(const std::string& utf8_string)
|
||||||
|
{
|
||||||
|
// get length
|
||||||
|
int length = MultiByteToWideChar(CP_UTF8, 0, utf8_string.c_str(), static_cast<int>(utf8_string.size()), nullptr, 0);
|
||||||
|
if(!(length > 0))
|
||||||
|
return std::wstring();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wstring result;
|
||||||
|
result.resize(static_cast<std::string::size_type>(length));
|
||||||
|
|
||||||
|
if(MultiByteToWideChar(CP_UTF8, 0, utf8_string.c_str(), static_cast<int>(utf8_string.size()),
|
||||||
|
&result[0], static_cast<int>(result.size())) == 0 )
|
||||||
|
throw error("Failure to execute convert_to_utf16: call to MultiByteToWideChar failed.");
|
||||||
|
else
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -3,6 +3,15 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string formatCentAsEuroString(const int cent, int width = 10);
|
std::string formatCentAsEuroString(const int cent, int width = 10);
|
||||||
|
|
||||||
|
#ifdef __WIN32
|
||||||
|
const std::string convert_to_utf8(const std::wstring& utf16_string);
|
||||||
|
const std::wstring convert_to_utf16(const std::string& utf8_string);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in a new issue