mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-06 00:40:11 +00:00
Compilation fix
This commit is contained in:
parent
4d9add5e7c
commit
a77a75660b
@ -563,22 +563,22 @@ template<typename T, size_t size = sizeof(T)> struct be_storage
|
||||
|
||||
template<typename T> struct be_storage<T, 2>
|
||||
{
|
||||
typedef u16 type;
|
||||
using type = u16;
|
||||
};
|
||||
|
||||
template<typename T> struct be_storage<T, 4>
|
||||
{
|
||||
typedef u32 type;
|
||||
using type = u32;
|
||||
};
|
||||
|
||||
template<typename T> struct be_storage<T, 8>
|
||||
{
|
||||
typedef u64 type;
|
||||
using type = u64;
|
||||
};
|
||||
|
||||
template<typename T> struct be_storage<T, 16>
|
||||
{
|
||||
typedef u128 type;
|
||||
using type = u128;
|
||||
};
|
||||
|
||||
template<typename T> using be_storage_t = typename be_storage<T>::type;
|
||||
@ -587,7 +587,7 @@ template<typename T>
|
||||
struct be_t
|
||||
{
|
||||
using type = std::remove_cv_t<T>;
|
||||
using stype = be_storage_t<type>;
|
||||
using stype = be_storage_t<std::remove_cv_t<T>>;
|
||||
|
||||
stype m_data;
|
||||
|
||||
@ -853,7 +853,7 @@ force_inline void convert_le_be(Tto& dst, Tfrom src)
|
||||
template<typename T> struct le_t
|
||||
{
|
||||
using type = std::remove_cv_t<T>;
|
||||
using stype = be_storage_t<type>;
|
||||
using stype = be_storage_t<std::remove_cv_t<T>>;
|
||||
|
||||
stype m_data;
|
||||
|
||||
|
@ -25,7 +25,7 @@ endif()
|
||||
|
||||
if (NOT MSVC)
|
||||
add_definitions(-DwxGUI)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fexceptions")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fexceptions")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -D_DEBUG")
|
||||
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -D_NDEBUG")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O1 -D_NDEBUG")
|
||||
|
@ -8,37 +8,50 @@
|
||||
#include <iconv.h>
|
||||
#endif
|
||||
|
||||
//#include <codecvt>
|
||||
#include "cellL10n.h"
|
||||
#include <codecvt>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern Module cellL10n;
|
||||
|
||||
s32 UTF16stoUTF8s(vm::ptr<const char16_t> utf16, vm::ref<u32> utf16_len, vm::ptr<char> utf8, vm::ref<u32> utf8_len)
|
||||
{
|
||||
cellL10n.Warning("UTF16stoUTF8s(utf16=*0x%x, utf16_len=*0x%x, utf8=*0x%x, utf8_len=*0x%x)", utf16, utf16_len, utf8, utf8_len);
|
||||
cellL10n.Todo("UTF16stoUTF8s(utf16=*0x%x, utf16_len=*0x%x, utf8=*0x%x, utf8_len=*0x%x)", utf16, utf16_len, utf8, utf8_len);
|
||||
|
||||
std::u16string wstr;
|
||||
wstr.resize(utf16_len);
|
||||
const u32 max_len = utf8_len; utf8_len = 0;
|
||||
|
||||
for (auto& wc : wstr)
|
||||
for (u32 i = 0, len = 0; i < utf16_len; i++, utf8_len = len)
|
||||
{
|
||||
wc = *utf16++;
|
||||
const char16_t ch = utf16[i];
|
||||
|
||||
// increase required length (TODO)
|
||||
len = len + 1;
|
||||
|
||||
// validate character (TODO)
|
||||
if (false)
|
||||
{
|
||||
utf16_len = utf16_len - i;
|
||||
return SRCIllegal;
|
||||
}
|
||||
|
||||
if (utf8)
|
||||
{
|
||||
if (len > max_len)
|
||||
{
|
||||
utf16_len = utf16_len - i;
|
||||
return DSTExhausted;
|
||||
}
|
||||
|
||||
if (ch <= 0x7f)
|
||||
{
|
||||
*utf8++ = static_cast<char>(ch);
|
||||
}
|
||||
else
|
||||
{
|
||||
*utf8++ = '?'; // TODO
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
|
||||
std::string str = convert.to_bytes(wstr);
|
||||
|
||||
if (utf8_len < str.size())
|
||||
{
|
||||
utf8_len = str.size();
|
||||
return DSTExhausted;
|
||||
}
|
||||
|
||||
utf8_len = str.size();
|
||||
memcpy(utf8.get_ptr(), str.c_str(), str.size());
|
||||
|
||||
return ConversionOK;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user