Home » Community » Newbie corner » [SOLVED] WIN32 API "MoveFile" and LineEdit Ctrl issue
Re: WIN32 API "MoveFile" and LineEdit Ctrl issue [message #37873 is a reply to message #37872] |
Mon, 19 November 2012 13:50 |
navi
Messages: 107 Registered: February 2012 Location: Sydney, Australia
|
Experienced Member |
|
|
Hello Deep and Koldo,
First of all let me congratulate and thank you guys for great detective investigation. Deep, great technique for investigating strings. I also solve it by myself but was a bit late to reply. But I found the solution and the cause of the problem by chance. Since, unlike Deep I could not figure how to look inside the string, I assume the string has something invisible and started to write my very own splitter. char by char. While doing that I stumble upon the issue that it's not that easy to split where '\n' is the delimiter. Upon searching the forum I stumble upon the following post by "great" Mirek: which essentially explains the problem and provides a elegant solution. Applying his Filter() solution I got it working immediately.
http://www.ultimatepp.org/forum/index.php?t=msg&goto=104 91&
mirek wrote on Tue, 10 July 2007 23:26 | Well, it is not U++, it is M$... Back in MSDOS days, they have decided that line are to be ended with "\r\n" and this stupid idea is still alive.
Standard C library solves this problem by intruducing "text" and "binary" streams (text streams remove/insert \r on read/write), but IMO that just adds to confusion.
U++ general take on the problem is to ignore all \r characters on input and insert \r before each \n on output - but both is to be handled by the code.
In your case you have many options. One simple is to filter out all \r out before Split:
int NoCr(int c) { return c == '\r' ? 0 : c; }
Split(Filter(s, NoCr), '\n')
As you seem to ignore empty lines, another simple solution (with a bit better performance) is to treat \r like \n (because it will just result in empty line, which is ignored anyway):
int CrOrLf(int c) { return c == '\r' || c == '\n' ? c : 0; }
Split(s, CrOrLf);
Mirek
|
Screen Shot of the Program applying Mirek's Filter() Solution.
Thank you very much for your help guys. I really appreciate it.
Navi
-
Attachment: pic3.png
(Size: 71.21KB, Downloaded 821 times)
[Updated on: Mon, 19 November 2012 14:26] Report message to a moderator
|
|
|
|
|
[SOLVED] WIN32 API "MoveFile" and LineEdit Ctrl issue
By: navi on Mon, 19 November 2012 06:32
|
|
|
Re: WIN32 API "MoveFile" and LineEdit Ctrl issue
By: navi on Mon, 19 November 2012 06:34
|
|
|
Re: WIN32 API "MoveFile" and LineEdit Ctrl issue
By: navi on Mon, 19 November 2012 06:36
|
|
|
Re: WIN32 API "MoveFile" and LineEdit Ctrl issue
By: unknown user on Mon, 19 November 2012 08:23
|
|
|
Re: WIN32 API "MoveFile" and LineEdit Ctrl issue
By: navi on Mon, 19 November 2012 08:44
|
|
|
Re: WIN32 API "MoveFile" and LineEdit Ctrl issue
By: koldo on Mon, 19 November 2012 08:59
|
|
|
Re: WIN32 API "MoveFile" and LineEdit Ctrl issue
By: navi on Mon, 19 November 2012 09:54
|
|
|
Re: WIN32 API "MoveFile" and LineEdit Ctrl issue
By: koldo on Mon, 19 November 2012 10:17
|
|
|
Re: WIN32 API "MoveFile" and LineEdit Ctrl issue
By: deep on Mon, 19 November 2012 11:44
|
|
|
Re: WIN32 API "MoveFile" and LineEdit Ctrl issue
By: koldo on Mon, 19 November 2012 12:44
|
|
|
Re: WIN32 API "MoveFile" and LineEdit Ctrl issue
By: deep on Mon, 19 November 2012 13:12
|
|
|
Re: WIN32 API "MoveFile" and LineEdit Ctrl issue
By: koldo on Mon, 19 November 2012 13:25
|
|
|
Re: WIN32 API "MoveFile" and LineEdit Ctrl issue
By: navi on Mon, 19 November 2012 13:50
|
Goto Forum:
Current Time: Wed May 08 21:29:22 CEST 2024
Total time taken to generate the page: 0.01874 seconds
|