Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous message
navi is currently offline  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.

index.php?t=getfile&id=3929&private=0



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

 
Read Message icon5.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Frameless(true); bug, my error or ???
Next Topic: EditDoubleSpin
Goto Forum:
  


Current Time: Wed May 08 21:29:22 CEST 2024

Total time taken to generate the page: 0.01874 seconds