I've encountered a problem with Unicode Windows file name.

If I set the file name to Unicode characters on Mac OSX, it works well. But on Windows if the filename starts with a digital number or the filename/path contains Unicode characters, it will not work well. (I am using Chinese Windows version, and Windows may be using GBK codings.)

If the filename starts with a digit, the \ will escape the following digit.

If the filename/path contains a Unicode character, Mathematica will not find the file in some situations.

This works:

enter image description here

This does not work (it tells me the file cannot be found):

enter image description here

Sorry the pictures are captured using Mac (it works), as on Windows system, the path separator will not be / but be \ . So it will cause the problem mentioned above.

Btw, I am using this to get the filename.

enter image description here


Sorry for late. I managed to find a Windows PC and got the file name as a string.

Here is the Unicode file name on Windows:



@Stitch I tried to replace the directory separator, but still cannot work:



enter image description here

  • $\begingroup$ are you using \\ or \ on windows? $\endgroup$ – vapor Mar 17 '17 at 15:49
  • $\begingroup$ Windows generated `\` as separator automatically. $\endgroup$ – cmal Mar 17 '17 at 15:50
  • 1
    $\begingroup$ So have you tried escaping the backslash? In other words, you'll use "\\" as the path separator in Mathematica. $\endgroup$ – Pirx Mar 17 '17 at 15:56
  • $\begingroup$ is your problem :FileNameSetter does not generate double slash for filenames, and that caused file not found problems in some cases? $\endgroup$ – vapor Mar 17 '17 at 15:59
  • 2
    $\begingroup$ You should be able to use / on Windows as well. $\endgroup$ – Stitch Mar 17 '17 at 16:29

I've found the encoding of file names on Windows systems is "CP936".

To Replace \ to / does not work maybe because of the encoding of / is "UTF8", so I use the following expression to split filename to table of strings and then join them back again and intercept them with $PathnameSeparator.

StringJoin[Riffle[FileNameSplit[Excel文件名], $PathnameSeparator]]

And It works!

| improve this answer | |
  • 1
    $\begingroup$ Will FileNameJoin @ FileNameSplit[Excel文件名] do the same? $\endgroup$ – Kuba Mar 20 '17 at 9:36
  • $\begingroup$ I've tried that. No. $\endgroup$ – cmal Mar 21 '17 at 8:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.