Compare commits
2 Commits
4aa596b179
...
53ec75bf0c
| Author | SHA1 | Date | |
|---|---|---|---|
| 53ec75bf0c | |||
| f5270d75eb |
@@ -366,7 +366,7 @@ PICout & PICout::operator<<(PIFlags<PICoutManipulators::PICoutFormat> v) {
|
|||||||
|
|
||||||
void PICout::stdoutPIString(const PIString & str, PICoutStdStream s) {
|
void PICout::stdoutPIString(const PIString & str, PICoutStdStream s) {
|
||||||
#ifdef HAS_LOCALE
|
#ifdef HAS_LOCALE
|
||||||
std::wstring_convert<std::codecvt_utf8<char16_t>, char16_t> utf8conv;
|
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> utf8conv;
|
||||||
getStdStream(s) << utf8conv.to_bytes((char16_t *)&(const_cast<PIString &>(str).front()),
|
getStdStream(s) << utf8conv.to_bytes((char16_t *)&(const_cast<PIString &>(str).front()),
|
||||||
(char16_t *)&(const_cast<PIString &>(str).front()) + str.size());
|
(char16_t *)&(const_cast<PIString &>(str).front()) + str.size());
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -32,7 +32,6 @@
|
|||||||
# ifdef ESP_PLATFORM
|
# ifdef ESP_PLATFORM
|
||||||
# include "esp_system.h"
|
# include "esp_system.h"
|
||||||
# endif
|
# endif
|
||||||
# include <codecvt>
|
|
||||||
# ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
# include <winsock2.h>
|
# include <winsock2.h>
|
||||||
extern FILETIME __pi_ftjan1970;
|
extern FILETIME __pi_ftjan1970;
|
||||||
@@ -149,9 +148,6 @@ PIInit::PIInit() {
|
|||||||
}
|
}
|
||||||
currentLocale_t = newlocale(LC_ALL, setlocale(LC_ALL, "C"), 0);
|
currentLocale_t = newlocale(LC_ALL, setlocale(LC_ALL, "C"), 0);
|
||||||
setlocale(LC_CTYPE, "en_US.UTF-8");
|
setlocale(LC_CTYPE, "en_US.UTF-8");
|
||||||
// std::ios_base::sync_with_stdio(false);
|
|
||||||
// std::locale utf8( std::locale(), new std::codecvt_utf8<wchar_t> );
|
|
||||||
// std::wcout.imbue(utf8);
|
|
||||||
# else // HAS_LOCALE
|
# else // HAS_LOCALE
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
setlocale(LC_NUMERIC, "C");
|
setlocale(LC_NUMERIC, "C");
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ void PIString::appendFromChars(const char * c, int s, const char * codepage) {
|
|||||||
d.enlarge(sz);
|
d.enlarge(sz);
|
||||||
MultiByteToWideChar((uint)(uintptr_t)codepage, MB_ERR_INVALID_CHARS, c, s, (LPWSTR)d.data(old_sz), sz);
|
MultiByteToWideChar((uint)(uintptr_t)codepage, MB_ERR_INVALID_CHARS, c, s, (LPWSTR)d.data(old_sz), sz);
|
||||||
# else
|
# else
|
||||||
std::wstring_convert<std::codecvt_utf8<char16_t>, char16_t> ucs2conv;
|
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> ucs2conv;
|
||||||
std::u16string ucs2 = ucs2conv.from_bytes(c, c + s);
|
std::u16string ucs2 = ucs2conv.from_bytes(c, c + s);
|
||||||
d.enlarge(ucs2.size());
|
d.enlarge(ucs2.size());
|
||||||
ucs2.copy((char16_t *)d.data(old_sz), ucs2.size());
|
ucs2.copy((char16_t *)d.data(old_sz), ucs2.size());
|
||||||
@@ -488,7 +488,7 @@ void PIString::buildData(const char * cp) const {
|
|||||||
data_size_ = sz;
|
data_size_ = sz;
|
||||||
return;
|
return;
|
||||||
# else
|
# else
|
||||||
std::wstring_convert<std::codecvt_utf8<char16_t>, char16_t> ucs2conv;
|
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> ucs2conv;
|
||||||
std::string u8str = ucs2conv.to_bytes((char16_t *)d.data(), (char16_t *)d.data() + d.size());
|
std::string u8str = ucs2conv.to_bytes((char16_t *)d.data(), (char16_t *)d.data() + d.size());
|
||||||
data_ = (char *)malloc(u8str.size() + 1);
|
data_ = (char *)malloc(u8str.size() + 1);
|
||||||
strcpy(data_, u8str.c_str());
|
strcpy(data_, u8str.c_str());
|
||||||
|
|||||||
Reference in New Issue
Block a user