AutoHotkey Community

It is currently May 27th, 2012, 1:01 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: November 19th, 2011, 10:56 pm 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
That's really interesting... I ran this code bellow. Then I made two files, one in Linux's nano editor, and the other in Notepad. I use FileRead to load them into variables and then called RegExMatch on them. One gave me "abc", and the other gave "abc <<new line>> def".
Code:
RegExMatch("abc`ndef", ".*", M)
MsgBox %M%
RegExMatch("abc`r`ndef", ".*", M)
MsgBox %M%


When you open those files in a (non-notepad) editor it looks the same. Both files will appear like this.

Quote:
abc
def


Wouldn't it make more sense to normalise input from files and the like? In python everything is loaded as one kind of line endings, but if you want the original you can read the file as binary. Or ANYCRLF could be the default for RegExMatch/Replace, but that's not as good as changing it at the source.

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 20th, 2011, 1:10 am 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
Isn't (*ANYCRLF) default in v2 already?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 20th, 2011, 1:26 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Frankie wrote:
Wouldn't it make more sense to normalise input from files and the like?
FileRead wrote:
*t: Replaces any/all occurrences of carriage return & linefeed (`r`n) with linefeed (`n). However, this translation reduces performance and is usually not necessary. ...
FileOpen wrote:
End of line (EOL) options
`n - 4 - Replace `r`n with `n when reading and `n with `r`n when writing.
`r - 8 - Replace standalone `r with `n when reading.
Loop (read file contents) wrote:
Windows and Unix formats are supported; that is, the file's lines may end in either carriage return and linefeed (`r`n) or just linefeed (`n).

nimda wrote:
Isn't (*ANYCRLF) default in v2 already?
Yes, since alpha 22. It had been omitted from the changelog in the v2 thread, though. I've corrected that.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 20th, 2011, 2:50 am 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
Thanks, that's 4 (or more) things I learned from this thread.

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group