I’m running into what is probably a simple/silly problem, but after spending some time on various forums, it’s time to throw my hands in the air and ask for help.
I’m using ofxCsv in order to work with a CSV file in openFrameworks. The addon stores the CSV in a nested string vector like this vector<vector<string> > data
. That seems easy enough. But when I pull that data, even though it is a string, it is being encoded / rendered differently than if I were to save the same text into a string testString
. Here is what I mean.
When I do this:
string stringTest = "one\ntwo\nthree";
cout << "myString is " << stringTest << endl;
string stringFromCsvDataVector = csv.data[1][9];
cout << "stringFromCsvDataVector is " << stringFromCsvDataVector << endl;
This is what prints to the console:
stringTest is one
two
three
stringFromCsvDataVector is one\ntwo\nthree
When I add breakpoints to the lines containing cout above and debug in Xcode, here are the descriptions of the two vars that are returning:
Printing description of stringFromCsvDataVector:
(std::string) stringFromCsvDataVector = “U\xb4\x0f\xac\xd0\x10\xc1\xea\x10\x89E\xc8\x89U\xcc\x0f\xb7E\xc8\x0f\xb7U\xcc\x89E\xc8\x89U\xcc\x8bE\xc0\x8bU\xc4\x03E\xc8\x13U\xcc\x89E\xb0\x89U\xb4\x8bE\xb0\x8bU\xb4\x89\xc6\x89\xd7\x0f\xac\xfe\x10\xc1\xef\x10\x89\xf0%\xff\xff”
Printing description of stringTest:
(std::string) stringTest = “one\ntwo\nthree”
I want the \n
embedded in a block of text in my CSV data file to be recognized as a new line when storing that block of text in a buffer that I’m writing to an ofFile, which is going to be turned into an .md file to make the CSV data readable. I’m sure there is an easy answer to this - but I can’t seem to find it.
Thanks in advance!