文字列を1文字ずつ列挙して、見つけた'¥'を'/'に変換します。
#include <tchar.h>
#include <iostream>
#include <string>
#include <windows.h>
/*
'¥'マークを'/'に変換する
*/
std::wstring ConvertWebPath
(
std::wstring strString // 変換したい文字列
)
{
std::wstring strRet;
std::wstring::iterator ite = strString.begin();
std::wstring::iterator iteEnd = strString.end();
while( ite != iteEnd ) {
TCHAR wChar = *ite++;
// '¥¥'を'/'に変換する
if ( L'¥¥' == wChar ) {
strRet += L'/';
continue;
}
strRet += wChar;
}
// 変換結果を返す
return( strRet );
}
/*
'¥'マークを'/'に変換する
*/
int _tmain
(
int argc
, _TCHAR* argv[]
)
{
// ロケール変更(wcoutでユニコードを出力する為)
std::wcout.imbue(std::locale("", std::locale::ctype));
// '¥'マークを'/'に変換する
std::wstring strRet = ConvertWebPath( L"http:¥¥¥¥www.wabiapp.com¥¥WabiSampleSource¥¥windows¥¥" );
// 結果の出力
std::wcout << L"¥"" << strRet.c_str() << L"¥"" << std::endl;
// 正常終了
return( 0 );
}
"http://www.wabiapp.com/WabiSampleSource/windows/"