//
// cocos2d::CCFileUtilsWin32::utf8Togbk from 0x18007e2f0 to 0x18007e49c (428 bytes)
//
// 11 xrefs:
// > cocos2d::CCFileUtilsWin32::addSearchPath @ 0x18007d160
// > cocos2d::CCFileUtilsWin32::fullPathForFilename @ 0x18007d279
// > cocos2d::CCFileUtilsWin32::getPathForFilename @ 0x18007d35b
// > cocos2d::CCFileUtilsWin32::getPathForFilename @ 0x18007d376
// > cocos2d::CCFileUtilsWin32::getPathForFilename @ 0x18007d391
// > cocos2d::CCFileUtilsWin32::isAbsolutePath @ 0x18007de3a
// > cocos2d::CCFileUtilsWin32::isFileExist @ 0x18007df58
// > cocos2d::CCFileUtilsWin32::removeSearchPath @ 0x18007e1e0
// > ??> @ 0x18014cf68
// > ??> @ 0x1801befd4
// > ??> @ 0x1801befe0
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:22:01 +0000
//
// Hidden C++ exception states: #wind=1
void **__fastcall cocos2d::CCFileUtilsWin32::utf8Togbk(__int64 a1, void **a2, CHAR *a3)
{
int cchWideChar; // ebx
void *lpWideCharStr; // r14
int v7; // edi
void *v8; // r15
size_t v9; // rax
__int64 v10; // r8
void **v11; // rdi
void *v12; // rax
char *v13; // rbx
__int64 v14; // rax
size_t v15; // rax
cchWideChar = MultiByteToWideChar(0xFDE9u, 0, a3, -1, nullptr, 0);
lpWideCharStr = (void *)sub_1800E4C6C(saturated_mul(cchWideChar + 1, 2u));
memset(lpWideCharStr, 0, 2 * cchWideChar + 2);
MultiByteToWideChar(0xFDE9u, 0, a3, -1, (LPWSTR)lpWideCharStr, cchWideChar);
v7 = WideCharToMultiByte(0, 0, (LPCWCH)lpWideCharStr, -1, nullptr, 0, nullptr, nullptr);
v8 = (void *)sub_1800E4C6C(v7 + 1);
memset(v8, 0, v7 + 1);
WideCharToMultiByte(0, 0, (LPCWCH)lpWideCharStr, -1, (LPSTR)v8, v7, nullptr, nullptr);
*(_OWORD *)a2 = 0;
a2[2] = nullptr;
a2[3] = nullptr;
v9 = strlen((const char *)v8);
sub_18000CEF0(a2, v8, v9);
v11 = a2;
if ( (unsigned __int64)a2[3] > 0xF )
v11 = (void **)*a2;
v12 = a2[2];
if ( v12 )
{
v13 = (char *)v11 + (_QWORD)v12;
LOBYTE(v10) = 63;
v14 = sub_1800E4920(v11, (char *)v11 + (_QWORD)v12, v10);
if ( (char *)v14 != v13 && v14 - (_QWORD)v11 != -1 )
{
v15 = strlen(a3);
sub_1800101E0(a2, a3, v15);
}
}
j_j_free_0(v8);
j_j_free_0(lpWideCharStr);
return a2;
}