ANSI encoding text file - new line

peterchan75

Supremacy Member
Joined
Apr 26, 2003
Messages
6,754
Reaction score
533
Hi All,

I use Excel macro to output 8 records to an ANSI encoding text file. Each record is 1000 characters long. The ANSI encoded file was created using CreateTextFile(filename, True, False) and output using WriteLine. When I use Notepad++ to view the text file, it indicated that it's ANSI encoding but the total file length was 8016 instead of 8000.

This text file is for Giro transaction upload and the system is not accepting it. The error message is... either not ANSI encoded or encrypted/hash or illegal file format.

Any chance that the new line characters are causing this issue ?
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,550
Reaction score
1,302
Hi All,

I use Excel macro to output 8 records to an ANSI encoding text file. Each record is 1000 characters long. The ANSI encoded file was created using CreateTextFile(filename, True, False) and output using WriteLine. When I use Notepad++ to view the text file, it indicated that it's ANSI encoding but the total file length was 8016 instead of 8000.

This text file is for Giro transaction upload and the system is not accepting it. The error message is... either not ANSI encoded or encrypted/hash or illegal file format.

Any chance that the new line characters are causing this issue ?

Microsoft line separator is actually 2 characters “\r\n”. They are carriage returns follow by a newline character.

That is why you 8 records is 8 * 2 = 16 extra characters

I don’t know about the GIRO transaction but it could be using the unix line separation, which is just a single newline(‘\n’) character.

Based on https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/writeline-method,
you will want to specify the argument as just a single “\n” so that it will use this as line separation in this case.

Try it :)
 

peterchan75

Supremacy Member
Joined
Apr 26, 2003
Messages
6,754
Reaction score
533
Microsoft line separator is actually 2 characters “\r\n”. They are carriage returns follow by a newline character.

That is why you 8 records is 8 * 2 = 16 extra characters

I don’t know about the GIRO transaction but it could be using the unix line separation, which is just a single newline(‘\n’) character.

Based on https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/writeline-method,
you will want to specify the argument as just a single “\n” so that it will use this as line separation in this case.

Try it :)

David, Thank you very much.
Since there isn't any newline character that do not take up space, it's best for the user to get help from bank technical support.
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,550
Reaction score
1,302
David, Thank you very much.
Since there isn't any newline character that do not take up space, it's best for the user to get help from bank technical support.

Of course if you want to ask from the bank, feel free to do so. All control characters take up space, space here is not display asset. I don’t understand what is the concern :)
 

peterchan75

Supremacy Member
Joined
Apr 26, 2003
Messages
6,754
Reaction score
533
Of course if you want to ask from the bank, feel free to do so. All control characters take up space, space here is not display asset. I don’t understand what is the concern :)

In this case, the bank would know what cause the upload to fail. I am guessing that the newline is causing the record to exceed 1000 characters is main reason for the upload to fail. No point guessing.
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,550
Reaction score
1,302
In this case, the bank would know what cause the upload to fail. I am guessing that the newline is causing the record to exceed 1000 characters is main reason for the upload to fail. No point guessing.

Didn’t the bank provide you with a sample of how the upload file should be? If each record must be strictly 1000 characters, then you don’t even need line separators. Just print 1000 characters records, one after the other. :)
 

peterchan75

Supremacy Member
Joined
Apr 26, 2003
Messages
6,754
Reaction score
533
Didn’t the bank provide you with a sample of how the upload file should be? If each record must be strictly 1000 characters, then you don’t even need line separators. Just print 1000 characters records, one after the other. :)

We follow the bank document right to the dot. It specifies that each upload must have a header record and follow by at least one detail record. Based on the document, both header and detail records are 1000 characters long. You bring up a good point. It never indicate that each record must be in a separate line. Why need separator? I let the user ask the IT support. Just don't want to the blind men touching an elephant situation.
 
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ Forums. Forum members and moderators are responsible for their own posts. Please refer to our Community Guidelines and Standards and Terms and Conditions for more information.
Top