From fab94e65ecdc343c2baf6a5bacedfdc565c560a6 Mon Sep 17 00:00:00 2001 From: webbrain-one <295484252+webbrain-one@users.noreply.github.com> Date: Wed, 12 Aug 2026 05:14:40 +0300 Subject: [PATCH] fix: correct database filename encoding on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Creating a database with characters like 'ä' resulted in garbled filenames (e.g., 'ä') due to encoding issues. Closes #160 --- .../node-firebird-driver-native/src/lib/attachment.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/node-firebird-driver-native/src/lib/attachment.ts b/packages/node-firebird-driver-native/src/lib/attachment.ts index 7f1d63d..dd65452 100644 --- a/packages/node-firebird-driver-native/src/lib/attachment.ts +++ b/packages/node-firebird-driver-native/src/lib/attachment.ts @@ -46,7 +46,16 @@ export class AttachmentImpl extends AbstractAttachment { return await client.statusAction(async (status) => { const dpb = createDpb(options); - attachment.attachmentHandle = await client!.dispatcher!.createDatabaseAsync(status, uri, dpb.length, dpb); + let encodedUri = uri; + if (process.platform === 'win32') { + try { + const { default: iconv } = await import('iconv-lite'); + encodedUri = iconv.encode(uri, 'cp0').toString('binary'); + } catch { + // Fallback to original URI if iconv-lite is not available + } + } + attachment.attachmentHandle = await client!.dispatcher!.createDatabaseAsync(status, encodedUri, dpb.length, dpb); return attachment; }); }