Hi All,
My question is very simple, is it possible to read Unicode text file and normal text file using a one method (CAL Code)?
Version : 2013
Further details:
I read a normal text file in a report, using following method. It works fine.
code
Variables;
name = TextFile data type = File
name = TextLine data type = Text
TextFile.OPEN(TextFileName);
TextFile.READ(TextLine);
code
Then I read a Unicode text file in a report, using following method (because of a client requirement). It works fine.
code
Variables;
name = ReadStream data type = InStream
name = StreamReader data type = DotNet
name = Encoding data type = DotNet
TextFile.CREATEINSTREAM(ReadStream);
StreamReader := StreamReader.StreamReader(ReadStream, Encoding.Unicode);
TextLine := StreamReader.ReadLine;
code
But, a normal text file cannot be read using the method I used for Unicode method.
I need to know, is there a method, which can use to read both normal & Unicode text files.
Thank you.
0
Comments
You can just use the DotNet interop and the standard Stream functionality, where you can set any encoding you want...
In your code use it as, select ASCII from the encoding properties.
StreamReader := StreamReader.StreamReader(ReadStream, Encoding.ASCII);
It works fine for me. Either you use ASCII or UNICODE encode text files.
Thank you.
ERP Consultant - MS Dynamics NAV
https://lk.linkedin.com/pub/lakshan-vindana-kulawansa/37/2a2/592