mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	feat(import/single): support UTF-16 LE with BOM for text notes
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								src/services/import/samples/UTF-16LE Text Note.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/services/import/samples/UTF-16LE Text Note.txt
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -66,4 +66,10 @@ describe("processNoteContent", () => { | |||||||
|         expect(importedNote.mime).toBe("application/json"); |         expect(importedNote.mime).toBe("application/json"); | ||||||
|         expect(importedNote.getContent().toString()).toStrictEqual(stripBom(buffer.toString("utf-16le"))); |         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>"); | ||||||
|  |     }); | ||||||
| }) | }) | ||||||
|   | |||||||
| @@ -91,7 +91,7 @@ function importCodeNote(taskContext: TaskContext, file: File, parentNote: BNote) | |||||||
|  |  | ||||||
| function importPlainText(taskContext: TaskContext, file: File, parentNote: BNote) { | function importPlainText(taskContext: TaskContext, file: File, parentNote: BNote) { | ||||||
|     const title = getNoteTitle(file.originalname, !!taskContext.data?.replaceUnderscoresWithSpaces); |     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 htmlContent = convertTextToHtml(plainTextContent); | ||||||
|  |  | ||||||
|     const { note } = noteService.createNewNote({ |     const { note } = noteService.createNewNote({ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user