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 » Retriving data in record containing ""
Re: Retriving data in record containing "" [message #33679 is a reply to message #33674] Mon, 05 September 2011 14:03 Go to previous message
mirek is currently offline  mirek
Messages: 14267
Registered: November 2005
Ultimate Member
Currently I am using this to parse csv:

Vector<String> ReadCsvLine(Stream& s, int separator, byte charset)
{
	Vector<String> r;
	bool instring = false;
	String val;
	for(;;) {
		int c = s.Get();
		if(c == '\n' || c < 0) {
			r.Add(ToCharset(CHARSET_UTF8, val, charset));
			return r;
		}
		else
		if(c == separator && !instring) {
			r.Add(ToCharset(CHARSET_UTF8, val, charset));
			val.Clear();
		}
		else
		if(c == '\"') {
			if(instring && s.Term() == '\"') {
				s.Get();
				val.Cat('\"');
			}
			else
				instring = !instring;
		}
		else
		if(c != '\r')
			val.Cat(c);
	}
}
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Need help about the codepage!
Next Topic: isnan [BUG?] fix for Core OSX11
Goto Forum:
  


Current Time: Tue Aug 26 07:36:02 CEST 2025

Total time taken to generate the page: 0.05480 seconds