Files
Loki Rautio 087b7e7abf Revert "Project modernization (#630)"
This code was not tested and breaks in Release builds, reverting to restore
functionality of the nightly. All in-game menus do not work and generating
a world crashes.

This reverts commit a9be52c41a.
2026-03-07 21:12:22 -06:00

51 lines
934 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 NULL;
}
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 NULL;
}
return strUtf8;
}