本文整理汇总了C++中Encoding::Convert方法的典型用法代码示例。如果您正苦于以下问题:C++ Encoding::Convert方法的具体用法?C++ Encoding::Convert怎么用?C++ Encoding::Convert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Encoding
的用法示例。
在下文中一共展示了Encoding::Convert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UploadVideoImage
void UploadVideoImage(LPVOID lpParam)
{
UploadVideoImageInfo* pUploadInfo = (UploadVideoImageInfo*)lpParam;
string PackageDataSegment;
PackageDataSegment.append("site=");
PackageDataSegment.append(Encoding::Convert(pUploadInfo->strSite, CP_ACP));
PackageDataSegment.append("&videoid=");
PackageDataSegment.append(Encoding::Convert(pUploadInfo->strVideoId, CP_ACP));
PackageDataSegment.append("&xml=%3C%3Fxml%20version%3D%221.0%22%3F%3E%0D%0A%3CFile%20xmlns%3Adt%3D%22urn%3Aschemas-microsoft-com%3Adatatypes%22%3E%3CName%3E");
PackageDataSegment.append(Encoding::Convert(pUploadInfo->GetFileName(), CP_ACP));
PackageDataSegment.append("%3C/Name%3E%3CData%20dt%3Adt%3D%22bin.hex%22%3E");
PackageDataSegment.append(pUploadInfo->GetFileData());
PackageDataSegment.append("%3C/Data%3E%3C/File%3E");
vector<BYTE> vPostData(PackageDataSegment.length());
memcpy(&vPostData.at(0), PackageDataSegment.c_str(), PackageDataSegment.length());
vector<BYTE> vResponseData;
WebClient::Download(TEXT("http://wizard2.webdev.com/cgi-bin/article/uploadimages4video"), vResponseData, vPostData);
vResponseData.push_back(0);
Encoding encode;
TSTLSTRING strRetValue = CW2T(encode.Convert((const char*)&vResponseData.at(0), CP_ACP).c_str());
delete pUploadInfo;
}
示例2: DeleteVideoToServer
void DeleteVideoToServer(LPVOID lpParam)
{
TCHAR* pKeyBuffer = (TCHAR*)lpParam;
TSTLSTRING strKey = TSTLSTRING(pKeyBuffer);
delete [] pKeyBuffer;
VideoInfo item = VideoDataManager::GetInstance().GetVideoInfo(strKey);
string PackageDataSegment("VideoID=");
PackageDataSegment.append(CT2A(item.VideoID.c_str()));
vector<BYTE> vPostData(PackageDataSegment.length());
memcpy(&vPostData.at(0), PackageDataSegment.c_str(), PackageDataSegment.length());
try
{
vector<BYTE> vResponseData;
WebClient::Download(VideoConfig::GetInstance().GetVideoProxyDeleteVideoUrl(), vResponseData, vPostData);
vResponseData.push_back(0);
Encoding encode;
TSTLSTRING strRetValue = CW2T(encode.Convert((const char*)&vResponseData.at(0), CP_UTF8).c_str());
TSTLSTRING::size_type pos = strRetValue.find(TEXT(":"));
if(pos == TSTLSTRING::npos)
{
TSTLSTRING ErrMsg(TEXT("·þÎñÆ÷·µ»ØÒì³££¡£¨"));
ErrMsg.append(strRetValue);
ErrMsg.append(TEXT("£©"));
VideoDataManager::GetInstance().ErrorDeleteVideoAndResume(strKey, ErrMsg);
throw Exception(ErrMsg);
}
if(TEXT("OK") == strRetValue.substr(0, pos))
{
TSTLSTRING strMsg(item.VideoName);
CTipsDlg::ShowTips(strMsg, false);
VideoDataManager::GetInstance().LocalDeleteVideo(strKey);
}
else
{
TSTLSTRING ErrMsg(TEXT("ɾ³ýÊÓƵʧ°Ü£¡£¨"));
ErrMsg.append(strRetValue.substr(pos + 1));
ErrMsg.append(TEXT("£©"));
VideoDataManager::GetInstance().ErrorDeleteVideoAndResume(strKey, ErrMsg);
throw Exception(ErrMsg);
}
}
catch(Exception& error)
{
VideoDataManager::GetInstance().VideoFail(strKey, error.GetMessage());
MessageBox(NULL, error.GetMessage().c_str(), TEXT("´íÎó"), MB_OK|MB_ICONERROR);
}
}
示例3: ReadText
TSTLSTRING File::ReadText(TSTLSTRING path, UINT uCode)
{
HANDLE hFile = CreateFile(path.c_str(), FILE_READ_DATA, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(hFile == INVALID_HANDLE_VALUE)
throw Exception(TEXT("´ò¿ªÎļþʧ°Ü¡£"));
DWORD dwSize = ::GetFileSize(hFile, NULL) + 1;
char* lpBuffer = new char[dwSize];
memset(lpBuffer, 0, dwSize);
DWORD dwReadSize = 0;
if(!ReadFile(hFile, lpBuffer, dwSize, &dwReadSize, NULL))
{
delete [] lpBuffer;
CloseHandle(hFile);
throw Exception(TEXT("¶ÁÈ¡Îļþʧ°Ü"));
}
Encoding encode;
TSTLSTRING strContent = encode.Convert(lpBuffer, uCode);
delete [] lpBuffer;
CloseHandle(hFile);
return strContent;
}
示例4: CreateVideoToServerWithoutArticle
void CreateVideoToServerWithoutArticle(LPVOID lpParam)
{
wchar_t* pVideoKey = (wchar_t*)lpParam;
TSTLSTRING strKey = TSTLSTRING(CW2T(pVideoKey));
delete [] pVideoKey;
VideoInfo item = VideoDataManager::GetInstance().GetVideoInfo(strKey);
try
{
TSTLSTRING FileMD5 = FileHash::MD5(item.VideoFilePath);
DWORD dwFileSize = FileHash::GetFileSize(item.VideoFilePath);
string PackageDataSegment;
PackageDataSegment.append("Name=");
PackageDataSegment.append(Encoding::UrlEncoding(Encoding::Convert(item.VideoName, CP_UTF8)));
PackageDataSegment.append("&SourceId=");
PackageDataSegment.append(Encoding::UrlEncoding(Encoding::Convert(item.VideoSource, CP_UTF8)));
PackageDataSegment.append("&Author=");
PackageDataSegment.append(Encoding::UrlEncoding(Encoding::Convert(item.VideoAuthor, CP_UTF8)));
PackageDataSegment.append("&Channel=");
PackageDataSegment.append(Encoding::UrlEncoding(Encoding::Convert(item.VideoChannel, CP_UTF8)));
PackageDataSegment.append("&Creator=");
PackageDataSegment.append(Encoding::UrlEncoding(Encoding::Convert(item.VideoCreator, CP_UTF8)));
PackageDataSegment.append("&CatalogId=");
PackageDataSegment.append(Encoding::UrlEncoding(Encoding::Convert(item.VideoCatalog, CP_UTF8)));
PackageDataSegment.append("&Content=");
PackageDataSegment.append(Encoding::UrlEncoding(Encoding::Convert(item.VideoContent, CP_UTF8)));
PackageDataSegment.append("&Keyword=");
PackageDataSegment.append(Encoding::UrlEncoding(Encoding::Convert(item.VideoKeyword, CP_UTF8)));
PackageDataSegment.append("&MD5=");
PackageDataSegment.append(Encoding::UrlEncoding(Encoding::Convert(FileMD5, CP_UTF8)));
PackageDataSegment.append("&VideoSize=");
PackageDataSegment.append(Encoding::UrlEncoding(boost::lexical_cast<std::string, DWORD>(dwFileSize)));
vector<BYTE> vPostData(PackageDataSegment.length());
memcpy(&vPostData.at(0), PackageDataSegment.c_str(), PackageDataSegment.length());
vector<BYTE> vResponseData;
WebClient::Download(VideoConfig::GetInstance().GetVideoProxyCreateVideoInfoUrl(), vResponseData, vPostData);
vResponseData.push_back(0);
Encoding encode;
TSTLSTRING strRetValue = CW2T(encode.Convert((const char*)&vResponseData.at(0), CP_UTF8).c_str());
TSTLSTRING::size_type pos = strRetValue.find(TEXT(":"));
if(pos == TSTLSTRING::npos)
{
TSTLSTRING ErrMsg(TEXT("·þÎñÆ÷·µ»ØÒì³££¡£¨"));
ErrMsg.append(strRetValue);
ErrMsg.append(TEXT("£©"));
throw Exception(ErrMsg);
}
if(TEXT("OK") == strRetValue.substr(0, pos))
{
TSTLSTRING strVideoId;
TSTLSTRING::size_type posId = strRetValue.find(TEXT("-"));
if(posId == TSTLSTRING::npos)
{
VideoDataManager::GetInstance().LocalDeleteVideo(strKey);
MessageBox(NULL, TEXT("¸ÃÊÓƵÒѾÉÏ´«£¡"), TEXT("Ìáʾ"), MB_OK|MB_ICONINFORMATION);
}
else
{
strVideoId = strRetValue.substr(posId + 1);
CVideoInfoDataManager& dataMgr = VideoDataManager::GetInstance();
dataMgr.SetVideoId(strKey, strRetValue.substr(pos + 1));
try
{
QQPlay play;
vector<TSTLSTRING> vVideoPic = play.GetPictures(item.VideoFilePath);
for(vector<TSTLSTRING>::iterator iter=vVideoPic.begin();
iter!=vVideoPic.end();
++iter)
{
UploadVideoImageInfo* pUploadInfo = new UploadVideoImageInfo();
pUploadInfo->strfile = *iter;
pUploadInfo->strSite = item.VideoChannel;
pUploadInfo->strVideoId = strVideoId;
UploadImageThread::GetInstance().SendMessage(WM_UPLOADVIDEOIMG, pUploadInfo);
}
}
catch(Exception& error)
{
MessageBox(NULL, error.GetMessage().c_str(), TEXT("´íÎó"), MB_OK|MB_ICONERROR);
}
}
}
else
{
TSTLSTRING ErrMsg(TEXT("Ìí¼ÓÊÓƵʧ°Ü£¡£¨"));
ErrMsg.append(strRetValue.substr(pos + 1));
ErrMsg.append(TEXT("£©"));
throw Exception(ErrMsg);
}
}
catch(Exception& error)
//.........这里部分代码省略.........
示例5: CreateVideoToServer
void CreateVideoToServer(LPVOID lpParam)
{
wchar_t* pVideoKey = (wchar_t*)lpParam;
TSTLSTRING strKey = TSTLSTRING(CW2T(pVideoKey));
delete [] pVideoKey;
VideoInfo item = VideoDataManager::GetInstance().GetVideoInfo(strKey);
try
{
TSTLSTRING FileMD5 = FileHash::MD5(item.VideoFilePath);
DWORD dwFileSize = FileHash::GetFileSize(item.VideoFilePath);
string PackageDataSegment;
PackageDataSegment.append("Name=");
PackageDataSegment.append(Encoding::UrlEncoding(Encoding::Convert(item.VideoName, CP_UTF8)));
PackageDataSegment.append("&SourceId=");
PackageDataSegment.append(Encoding::UrlEncoding(Encoding::Convert(item.VideoSource, CP_UTF8)));
PackageDataSegment.append("&Author=");
PackageDataSegment.append(Encoding::UrlEncoding(Encoding::Convert(item.VideoAuthor, CP_UTF8)));
PackageDataSegment.append("&Channel=");
PackageDataSegment.append(Encoding::UrlEncoding(Encoding::Convert(item.VideoChannel, CP_UTF8)));
PackageDataSegment.append("&Creator=");
PackageDataSegment.append(Encoding::UrlEncoding(Encoding::Convert(item.VideoCreator, CP_UTF8)));
PackageDataSegment.append("&CatalogId=");
PackageDataSegment.append(Encoding::UrlEncoding(Encoding::Convert(item.VideoCatalog, CP_UTF8)));
PackageDataSegment.append("&Content=");
PackageDataSegment.append(Encoding::UrlEncoding(Encoding::Convert(item.VideoContent, CP_UTF8)));
PackageDataSegment.append("&Keyword=");
PackageDataSegment.append(Encoding::UrlEncoding(Encoding::Convert(item.VideoKeyword, CP_UTF8)));
PackageDataSegment.append("&MD5=");
PackageDataSegment.append(Encoding::UrlEncoding(Encoding::Convert(FileMD5, CP_UTF8)));
PackageDataSegment.append("&VideoSize=");
PackageDataSegment.append(Encoding::UrlEncoding(boost::lexical_cast<std::string, DWORD>(dwFileSize)));
vector<BYTE> vPostData(PackageDataSegment.length());
memcpy(&vPostData.at(0), PackageDataSegment.c_str(), PackageDataSegment.length());
vector<BYTE> vResponseData;
WebClient::Download(VideoConfig::GetInstance().GetVideoProxyCreateVideoInfoUrl(), vResponseData, vPostData);
vResponseData.push_back(0);
Encoding encode;
TSTLSTRING strRetValue = CW2T(encode.Convert((const char*)&vResponseData.at(0), CP_UTF8).c_str());
TSTLSTRING::size_type pos = strRetValue.find(TEXT(":"));
if(pos == TSTLSTRING::npos)
{
TSTLSTRING ErrMsg(TEXT("·þÎñÆ÷·µ»ØÒì³££¡£¨"));
ErrMsg.append(strRetValue);
ErrMsg.append(TEXT("£©"));
throw Exception(ErrMsg);
}
if(TEXT("OK") == strRetValue.substr(0, pos))
{
TSTLSTRING strVideoId;
TSTLSTRING::size_type posId = strRetValue.find(TEXT("-"));
if(posId == TSTLSTRING::npos)
{
VideoDataManager::GetInstance().LocalDeleteVideo(strKey);
MessageBox(NULL, TEXT("¸ÃÊÓƵÒѾÉÏ´«£¬ÕýÔÚ´´½¨ÊÓƵÎÄÕÂ..."), TEXT("Ìáʾ"), MB_OK|MB_ICONINFORMATION);
strVideoId = strRetValue.substr(pos + 1);
TSTLSTRING url(TEXT("http://wizard2.webdev.com/tcms/article/videoarticle.php?VideoID="));
url.append(strVideoId);
ShellExecute(NULL, TEXT("open"), url.c_str(), TEXT(""), NULL, SW_SHOWDEFAULT);
}
else
{
strVideoId = strRetValue.substr(posId + 1);
CVideoInfoDataManager& dataMgr = VideoDataManager::GetInstance();
dataMgr.SetVideoId(strKey, strRetValue.substr(pos + 1));
try
{
QQPlay play;
vector<TSTLSTRING> vVideoPic = play.GetPictures(item.VideoFilePath);
TSTLSTRING strAppPath = VideoApp::GetInstance().GetAppPath();
strAppPath = strAppPath.substr(0, strAppPath.find_last_of(TEXT("\\")) + 1);
strAppPath.append(TEXT("Temp\\ImageData\\"));
Directory::CreateDirectory(strAppPath);
GUID guid;
HRESULT hr = CoCreateGuid(&guid);
if(hr == S_OK)
{
wchar_t buffer[39];
memset(buffer, 0, 39*sizeof(wchar_t));
StringFromGUID2(guid, buffer, 39);
strAppPath.append(CW2T(buffer));
HANDLE hDataFile = CreateFile(strAppPath.c_str(), FILE_ALL_ACCESS, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(hDataFile == INVALID_HANDLE_VALUE)
throw Exception(TEXT("ÊÓƵ½Øͼʧ°Ü¡£"));
TSTLSTRING content;
UINT count = vVideoPic.size();
for(UINT i=0; i<count; ++i)
{
//.........这里部分代码省略.........