Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sv_Replace(StringVar::Replace function in StringVar.cpp) does not take into account when the target is a multibyte character(Problems occurred with Ultimate Leveling in Japanese environment.) #229

Closed
oto-git opened this issue May 31, 2024 · 2 comments

Comments

@oto-git
Copy link

oto-git commented May 31, 2024

When Experience based leveling is selected in Ultimate Leveling,
When the skill name is set to Japanese, the skill level does not increase even if the points are allocated to Mysticism.

I checked the Ultimate Leveling script, and found that when assigning skill points, there is a process that converts "_" to " " using sv_Replace in the normalization of skill names, as shown below, but at this time a misconversion occurred, and the misconverted characters were used in the subsequent process, causing the problem.

*mytile is the name of the skill

Begin Function { mytile }

set i to 1 + sv_Find "\" mytile
while i > 0
	sv_Erase mytile 0 i
	set i to 1 + sv_Find "\" mytile
loop

; REPLACE _ WITH SPACE
sv_Replace "_| " mytile


SetFunctionValue mytile

If the character in the mytile variable was "神秘", it was mis-converted to "??秘" with sv_Replace "_| ".
(For environments with Japaneseized skill names, Mysticism is named "神秘".)

I checked the StringVar::Replace function in StringVar.cpp, which handles sv_Replace, and found that it assumes that the string used is a single-byte character.
It seems that the character to be searched for is treated as a single-byte character, not a multibyte character, and may be incorrectly converted if the character to be replaced in sv_Replace specifies a single-byte character.
(In the previous example of misconversion, the character code for the search target "神秘" in bytes is 90 5F 94 E9, the character code for the character "_" before substitution is 5F, and the character code for the character " " after substitution is 20, so 90 5F 94 E9 is converted to 90 20 94 E9, which is converted into the character "??秘")

@llde
Copy link
Owner

llde commented May 31, 2024

Thanks for the report, quite the important issue here.
Most of StringVar may assume Single byte character, and I need to check how to handle this properly.
The first step is a small script I can use to reproduce the problem in autonomy.

@llde llde added this to the 22-final milestone May 31, 2024
llde added a commit that referenced this issue Aug 12, 2024
…r components to single byte char, provided that the system locale is setted according to the character set required. Stop gap measure for fixing bug #229, until a more proper solution can be implemented for #235
@llde
Copy link
Owner

llde commented Aug 12, 2024

Closing with the stopgap measure of using wide strings in b3c9331.
Be careful to have the proper locale setted in the system

@oto-git

@llde llde closed this as completed Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants