I'm programming a webmail interface for educational purposes, and it has problems with attachments.
When testing with DevTools:
console.log( file )
file.length
new File( [ file ], "download.pdf" );
produces the following results:
> console.log( file )
< ...
< ...
< Ò:ašSéàƒ‰òâ#ZMÖ…S©øz‡cß¾}uµ4ƒX™:´ìø,^j<¤Ö#AŒŽtaù£´tc¬¾t"
< Show more (26.7 kB) Copy
> file.length
< 18899
> new File( [ file ], "download.pdf", )
< File {name: "test.pdf", lastModified: 1596733568533, lastModifiedDate: Thu Aug 06 2020 13:06:08 GMT-0400 (hora de Venezuela)
, webkitRelativePath: "", size: 26739, …}
when I download the file "download.pdf" and verify these results on the server it matches the files (original and downloaded)
$ ls -go *pdf
-rw-rw-r-- 1 26739 ago 6 09:58 download.pdf
-rw-rw-r-- 1 18899 ago 3 20:41 file.pdf
$ file *pdf
download.pdf: PDF document, version 1.5
file.pdf: PDF document, version 1.5
$ iconv -f iso8859-1 -t utf-8 <file.pdf>utf8.pdf
$ ls -go *pdf
-rw-rw-r-- 1 26739 ago 6 09:58 download.pdf
-rw-rw-r-- 1 18899 ago 3 20:41 file.pdf
-rw-rw-r-- 1 26739 ago 6 14:18 utf8.pdf
$ cmp download.pdf utf8.pdf
$
When I compare the "download.pdf" files with "utf8.pdf" both files are the same!, which means the File() command encodes "file" string from iso8859-1 to utf-8
How can I prevent this from happening?