Dir-A / Dir-A_Essays_MD

自己的一点感悟

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about c++

Cosetto opened this issue · comments

So I have ToHalfWidth() function and I want to add it to dllmain
Can you check if correct or not? And I'm not sure how to write a table of characters for that, like:
{ L'a', L'a' },
{ L'b', L'b' },
image
It's for a game only accepts full-width characters only.
image

I'm not quite sure what your question is.

If you just want to write full-width strings to the game's scripts and then convert them to half-width strings when you run the game, you should hook the game's or system‘s function used to draw character.

I've never used VNTextProxy, but I checked it out just now, and its general process is to hook some system API related to draw character, and convert character via SjisTunnelEncoding Before entering API funcation.

https://github.com/arcusmaximus/VNTranslationTools/blob/main/VNTextProxy/GdiProportionalizer.cpp#L191
For example, if the game uses GetGlyphOutlineA to get glyph data,
then hook this function and then convert input character(uChar) to wide char via SjisTunnelEncoding::Decode,
then call GetGlyphOutlineW to get the graph data.

But the input character does not have to be the same as the displayed character, in other words the character can be 'A' but SjisTunnelEncoding::Decode can convert the character to 'B' before actually fetching the graph data.
So although the game script write 'A', the game actually displays 'B', which can be used to bypass some game's character check.

So the answer is obvious, you should change SjisTunnelEncoding::Decode

https://github.com/arcusmaximus/VNTranslationTools/blob/main/VNTextProxy/SjisTunnelEncoding.cpp#L38C13-L38C13

return StringUtil::ToHalfWidth(result);

https://github.com/arcusmaximus/VNTranslationTools/blob/main/VNTextProxy/GdiProportionalizer.cpp#L199C52-L199C52

 wstring wstr = SjisTunnelEncoding::Decode(str);
 wstr = StringUtil::ToHalfWidth(wstr)

Thanks a lot bro, this should be helpful for games which only accept full-width text.