fix log for Android that does not support <codecvt>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "log.h"
|
||||||
#include "shader.h"
|
#include "shader.h"
|
||||||
#include "shape.h"
|
#include "shape.h"
|
||||||
#include "texture.h"
|
#include "texture.h"
|
||||||
|
|||||||
@@ -73,13 +73,19 @@ void LogRemote::log(const wchar_t* format, ...)
|
|||||||
std::wstring string_to_convert(buffer, n);
|
std::wstring string_to_convert(buffer, n);
|
||||||
|
|
||||||
//setup converter
|
//setup converter
|
||||||
using convert_type = std::codecvt_utf8<wchar_t>;
|
// using convert_type = std::codecvt_utf8<wchar_t>;
|
||||||
std::wstring_convert<convert_type, wchar_t> converter;
|
// std::wstring_convert<convert_type, wchar_t> converter;
|
||||||
|
|
||||||
|
mbstate_t st = {};
|
||||||
|
std::string converted;
|
||||||
|
converted.reserve(string_to_convert.size());
|
||||||
|
const wchar_t * wptr = string_to_convert.c_str();
|
||||||
|
std::wcsrtombs((char*)converted.data(), &wptr, converted.capacity(), &st);
|
||||||
|
|
||||||
//use converter (.to_bytes: wstr->str, .from_bytes: str->wstr)
|
//use converter (.to_bytes: wstr->str, .from_bytes: str->wstr)
|
||||||
//std::string converted_str = converter.to_bytes(string_to_convert);
|
//std::string converted_str = converter.to_bytes(string_to_convert);
|
||||||
|
|
||||||
m_mq.Post(converter.to_bytes(string_to_convert));
|
m_mq.Post(std::move(converted));
|
||||||
}
|
}
|
||||||
LogRemote::~LogRemote()
|
LogRemote::~LogRemote()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,8 +47,6 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <locale>
|
|
||||||
#include <codecvt>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|||||||
Reference in New Issue
Block a user