diff options
| author | tim <tim@eclectronics.org> | 2017-04-06 20:22:39 +0100 |
|---|---|---|
| committer | tim <tim@eclectronics.org> | 2017-04-06 20:22:39 +0100 |
| commit | 98297beced2af85d416ea857b530fc889bccbbf5 (patch) | |
| tree | a2a7a27c93d6b265c2ee8f84567705fc7a4790de /menuApp/src/ofApp.cpp | |
| parent | 09826101d0d9162a5cabfcdc82e4178714403cf9 (diff) | |
recognise euro symbol
Diffstat (limited to 'menuApp/src/ofApp.cpp')
| -rw-r--r-- | menuApp/src/ofApp.cpp | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/menuApp/src/ofApp.cpp b/menuApp/src/ofApp.cpp index 43ae097..67bc645 100644 --- a/menuApp/src/ofApp.cpp +++ b/menuApp/src/ofApp.cpp @@ -3,7 +3,31 @@ #define timtoken "3281768761.3dfcaf5.14ca9410c2aa4c00b9b60f36cd09d01a" #define hangdaitoken "3939854844.b31608d.a61a4e49a4dc40a688c22f4e0e81da3a" +std::string replaceStrChar(std::string str, const std::string& replace, char ch) { + + // set our locator equal to the first appearance of any character in replace + size_t found = str.find_first_of(replace); + + while (found != std::string::npos) { // While our position in the sting is in range. + str[found] = ch; // Change the character at position. + found = str.find_first_of(replace, found+1); // Relocate again. + } + + return str; // return our new string. +} + void ofApp::loadInstagramFeed(){ + +/* + std::string test[5]; + int testindex=0; + for (int i=0;i<255;i++){ + test[testindex]=" "+test[testindex]; + test[testindex][0]=i; + if (i==25||i==126||i==174||i==229) test[testindex]="\n"+test[testindex]; + if (i==51||i==102||i==153||i==204) testindex++; + } +*/ items.clear(); items.resize(IMAGE_SLOTS); instagram.getUserRecentMedia("self"); @@ -20,7 +44,9 @@ void ofApp::loadInstagramFeed(){ { for ( int i = 0; i < instagram.getImageURL().size(); i++) { - vector <std::string> tokens = ofSplitString(instagram.getImageCaption()[i]," ",true,true); //,ignoreEmpty=false,trim=false); + std::string str=replaceStrChar(instagram.getImageCaption()[i],"\n",' '); + + vector <std::string> tokens = ofSplitString(str," ",true,true); //,ignoreEmpty=false,trim=false); std::string caption; std::string price; @@ -43,9 +69,11 @@ void ofApp::loadInstagramFeed(){ tags+=" "; foundTags=true; } - else if((*it).at(0)=='€'){ + else if(((uint8_t)(*it).at(0))==226){ price=*it; foundPrice=true; + price[0]=164; + ofLog(OF_LOG_NOTICE) << "price is "<<price<<" from "<<*it; } else{ if (!foundTags){ @@ -58,6 +86,7 @@ void ofApp::loadInstagramFeed(){ if (interesting){ items[slot]=menuItem(caption,price); + //items[slot]=menuItem(test[i],price); std::string id=instagram.getImageID()[i]; @@ -70,10 +99,10 @@ void ofApp::loadInstagramFeed(){ if (!imagepool[id].isAllocated()) { getImages.loadFromURL(imagepool[id], instagram.getImageURL()[i]); - ofLog(OF_LOG_NOTICE) << "LOADING " << menutag << " " << slot << " " << id; + ofLog(OF_LOG_NOTICE) << "LOADING " << id << " " << slot << " " << caption; } else { - ofLog(OF_LOG_NOTICE) << "REUSE " << menutag << " " << slot << " " << id; + ofLog(OF_LOG_NOTICE) << "REUSE " << id << " " << slot << " " << menutag; } items[slot].image=&imagepool[id]; @@ -94,7 +123,11 @@ void ofApp::loadInstagramFeed(){ //-------------------------------------------------------------- void ofApp::setup(){ - + std::string str ("€"); + + ofLog(OF_LOG_NOTICE) << "code for € is " << ((int)str.at(0)) << " not " << 0xA4; + ofLog(OF_LOG_NOTICE) << "-30 as uint8_t is " << ((int)((uint8_t)-30)); + ofTrueTypeFont::setGlobalDpi(150); myText.init("American Typewriter Regular.ttf", FONTSIZE*FACTOR, 'i'); |
