Files
MinecraftConsoles/Minecraft.Client/PSVita/PSVitaExtras/PSVitaStrings.cpp
ModMaker101 a9be52c41a Project modernization (#630)
* Fixed boats falling and a TP glitch #266

* Replaced every C-style cast with C++ ones

* Replaced every C-style cast with C++ ones

* Fixed boats falling and a TP glitch #266

* Updated NULL to nullptr and fixing some type issues

* Modernized and fixed a few bugs

- Replaced most instances of `NULL` with `nullptr`.
- Replaced most `shared_ptr(new ...)` with `make_shared`.
- Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances.

* Fixing more conflicts

* Replace int loops with size_t and start work on overrides
2026-03-08 09:56:03 +07:00

51 lines
940 B
C++

#include "stdafx.h"
#include "PSVitaStrings.h"
#include <ces.h>
uint8_t *mallocAndCreateUTF8ArrayFromString(int iID)
{
LPCWSTR wchString=app.GetString(iID);
size_t src_len,dst_len;
int iLen=wcslen(wchString);
src_len=sizeof(WCHAR)*(iLen);
SceCesUcsContext context;
int result = sceCesUcsContextInit( &context );
if( result != S_OK )
{
app.DebugPrintf("sceCesUcsContextInit failed\n");
return nullptr;
}
uint32_t utf16Len;
uint32_t utf8Len;
result = sceCesUtf16StrGetUtf8Len( &context,
(uint16_t *)wchString,
iLen,
&utf16Len,
&utf8Len
);
utf8Len += 1;
uint8_t *strUtf8=(uint8_t *)malloc(utf8Len);
memset(strUtf8,0,utf8Len);
result = sceCesUtf16StrToUtf8Str(
&context,
(uint16_t *)wchString,
iLen,
&utf16Len,
strUtf8,
utf8Len,
&utf8Len
);
if( result != SCE_OK )
{
app.DebugPrintf("sceCesUtf16StrToUtf8Str: conversion error : 0x%x\n", result);
return nullptr;
}
return strUtf8;
}