Skip to content

Commit

Permalink
Switch to single byte string
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Nov 3, 2024
1 parent 72b9d63 commit 3383d4f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/patch_java_manifest_for_utf8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ int wmain(int argc, wchar_t *argv[]) {
}
DWORD manifestLen = SizeofResource(exe, manifestResource);

std::wstring manifest((wchar_t *) manifestData, manifestLen / sizeof(wchar_t));
fwprintf(stderr, L"Manifest data: %ls\n", manifest.c_str());
std::string manifest((char *) manifestData, manifestLen);
fwprintf(stderr, L"Manifest data: %s\n", manifest.c_str());

UnlockResource(manifestHandle);
FreeResource(manifestHandle);

std::size_t insertPos = manifest.find(L"</asmv3:windowsSettings>");
std::size_t insertPos = manifest.find("</asmv3:windowsSettings>");
if (insertPos == std::wstring::npos) {
fwprintf(stderr, L"End tag not found.\n");
return 1;
}
std::wstring newManifest = manifest.substr(0, insertPos) +
L"<activeCodePage xmlns=\"http://schemas.microsoft.com/SMI/2019/WindowsSettings\">UTF-8</activeCodePage>" +
std::string newManifest = manifest.substr(0, insertPos) +
"<activeCodePage xmlns=\"http://schemas.microsoft.com/SMI/2019/WindowsSettings\">UTF-8</activeCodePage>" +
manifest.substr(insertPos);

fwprintf(stderr, L"Modified manifest data: %ls\n", newManifest.c_str());
Expand All @@ -78,8 +78,8 @@ int wmain(int argc, wchar_t *argv[]) {
MAKEINTRESOURCEW(1),
MAKEINTRESOURCEW(24),
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
(wchar_t*) newManifest.c_str(),
newManifest.size() * sizeof(wchar_t))) {
(char *) newManifest.c_str(),
newManifest.size())) {
fwprintf(stderr, L"Error updating resource.\n");
return 1;
}
Expand Down

0 comments on commit 3383d4f

Please sign in to comment.