From b119675d0295c019cf7808d920d7cec708b68c76 Mon Sep 17 00:00:00 2001 From: sripp Date: Mon, 5 Oct 2026 15:10:08 +0200 Subject: [PATCH 1/2] Keep characters without single-char upper case in NaturalComparer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JS toUpperCase maps 'ß' to 'SS', while C# char.ToUpperInvariant keeps 'ß'. Keep the original character when the upper case is not a single character, so the sort order matches the C# version. Co-Authored-By: Claude Opus 5.5 --- TiaCodegen-ts/src/Extensions/NaturalComparer.ts | 10 ++++++++-- TiaCodegen-ts/tests/NaturalComparer.test.ts | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/TiaCodegen-ts/src/Extensions/NaturalComparer.ts b/TiaCodegen-ts/src/Extensions/NaturalComparer.ts index cf49d0a..b8b51bc 100644 --- a/TiaCodegen-ts/src/Extensions/NaturalComparer.ts +++ b/TiaCodegen-ts/src/Extensions/NaturalComparer.ts @@ -22,8 +22,8 @@ export class NaturalComparer { if (vx !== vy) return vx < vy ? -1 : 1; } else { // Ordinal comparison like char.ToUpperInvariant(cx).CompareTo(...) in the C# version - const ux = cx.toUpperCase(); - const uy = cy.toUpperCase(); + const ux = this.toUpperChar(cx); + const uy = this.toUpperChar(cy); if (ux !== uy) return ux < uy ? -1 : 1; i++; j++; @@ -35,4 +35,10 @@ export class NaturalComparer { private isDigit(c: string): boolean { return c >= '0' && c <= '9'; } + + // char.ToUpperInvariant keeps characters without a single-char upper case (e.g. 'ß' -> 'SS' in JS) + private toUpperChar(c: string): string { + const upper = c.toUpperCase(); + return upper.length === 1 ? upper : c; + } } diff --git a/TiaCodegen-ts/tests/NaturalComparer.test.ts b/TiaCodegen-ts/tests/NaturalComparer.test.ts index 63dd2b8..7ad12e1 100644 --- a/TiaCodegen-ts/tests/NaturalComparer.test.ts +++ b/TiaCodegen-ts/tests/NaturalComparer.test.ts @@ -12,4 +12,10 @@ describe('NaturalComparer', () => { expect(comparer.compare('a2', 'a10')).toBeLessThan(0); expect(comparer.compare('a', 'A')).toBe(0); }); + + test('keeps characters without a single-char upper case like C# ToUpperInvariant', () => { + const comparer = new NaturalComparer(); + expect(comparer.compare('xßy', 'xzy')).toBeGreaterThan(0); + expect(comparer.compare('xßy', 'xÜy')).toBeGreaterThan(0); + }); }); From 0377d0f17b30963de10a5b3c1cfd8b41902598b1 Mon Sep 17 00:00:00 2001 From: sripp Date: Mon, 5 Oct 2026 15:13:38 +0200 Subject: [PATCH 2/2] Bump tia-codegen-ts to 2.0.2 Co-Authored-By: Claude Opus 5.5 --- TiaCodegen-ts/package-lock.json | 4 ++-- TiaCodegen-ts/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/TiaCodegen-ts/package-lock.json b/TiaCodegen-ts/package-lock.json index 8703977..be4de9c 100644 --- a/TiaCodegen-ts/package-lock.json +++ b/TiaCodegen-ts/package-lock.json @@ -1,12 +1,12 @@ { "name": "@node-projects/tia-codegen-ts", - "version": "2.0.1", + "version": "2.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@node-projects/tia-codegen-ts", - "version": "2.0.1", + "version": "2.0.2", "devDependencies": { "@types/jest": "^29.5.12", "@types/node": "^20.12.7", diff --git a/TiaCodegen-ts/package.json b/TiaCodegen-ts/package.json index b53e105..b8e6352 100644 --- a/TiaCodegen-ts/package.json +++ b/TiaCodegen-ts/package.json @@ -1,6 +1,6 @@ { "name": "@node-projects/tia-codegen-ts", - "version": "2.0.1", + "version": "2.0.2", "description": "TypeScript port of TiaCodeGen C# library", "type": "module", "main": "dist/index.js",