locale changes, piscreen
This commit is contained in:
@@ -85,6 +85,7 @@ ushort charFromCodepage(const char * c, int size, const char * codepage, int * t
|
||||
wchar_t wc;
|
||||
ret = mbrtowc(&wc, c, size, &state);
|
||||
//printf("mbtowc = %d\n", ret);
|
||||
//piCout << errorString();
|
||||
if (ret < 1) return 0;
|
||||
return ushort(wc);
|
||||
# endif
|
||||
|
||||
@@ -151,9 +151,6 @@ PRIVATE_DEFINITION_START(PICout)
|
||||
static WORD dattr;
|
||||
static DWORD smode;
|
||||
#endif
|
||||
#ifdef HAS_LOCALE
|
||||
std::wstring_convert<std::codecvt_utf8<char16_t>, char16_t> utf8conv;
|
||||
#endif
|
||||
PRIVATE_DEFINITION_END(PICout)
|
||||
|
||||
#ifdef WINDOWS
|
||||
@@ -546,20 +543,24 @@ PICout & PICout::writePIString(const PIString & s) {
|
||||
if (buffer_) {
|
||||
buffer_->append(s);
|
||||
} else {
|
||||
|
||||
if (PICout::isOutputDeviceActive(PICout::StdOut)) {
|
||||
#ifdef HAS_LOCALE
|
||||
std::cout << PRIVATE->utf8conv.to_bytes((char16_t*)&(const_cast<PIString&>(s).front()), (char16_t*)&(const_cast<PIString&>(s).front()) + s.size());
|
||||
#else
|
||||
for (PIChar c: s) std::wcout.put(c.toWChar());
|
||||
#endif
|
||||
}
|
||||
if (PICout::isOutputDeviceActive(PICout::StdOut))
|
||||
stdoutPIString(s);
|
||||
if (PICout::isOutputDeviceActive(PICout::Buffer)) PICout::__string__().append(s);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void PICout::stdoutPIString(const PIString & s) {
|
||||
#ifdef HAS_LOCALE
|
||||
std::wstring_convert<std::codecvt_utf8<char16_t>, char16_t> utf8conv;
|
||||
std::cout << utf8conv.to_bytes((char16_t*)&(const_cast<PIString&>(s).front()), (char16_t*)&(const_cast<PIString&>(s).front()) + s.size());
|
||||
#else
|
||||
for (PIChar c: s) std::wcout.put(c.toWChar());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void PICout::init() {
|
||||
#ifdef WINDOWS
|
||||
if (__Private__::hOut == 0) {
|
||||
|
||||
@@ -291,6 +291,10 @@ public:
|
||||
//! \~russian Пишет сырой \a PIString
|
||||
PICout & writePIString(const PIString & s);
|
||||
|
||||
//! \~english Output \a PIString to stdout
|
||||
//! \~russian Вывод \a PIString в stdout
|
||||
static void stdoutPIString(const PIString & s);
|
||||
|
||||
//! \~english Set output device to \a PICout::Buffer and if "clear" clear it
|
||||
//! \~russian Устанавливает устройство вывода на \a PICout::Buffer и если "clear" то очищает его
|
||||
static bool setBufferActive(bool on, bool clear = false);
|
||||
|
||||
@@ -157,7 +157,8 @@ PIInit::PIInit() {
|
||||
freelocale(currentLocale_t);
|
||||
currentLocale_t = 0;
|
||||
}
|
||||
currentLocale_t = newlocale(LC_ALL, setlocale(LC_ALL, ""), 0);
|
||||
currentLocale_t = newlocale(LC_ALL, setlocale(LC_ALL, "C"), 0);
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user