mirror of
https://github.com/decompals/wibo.git
synced 2025-10-16 07:05:11 +00:00
more debug logs for wstr conversions
This commit is contained in:
parent
8af589882e
commit
4c9918ff2a
@ -138,10 +138,13 @@ namespace msvcrt {
|
||||
|
||||
size_t varnamelen = wstrlen(varname);
|
||||
|
||||
DEBUG_LOG("\tSearching env vars...\n");
|
||||
for(uint16_t** env = __winitenv; env && *env; ++env){
|
||||
uint16_t* cur = *env;
|
||||
std::string cur_str = wideStringToString(cur);
|
||||
DEBUG_LOG("\tCur env var: %s\n", cur_str.c_str());
|
||||
if(wstrncmp(cur, varname, varnamelen) == 0 && cur[varnamelen] == L'='){
|
||||
DEBUG_LOG("Found the env var %s!\n", var_str.c_str());
|
||||
uint16_t* value = cur + varnamelen + 1;
|
||||
size_t value_len = wstrlen(value);
|
||||
|
||||
@ -156,6 +159,7 @@ namespace msvcrt {
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_LOG("Could not find env var %s\n", var_str.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
13
strutil.cpp
13
strutil.cpp
@ -5,8 +5,11 @@
|
||||
#include <string>
|
||||
#include <locale>
|
||||
#include <codecvt>
|
||||
#include <sstream>
|
||||
|
||||
size_t wstrlen(const uint16_t *str) {
|
||||
if(!str) return 0;
|
||||
|
||||
size_t len = 0;
|
||||
while (str[len] != 0)
|
||||
++len;
|
||||
@ -126,13 +129,23 @@ std::string wideStringToString(const uint16_t *src, int len = -1) {
|
||||
|
||||
// the old implementation
|
||||
std::string res(len, '\0');
|
||||
std::string debug_wstr;
|
||||
std::stringstream ss;
|
||||
bool is_wide = false;
|
||||
for (int i = 0; i < len; i++) {
|
||||
ss << "0x" << std::hex << src[i] << " ";
|
||||
// debug_wstr += std::format("0x%X ", src[i]);
|
||||
if(src[i] > 255){
|
||||
// DEBUG_LOG("Encountered wide char with value 0x%X!\n", src[i]);
|
||||
// assert(src[i] <= 255);
|
||||
is_wide = true;
|
||||
}
|
||||
res[i] = src[i] & 0xFF;
|
||||
}
|
||||
if(is_wide){
|
||||
debug_wstr += ss.str();
|
||||
DEBUG_LOG("wideString (%d): %s\n", wstrlen(src), debug_wstr.c_str());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user