AnsweredAssumed Answered

Is there a way to dynamically set the file encoding when writing a file?

Question asked by samuel.leibowitz on Sep 29, 2015
Latest reply on Sep 29, 2015 by MWNiebuhr

We currently have a process which writes some dataset content out to the filesystem, then runs a script against it. Unfortunately, we sometimes need to change the code page for the file depending on server-specific settings (in other words, if the host is in, say, Sweden).


In the Write File operator, there is a File Encoding selector which enables you to set the character encoding for the file to be written.  However, it's stored in a system variable and is not accessible to be modified in code - so trying to set Process[OpName].fileencoding yields an error like this:


Failed to evaluate pre-execution.

Failed to execute code:

Process[OpName].fileencoding = "UTF-16"

-- Editing of system variable "fileencoding" not allowed. (#2)


Has anyone else here tried to create a process which can dynamically set the file encoding for  a new file? Is there maybe a different way to accomplish the same goal?