fix log for Android that does not support <codecvt>

This commit is contained in:
2017-04-02 18:21:27 +01:00
parent 2dc7c4a9cc
commit dc693b2232
3 changed files with 10 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
#pragma once
#include "log.h"
#include "shader.h"
#include "shape.h"
#include "texture.h"

View File

@@ -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()
{

View File

@@ -47,8 +47,6 @@
#include <mutex>
#include <memory>
#include <string>
#include <locale>
#include <codecvt>
#include <vector>
#include <random>
#include <thread>