Can't use em dash in ghostscript command on Debian

51 views Asked by At

I have been searching for quite a bit, and can't seem to find a solution.

I have a ghostscript command in a PHP (7.4) Drupal specific script (not written by me), which seems to work fine. The command is specifically what is below:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -sPAPERSIZE=a4 -dFIXEDMEDIA -dPDFFitPage -dNOPAUSE -dQUIET -dBATCH -sOutputFile=converted.pdf 'path/to/filename/with and em–dash.pdf'

This command works fine for me on other special characters, such as æ, ø, å, but as soon as an em dash is added, it fails:

GPL Ghostscript 9.23: Unrecoverable error, exit code 1
head: cannot open '' for reading: No such file or directory

I have tried encasing the file path with double and single quotes, which does not seem to work. The file path is dynamically added.

I am pretty certain this is a command line issue over a PHP issue, but please do correct me if I am wrong, and I will share what I can from the script. I would very much like to avoid changing the file name, as I am certain the client will upload another file with an em dash in its name.

Couple of notes:

  • I am aware PHP 7.4 is EOL and should be changed to at least 8.1 (at the time of writing)
  • This is on a Debian 9 which is also EOL and should be upgraded to at least Debian 10 (at the time of writing)
  • This is in connection with a Drupal 7 installation which is nearing EOL, and should also be updated to at least 9 (at the time of writing)
  • Even with the information about the impending doom of outdated software, I cannot do anything about it, as I am not in charge of this stuff. So suggestions to update might be the right path to go, I unfortunately am unable to, not due to lack of skill, but to lack of "other stuff" further above in the ladder.
  • The locale is en_DK.UTF-8
  • GhostScript is on version 9.23
0

There are 0 answers