orbs Posted March 29, 2019 Posted March 29, 2019 what's it called when you have \n instead of @CRLF in a string? how to convert that? i know i can use StringReplace(), but i need to check the backslash itself is not escaped, and to handle other such indicators like \r , and maybe others i don't know about. so i'm asking what is the formal name of that string format, so i can understand it and search for some native function for conversion (which i'm certain exists somewhere). Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
FrancescoDiMuro Posted March 29, 2019 Posted March 29, 2019 (edited) @orbs The character \n is called new line. Do you need to check that \n is not escaped, so there must be not a sequence of characters like this: \\n ? Edited March 29, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
orbs Posted March 29, 2019 Author Posted March 29, 2019 i know it's a new line (EOL). i want to be able to convert it safely to @CRLF, and to convert \r and others to their respective special characters, which i don't know, so i'm asking what is the formal name of this "format" or "standard" of special characters representation in a string. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
alienclone Posted March 29, 2019 Posted March 29, 2019 not sure what you mean by formal, unless you are talking about the ASCII characters, which CR (Carriage Return) would be Chr(13) and LF (Line Feed) would be Chr(10) If @error Then MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!") EndIf "Yeah yeah yeah patience, how long will that take?" -Ed Gruberman REAL search results | SciTE4AutoIt3 Editor Full Version
alienclone Posted March 29, 2019 Posted March 29, 2019 or do you mean what are the @ prefixed characters called? that would be Macros https://www.autoitscript.com/autoit3/docs/macros.htm If @error Then MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!") EndIf "Yeah yeah yeah patience, how long will that take?" -Ed Gruberman REAL search results | SciTE4AutoIt3 Editor Full Version
FrancescoDiMuro Posted March 29, 2019 Posted March 29, 2019 @orbs Thanks for the clarification. So, \n is a representation of a "new line"... It's just a character, which has various representations in some formats (character : \n, Unicode : U+000A, ASCII : 10, hex : 0x0a). By the way, \n and \r are two different chracters, and so, they are threated in a different manner. For example, the character \n, traduced in .au3 would be just @LF, while \r would be @CR; so, @CRLF is a sequence of \r\n. If you want to traduce the \n with his corresponding character in .au3, then you need to use just @LF, and so on Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
orbs Posted March 29, 2019 Author Posted March 29, 2019 (edited) ok. so i need to read the text char by char, and if i find unescaped substring "\n" then i StringReplace() it with @LF, and "\r" with @CR. there is probably a regexp to do that, but i'm no regex expert. that is all good and well, but: 1) i wonder if there are other special characters, @TAB for example, that has such a representation (of a backslash followed by a normal character), and handle them as well - is there any formal specification for that? 2) i'm probably not the first to encounter such a task, there is probably already a function doing just that - how do i search for it? what do i type in google? P.S. the text is generated by a python script, which i can modify. i guess python prefers using \n and \r, but it may be possible to tell python to use chr(10) and chr(13) instead. i'll look into that. Edited March 29, 2019 by orbs Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
FrancescoDiMuro Posted March 29, 2019 Posted March 29, 2019 @orbs Could you please post a sample text? It's difficult to guess... Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
orbs Posted March 29, 2019 Author Posted March 29, 2019 no problem. a very simple example: \n\nline with two blank lines before, and two blank lines after\n\n i'll get you a more decent example shortly :-) Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
orbs Posted March 29, 2019 Author Posted March 29, 2019 UPDATE: i think the way i'm going to tackle this is on the python side, i'm going to process the text for AutoIt-compliant format before output. preliminary test suggest it is easier. trying it now... Earthshine 1 Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
orbs Posted March 29, 2019 Author Posted March 29, 2019 yup, got in on the python side. now for the AutoIt post-processor, see how it goes. thanks for all the help so far, i will update here if any issues arise. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
user4157124 Posted March 29, 2019 Posted March 29, 2019 Possibly just: ConsoleWrite(StringFormat('\r\n@CRLF before this\t@TAB before this\n')) Called escape sequence. orbs 1 AUERLO (AutoIt error logger)
orbs Posted March 29, 2019 Author Posted March 29, 2019 indeed. thank you @user4157124. although i currently no longer need the solution, it's good to know it's there. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now