fix log for Android that does not support <codecvt>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "log.h"
|
||||
#include "shader.h"
|
||||
#include "shape.h"
|
||||
#include "texture.h"
|
||||
|
||||
@@ -73,13 +73,19 @@ void LogRemote::log(const wchar_t* format, ...)
|
||||
std::wstring string_to_convert(buffer, n);
|
||||
|
||||
//setup converter
|
||||
using convert_type = std::codecvt_utf8<wchar_t>;
|
||||
std::wstring_convert<convert_type, wchar_t> converter;
|
||||
// using convert_type = std::codecvt_utf8<wchar_t>;
|
||||
// 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)
|
||||
//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()
|
||||
{
|
||||
|
||||
@@ -47,8 +47,6 @@
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <locale>
|
||||
#include <codecvt>
|
||||
#include <vector>
|
||||
#include <random>
|
||||
#include <thread>
|
||||
|
||||
Reference in New Issue
Block a user