Custom Linear Terminations ASP Readline

I am using the ASP Classic function of a ReadLine()file system object.
Everything worked fine until someone made their import file on Mac in TextEdit.

Line endings do not match, but are ReadLine()read throughout the file, not just one line at a time.

Is there a standard way to handle this? Any page directive or setting in the file system object?

I suppose I could read the whole file and split by vbLF, then replace for each element with vbCR"", and then process the lines one at a time, but that seems a bit kludgy.

I searched for all the solutions for this problem, but all the solutions match the lines "do not save the file with the end of the line Mac [sic]".

Anyone have a better way to deal with this problem?

+3
source share
1 answer

There is no way to change the behavior ReadLine, it will recognize CRLF only as a line terminator. Therefore, the only simple solution is the one you have already described.

Edit

In fact, there is another library that should be available out of the box on the ASP server, which may offer some help. This is the ADODB library.

ADODB.Stream LineSeparator, 10 13 CRLF , . , , ReadText. ReadText , -2.

: -

Dim sLine
Dim oStreamIn : Set oStreamIn = CreateObject("ADODB.Stream")

oStreamIn.Type = 2 '' # Text
oStreamIn.Open 
oStreamIn.CharSet = "Windows-1252"
oStreamIn.LoadFromFile "C:\temp\test.txt"
oStreamIn.LineSeparator = 10 '' # Linefeed

Do Until oStreamIn.EOS
  sLine = oStreamIn.ReadText(-2)
  '' # Do stuff with sLine
Loop

oStreamIn.Close

, CharSet unicode, CharSet, , Unicode. "Unicode" , , UTF-16. , ADODB Stream UTF-8 Scripting.

, , MAC CR ? Unix, LF, ?

+4

Source: https://habr.com/ru/post/1724999/


All Articles