myspacee 0 Report post Posted March 20, 2009 hello to all, I need to open a [ANSI UNIX] text file and save in [ANSI PC] format, is possible with Autoit without use external tool ? thank you, m. Share this post Link to post Share on other sites
Richard Robertson 186 Report post Posted March 20, 2009 What do you mean by UNIX and PC? Are you referring to the line endings? That's easy. Just read each character and if you find a line feed, add a carriage return. Share this post Link to post Share on other sites
GEOSoft 64 Report post Posted March 20, 2009 (edited) hello to all, I need to open a [ANSI UNIX] text file and save in [ANSI PC] format, is possible with Autoit without use external tool ? thank you, m. If it's just the line feed difference then you could use a simple StringReplace. $sStr = FileRead("C:\some\text\file.txt") $sStr = StringReplace($sStr, @LF, @CRLF) EDIT: Actually, better yet $sStr = StringStripCR(FileRead("C:\some\text\file.txt")) $sStr = StringReplace($sStr, @LF, @CRLF) Edited March 20, 2009 by GEOSoft GeorgeQuestion about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else."Old age and treachery will always overcome youth and skill!" Share this post Link to post Share on other sites
GEOSoft 64 Report post Posted March 20, 2009 Now you have me thinking. I'm thinking that what I gave you is actually Mac to Windows. If that doesn't work then try this one. $sStr = FileRead("C:\some\text\file.txt") $sStr = StringReplace($sStr, @LF, "") $sStr = StringReplace($sStr, @CR, @CRLF) All of these are untested by the way GeorgeQuestion about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else."Old age and treachery will always overcome youth and skill!" Share this post Link to post Share on other sites
ProgAndy 66 Report post Posted March 20, 2009 (edited) the linefeeds: ( http://en.wikipedia.org/wiki/Newline )* LF: Multics, Unix and Unix-like systems (GNU/Linux, AIX, Xenix, Mac OS X, FreeBSD, etc.), BeOS, Amiga, RISC OS, and others * CR+LF: DEC RT-11 and most other early non-Unix, non-IBM OSes, CP/M, MP/M, DOS, OS/2, Microsoft Windows, Symbian OS * CR: Commodore machines, Apple II family, Mac OS up to version 9 and OS-9So this should convert all:Enum $NL_MAC, $NL_WIN, $NL_NIX Func _NewlineConv($text, $type=$NL_WIN) ; Prog@ndy Switch $type Case $NL_WIN If StringInStr($text,@LF) Then Return StringReplace(StringStripCR($text),@LF,@CRLF) Else Return StringReplace($text,@CR,@CRLF) EndIf Case $NL_MAC If StringInStr($text,@LF) Then Return StringReplace(StringStripCR($text),@LF,@CR) Else Return $text EndIf Case $NL_NIX If StringInStr($text,@LF) Then Return StringStripCR($text) Else Return StringReplace($text,@CR,@LF) EndIf Case Else Return SetError(1,0,$text) EndSwitch EndFunc Edited March 20, 2009 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Share this post Link to post Share on other sites
myspacee 0 Report post Posted March 20, 2009 this resolve: $sStr = FileRead("C:\some\text\file.txt") $sStr = StringReplace($sStr, @LF, "") $sStr = StringReplace($sStr, @CR, @CRLF) thank you all, m. Share this post Link to post Share on other sites