//
// tinyxml2::XMLUtil::ConvertUTF32ToUTF8 from 0xb2348c to 0xb235b4 (296 bytes)
//
// 2 xrefs:
// > tinyxml2::XMLUtil::GetCharacterRef @ 0xb23684
// > ??> @ 0x51240
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __fastcall tinyxml2::XMLUtil::ConvertUTF32ToUTF8(unsigned __int64 this, __int64 a2, char *a3, int *a4)
{
__int64 v4; // x1
char v5; // w2
__int64 v7; // x5
__int64 v8; // x4
char v9; // w1
_QWORD v10[7]; // [xsp+10h] [xbp+10h]
v10[0] = 0;
v10[2] = 192;
v10[3] = 224;
v10[4] = 240;
v10[1] = 0;
v10[5] = 248;
v10[6] = 252;
if ( this > 0x7F )
{
if ( this > 0x7FF )
{
if ( this <= 0xFFFF )
{
v8 = a2 + 3;
*(_DWORD *)a3 = 3;
}
else
{
if ( this > 0x1FFFFF )
{
*(_DWORD *)a3 = 0;
return _stack_chk_guard;
}
*(_DWORD *)a3 = 4;
v8 = a2 + 3;
*(_BYTE *)(a2 + 3) = this & 0x3F | 0x80;
this >>= 6;
}
v7 = v8 - 1;
v9 = this & 0x3F | 0x80;
this >>= 6;
*(_BYTE *)(v8 - 1) = v9;
}
else
{
v7 = a2 + 2;
*(_DWORD *)a3 = 2;
}
v4 = v7 - 1;
*(_BYTE *)(v7 - 1) = this & 0x3F | 0x80;
this >>= 6;
v5 = v10[*(int *)a3];
}
else
{
v4 = a2 + 1;
*(_DWORD *)a3 = 1;
v5 = 0;
}
*(_BYTE *)(v4 - 1) = v5 | this;
return _stack_chk_guard;
}