Bug fixed in 12.2.0
Tested with versions 9.0.0
, 10.0.2
and 10.3.0
, all under OS X 10.10.5. and Linux
The drag-and-drop front-end functionality also results in $Failed
.
Surprisingly, Import
ing, JPEGs, TXTs, and XLSX work just fine!
(* Initialization *)
SetDirectory[NotebookDirectory[]];
text = "Uh oh, this could be a bug";
fileNameTemplate = StringTemplate["s`1`mple file.`2`"];
extensions = { "pdf", "txt", "jpeg", "xlsx"};
$CharacterEncoding
"UTF-8"
(* The list of "a"s used in the test *)
Table[FromCharacterCode@a, {a, 1, 1000}];
as = Select[%, RemoveDiacritics@# == "a" &]
{"a", "à", "á", "â", "ã", "ä", "å", "ā", "ă", "ą", "ǎ", "ǟ", "ǡ", "ǻ", "ȁ", "ȃ", "ȧ", "ɐ", "ɑ", "ɒ"}
(* Exporting files, no failures so far *)
Map[# -> Export[fileNameTemplate @@ #, text] &, Outer[List, as, extensions], {2}]
{a,pdf}->sample file.pdf,
{a,txt}->sample file.txt,
{a,jpeg}->sample file.jpeg,
{a,xlsx}->sample file.xlsx
[...]
{ɒ,pdf}->sɒmple file.pdf,
[...]
{ɒ,xlsx}->sɒmple file.xlsx
(* Re-importing files *)
res = Map[# -> Import@# &, GatherBy[FileNames["*file*"], FileBaseName], {2}];
Drop[res, -1];
%[[-4 ;; -3, 1 ;; 4]] // Flatten // Column
sample file.jpeg->
#image here#
sample file.pdf->{#image here#
}
sample file.txt->Uh oh, this could be a bug
sample file.xlsx->{{{Uh oh, this could be a bug}}}
sɐmple file.jpeg->#image here#
sɐmple file.pdf->$Failed
sɐmple file.txt->Uh oh, this could be a bug
sɐmple file.xlsx->{{{Uh oh, this could be a bug}}}
Only PDF
s fail.
I've tried a bunch of different $CharacterEncodings, but the only solution so far was to rename the file, work with it, then rename it back, as in this (very rudimentary) example
withFunnyName[filePath_, fun_] :=
Module[{origName = filePath, tempName, res},
tempName = CreateTemporary[];
DeleteFile[tempName];
RenameFile[origName, tempName];
res = fun@tempName;
RenameFile[tempName, origName];
res
]
What could I be doing wrong? Some system configurations?
Import[Export["test_ǡ.png", "Hello"]]
works whileImport[Export["test_ǡ.pdf", "Hello"]]
returns$Failed
$\endgroup$