BOM getTextBom(gkString& line, bool removeBom) { size_t len = line.size(); BOM bom = getTextEncoding(line.c_str(), len); if (bom != BOM_NONE && removeBom) { //strip bom line = line.substr(getBOMLength(bom)); } return bom; }
//-- gkString //from ogre3d StringUtil liStrVec strSplit( const gkString& str, const gkString& delims, UTuint32 maxSplits) { liStrVec ret; // Pre-allocate some space for performance ret.reserve(maxSplits ? maxSplits+1 : 10); // 10 is guessed capacity for most case unsigned int numSplits = 0; // Use STL methods size_t start, pos; start = 0; do { pos = str.find_first_of(delims, start); if (pos == start) { // Do nothing start = pos + 1; } else if (pos == gkString::npos || (maxSplits && numSplits == maxSplits)) { // Copy the rest of the gkString ret.push_back( str.substr(start) ); break; } else { // Copy up to delimiter ret.push_back( str.substr(start, pos - start) ); start = pos + 1; } // parse up to next real data start = str.find_first_not_of(delims, start); ++numSplits; } while (pos != gkString::npos); return ret; }