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 » U++ Library support » U++ Core » Problem using Split on carriage return
Problem using Split on carriage return [message #10467] Tue, 10 July 2007 23:10 Go to previous message
$mike{is_here} is currently offline  $mike{is_here}
Messages: 12
Registered: July 2007
Promising Member
Hi,

I want to split a String s loaded from a text file at the carriage return, like this:

Vector<String>	getLines(String s) {	// new line at \n
	Vector<String> vs;
	vs = Split(s.Begin(), '\n', true); // split by lines
	return vs;	
}


From Perl I'm used to do something like:

@list = split /\n/, $many_lines_of_text;


which finds all '\n' in the string $many_lines_of_text and puts it into a list.

It looks like U++ treats the carriage return as two separate characters, i.e. '\r\n'. When I split in U++ at '\n' or when I split at '\r' the other character is left over, leading to trouble.

What I would have to do is:

	vs = Split(s.Begin(), '\r\n', true); // split by lines


which obviously leads to trouble.


What's the correct way to do it in U++ ?


Thanks and kind regards,
Micha



 
Read Message
Read Message
Read Message
Previous Topic: Gate() or flow control problem
Next Topic: How to do interation on Vector<String>
Goto Forum:
  


Current Time: Thu May 09 21:52:46 CEST 2024

Total time taken to generate the page: 0.02371 seconds