示例#1
0
Utf8String StrReplace(Utf8String text, Utf8String s, Utf8String d)
{
    for(int index=0; index=text.find(s, index), index!=std::string::npos;)
	{
		text.replace(index, s.length(), d);
		index += d.length();
	}
	return text;
}
示例#2
0
bool PutFileContents(const Utf8String& utf8Filename, const Utf8String& content)
{
	FILE *stream = fopen_utf8(utf8Filename.c_str(), "wb");
	if(!stream) return false;
	fwrite(content.c_str(), content.length(),1, stream);
	fclose(stream);
	return true;
}
示例#3
0
文件: String.cpp 项目: klinki/MI-RUN
			String::String(Utf8String & str, Class * classPtr): ObjectHeader(classPtr)
			{
				this->dataLength = str.bytes();
				this->hash = str.getHash();
				this->stringLength = str.length();

				memcpy(this->data, str.toAsciiString(), str.bytes());
			}
示例#4
0
const Utf8String ExtractFilePath(const Utf8String& fileName)
{
	int i, len = fileName.length();
	for(i = len-1; i >= 0; i--)
	{
		if(fileName[i] == '\\' || fileName[i]=='/')
		{
			return fileName.substr(0, i+1);
		}
			
	}
	return "";
}
示例#5
0
Utf8String ExtractFileName(const Utf8String fileName)
{
		Utf8String temp = fileName;
		int Qpos = temp.find_last_of('?');
		if(Qpos>=0) temp = temp.substr(0, Qpos-1);
		int i,len = temp.length();
		for(i=len-1; i>=0; i--)
		{
			if(temp[i] == '\\' || temp[i]=='/')
				break;
		}
		return temp.substr(i+1);
}
示例#6
0
Utf8String ExtractFileExt(const Utf8String fileName)
{
	int nLen = fileName.length();

	Utf8String result;
	for( int i=nLen-1; i>=0; i-- )
	{
		if(fileName[i] == '.')
		{
			result = fileName.substr(i + 1);
			break;
		}
		else if(fileName[i] == '\\' || fileName[i] == '/') break;
	}
	return result;
}