Skip to main content
Inspiring
June 25, 2024
Question

cffile read and special characters

  • June 25, 2024
  • 1 reply
  • 294 views

I moved code from ColdFusion2016 (Linux) to ColdFusion2023 (Windows). The database and network share behind the website are identical. 

 

I am using cffile read to read a file in a network share.  The website on the CF16 server can read the file and displays as expected.  The website (same code) on the CF23 server is unable to read the file and throws and error. 

 

This is the value in our database that sits behind both CF16 & CF23 code 'PLN_29886_ Istanbul SIOT DAY 1 - 1to1 Turkish Thank You — Triggered Email.htm'

On the network drive the filename is displayed as 'PLN_29886_ Istanbul SIOT DAY 1 - 1to1 Turkish Thank You — Triggered Email.htm'

 

I do not have any control over the filenames that are placed into the network share.

 

I can see that the em-dash is translated into — in the file. I'm at a loss as to why cffile on CF16 reads the file but cffile on CF23 an error is thrown. I would expect the same result either they both read the file or they both throw and error.  I assume that there was some change to CF or cffile that will cause this behavior but I cannot seem to find out what. I looked at the documentation and didn't find a clue. I also looked at the CF Administrator trying to see there is anything in there that need to be added/changed/checked.

 

ERROR MESSAGE
An error occurred when performing a file operation read on file //hoover/sim_client/invite_uploads/PLN_29886_ Istanbul SIOT DAY 1 - 1to1 Turkish Thank You — Triggered Email.htm.
The cause of this exception was: java.io.FileNotFoundException: //hoover/sim_client/invite_uploads/PLN_29886_ Istanbul SIOT DAY 1 - 1to1 Turkish Thank You — Triggered Email.htm (The system cannot find the file specified).

The error occurred in //nagennas02/ColdFusion2023/mdocfprod/invites-app/invites/showinvite.cfm: line 42
40 :
41 : <cffile action = "read"
42 : file = "\\hoover\sim_client\invite_uploads\#getInviteData.ServerAttFile1#"
43 : variable = "inviteFile" >
44 : <p>

 

Has anyone else had an issue like this?

TIA,

Jennifer

    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    June 26, 2024

     I don't see any â€” character in ColdFusion's error message. I am therefore confused as to why you think it is a CF2016 versus CF2023 question. After all, you say, "On the network drive the filename is displayed as 'PLN_29886_ Istanbul SIOT DAY 1 - 1to1 Turkish Thank You — Triggered Email.htm' ". If my address in the US contains the characters मेरा पता then I won't blame the postman for being unable to deliver my letters.

     

    Or perhaps there's something I'm missing from your explanation. What do you mean by "On the network drive the filename is displayed as"?

    BKBK
    Community Expert
    Community Expert
    June 26, 2024

    In the meantime, some things you could try:

    1.  Verify the origin of the data in getInviteData.ServerAttFile1. Was UTF-8 encoding used when getting the data? Output it. Is the value what you expect?
    2.  Add the attribute charset="utf-8" to cffile and see it it helps.  
    3.  An experiment that might be useful:
      <cfset path='PLN_29886_ Istanbul SIOT DAY 1 - 1to1 Turkish Thank You — Triggered Email.htm'>
      <cfset convertedPath=ReplaceNoCase(path, '—', chr(8212))>
      <cfoutput>#convertedPath#</cfoutput>​