How to split a string at a newline?

The string I am trying to split looks like this:
“Architecture

Instrument Playing

Listening Habits”

I tried:

  
    vector<string> skws = ofSplitString(kws, "&#13;&#13;");  
  
and  
  
            vector<string> skws = ofSplitString(kws, "\n\n");  
  

Neither works, I just get an array with one element with the same string in the first position.

Thanks,
Jack

Hi Jack,

This works for me in v0072 and 0.7.4 versions:

  
  
	string kws = "Architecture&#13;&#13;Instrument Playing&#13;&#13;Listening Habits";  
	cout << kws << endl;  
	vector<string> skws = ofSplitString(kws, "&#13;&#13;");  
	for (int i = 0; i < skws.size(); i++){  
		cout << skws[i] << endl;  
	}  
  

The output is:

  
  
Architecture&#13;&#13;Instrument Playing&#13;&#13;Listening Habits  
Architecture  
Instrument Playing  
Listening Habits  
  

Is this what you want to do?

Cheers,

punkto

I tried this, does not work for me actually. Let me elaborate, the string that I am getting is actually coming from an XML file. I am parsing the XML file using ofxXmlSettings. When I print out the string before attempting to split it comes out like this:

  
Architecture  
  
Instrument Playing  
  
Listening Habits  

With double line breaks as you can see. But when I view the XML file directly the string looks like this:
“Architecture&#13;&#13;Instrument Playing&#13;&#13;Listening Habits”

As I have said. Perhaps this has to do with the encoding of the XML file, or with how the ofxXmlSettings class deencodes it? Either way, splitting it on the “&#13;&#13;” does not work for me.

Thanks,
Jack

have you played with the last two options to ofSplitString?

ignoreEmpty=false, bool trim=false

http://www.openframeworks.cc/documentation/utils/ofUtils.html#ofSplitString

I have not, but thanks for the suggestion.

I was able to export the data with a different delimiter, so this is no longer a problem for me. Thanks.