Set file encoding in TextIO

Hello all

I wrote a batch class to automatically create a text file based on certain data. It’s creating the text file just fine, but it’s encoding it as utf-16. I need it encoded as us-ascii. How can I change the encoding? I would assume it would be in my InitTextIO or WritetoCSV method, but I’m a little too new to X++ to figure it out myself.

Thanks!

You can define codepage in TextIo’s constructor. Find details in documentation: http://msdn.microsoft.com/en-us/library/aa881745.aspx.

For UTF-16LE you can set this in the ctor like new TextIo(@“C:\test.txt”, “W”, 1200**);**

Here is the reference:

http://msdn.microsoft.com/en-us/library/aa881745.aspx

Are you able to run your batch job as a batch process? If so, how? I am having issues where my TextIO object is always null, even if I initialize it correctly. However, when I run it as an interactive batch job, it works fine.