feat(import/single): support UTF-16 LE with BOM for text notes

This commit is contained in:
Elian Doran 2025-02-22 01:06:25 +02:00
parent cadd78524c
commit 77ee7f96c1
No known key found for this signature in database
3 changed files with 7 additions and 1 deletions

Binary file not shown.

View File

@ -66,4 +66,10 @@ describe("processNoteContent", () => {
expect(importedNote.mime).toBe("application/json");
expect(importedNote.getContent().toString()).toStrictEqual(stripBom(buffer.toString("utf-16le")));
});
it("supports plain text note with UTF-16", async () => {
const { importedNote } = await testImport("UTF-16LE Text Note.txt", "text/plain");
expect(importedNote.mime).toBe("text/html");
expect(importedNote.getContent().toString()).toBe("<p>Plain text goes here.<br></p>");
});
})

View File

@ -91,7 +91,7 @@ function importCodeNote(taskContext: TaskContext, file: File, parentNote: BNote)
function importPlainText(taskContext: TaskContext, file: File, parentNote: BNote) {
const title = getNoteTitle(file.originalname, !!taskContext.data?.replaceUnderscoresWithSpaces);
const plainTextContent = file.buffer.toString("utf-8");
const plainTextContent = processStringOrBuffer(file.buffer);
const htmlContent = convertTextToHtml(plainTextContent);
const { note } = noteService.createNewNote({