BUG (SOLVED): TR locale causes SWIMMER → SWİMMER and skillset data loss on save

Started by roltemurto, March 30, 2026, 11:45:49 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

roltemurto

Environment:
Windows 10, Turkish locale (tr-TR)
Affects both SLXEditor 3.0.2 and NLEditor 1.42

Description:
On a system with Turkish locale, the editor corrupts .nxlv files in two ways when saving:

Skill name corruption: Skill keywords such as SWIMMER are saved as SWİMMER (with a dotted capital İ). This is caused by String.ToUpper() following Turkish locale rules, where i uppercases to İ instead of I. The NeoLemmix Player does not recognize SWİMMER as a valid keyword, so the skill is ignored entirely.
Skillset data loss: The entire $SKILLSET block is saved empty. Opening an existing level with skills defined (e.g. SWIMMER 4, DISARMER 2) and doing Save As produces a file with a blank $SKILLSET block, stripping all skill assignments. This appears to be a consequence of the same issue — the editor fails to match or write skill names when the locale-aware string comparison/conversion produces unexpected characters.

Root cause:
This is a well-known .NET pitfall sometimes called the "Turkish I problem". In most languages, i.ToUpper() produces I. However, Turkish (and a small number of other locales including Azerbaijani) have a dotted/dotless I distinction: they have four separate letters — i, İ, ı, I — and their casing rules reflect this. So on any tr-TR or az-AZ system, .NET's locale-aware string methods will silently produce different results than on any other system.
This is not a UTF-8 issue — the files are encoded correctly. It is purely a string operation behavior issue. The same bug would affect any user whose Windows system locale is set to Turkish or Azerbaijani, regardless of their keyboard layout or display language.
All calls to String.ToUpper(), String.ToLower(), and String.Compare() that deal with keywords or identifiers should explicitly pass CultureInfo.InvariantCulture to guarantee consistent behavior across all locales:

csharp
// Problematic:
keyword.ToUpper()
// Fix:
keyword.ToUpper(System.Globalization.CultureInfo.InvariantCulture)

Impact:
Any level saved through the editor loses its entire skillset. The editor is completely unusable for level creation on Turkish systems.
Affected locales are not limited to Turkish. The same dotted/dotless I distinction applies in Azerbaijani (az-AZ) and Crimean Tatar (CRT) and Kazakh (KAZ) as well.

WillLem

Thanks for reporting this. I've prepared a test version with the suggested fix (see attached), although it uses "ToUpperInvariant()" and "ToLowerInvariant()" instead, as this is shorthand for the same thing.

Can you confirm that this indeed fixes the issue?



EDIT: Attachment removed.


roltemurto

Quote from: WillLem on Today at 02:08:08 AMThanks for reporting this. I've prepared a test version with the suggested fix (see attached), although it uses "ToUpperInvariant()" and "ToLowerInvariant()" instead, as this is shorthand for the same thing.

Can you confirm that this indeed fixes the issue?



NOTE TO ALL: Please do not use the attached Editor for anything important as stability cannot be guaranteed. Thanks.



Dear WillLem,

Thank you so much for your rapid response and quick fix. I tried the exe and the fix indeed works as intended.   :lem-mindblown: :thumbsup:
To test it, I first opened a level with swimmers and used Save As. The saved copy did in fact carry the skillset forward and the spelling is now correct.
Then I edited the file, set the hatch object piece to spawn swimmers re-saved and that file is also saved correctly and both levels open correctly in the player.
You can count the infamous "Turkish I problem" as 'solved' for your release candidate.

I also set the level to spawn ten lemmings and added a lemmings object, setting it's skill to swimmer. As mentioned earlier even with the hatch being set to spawn swimmers and manually added a lemming, the Globals tab still shows "11 Normal" under the Lemmings spawn/release rate and save options. I am not sure if I am doing something wrong or if it's a bug I wanted to let you know about this as well.

Once again, I thank you so much on behalf of all the players who suffered from the "İ" problem, for fixing it.