tracker issue : CF-4204028

select a category, or use search below
(searches all categories and all time range)
Title:

[ANeff] Bug for: FileWrite() cannot change FileObject's charset

| View in Tracker

Status/Resolution/Reason: To Track//PRNeedInfo

Reporter/Name(from Bugbase): Aaron N. / ()

Created: 02/17/2019

Components: File Management

Versions: 13.0

Failure Type: Non Functioning

Found In Build/Fixed In Build: 2018.0.0.310739 /

Priority/Frequency: Normal / Some users will encounter

Locale/System: / Windows 10 64 bit

Vote Count: 0

Issue: FileWrite() cannot change FileObject's charset

This works:
----
{code:java}
<cfprocessingdirective pageencoding="utf8"><!--- B/c CF-3712167 --->
<cfscript>
  //cfprocessingdirective(pageencoding="utf8");//b/c auto-detection of page encoding randomly fails
  fileWrite(expandPath("./myfile1.txt"), "a", "us-ascii");
  fileWrite(expandPath("./myfile1.txt"), "€", "utf-8");//myfile1.txt becomes UTF8 (good)
</cfscript>
{code}

----

This fails:
----
{code:java}
<cfprocessingdirective pageencoding="utf8"><!--- B/c CF-3712167 --->
<cfscript>
  //cfprocessingdirective(pageencoding="utf8");//b/c auto-detection of page encoding randomly fails
  fileWrite(expandPath("./myfile2.txt"), "a", "us-ascii");
  myFileObject = fileOpen(expandPath("./myfile2.txt"), "write", "us-ascii");
  fileWrite(myFileObject, "€", "utf-8");//throws "Complex object types cannot be converted to simple values."
  fileClose(myFileObject);
</cfscript>
{code}

----

Suggestion: Allow `charset` parameter, when FileWrite() writes to myFileObject.

Attachments:

Comments:

Hi Aaron, Can you please try below code and let us know : {code:java} <cfprocessingdirective pageencoding="utf8"> <cfscript> fileWrite(expandPath("./myfile2.txt"), "a", "us-ascii"); myFileObject = fileOpen(expandPath("./myfile2.txt"), "write", "us-ascii"); fileWrite(myFileObject.path, "€", "utf-8"); fileClose(myFileObject); </cfscript>{code}   Thanks, Mukesh
Comment by Mukesh K.
30473 | March 12, 2019 11:55:05 AM GMT