IT Process Automation

 View Only
Expand all | Collapse all

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

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

    Posted Sep 29, 2015 10:55 AM

    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?

     

    Thanks,

    Sam



  • 2.  Re: Is there a way to dynamically set the file encoding when writing a file?
    Best Answer

    Broadcom Employee
    Posted Sep 29, 2015 12:59 PM

    fileencoding is likely a system variable that is not adjustable by the end user.

    Have you considered Powershell?  That may allow you to option to modify the file encoding as that would occur outside the limits of the file operators.