0
文字列をWStringに変換する方法。文字列をWstringに変換する方法C++ Visual Studio
EscapeXMLを変換する前に、最初に文字列をwstringに変換する必要があります。
例:
私は文字列値= "& & &" を持って、私はwstringのにこの文字列を変換したいです。
私のソースコード:
string escapeXML(const std::string & value)
{
// Here
CA2W ca2w(value.c_str());
wstring value = ca2w;
int output_size = EscapeXML(value.c_str(), value.length(), 0, 0, ATL_ESC_FLAG_ATTR);
std::wstring testout;
testout.resize(output_size);
EscapeXML(value.c_str(), value.length(), &testout[0], output_size, ATL_ESC_FLAG_ATTR);
using convert_type = std::codecvt_utf8<wchar_t>;
std::wstring_convert<convert_type, wchar_t> converter;
string converted_str = converter.to_bytes(testout);
return converted_str;
}
int main()
{
std::string test = " & & & ";
cout << escapeXML(test) << '/n';
return 0;
}
マイ出力:
C2082: redefinition of formal parameter 'value'
IntelliSense: argument of type "const char *" is incompatible with parameter of type "const wchar_t *"
あなたのコードを実行しないと、私はあなたの問題/質問を見ることができませんか?あなたは何を期待していましたか、あなたは何を見ましたか/見ましたか? –
私は今ケースを更新します。私はあなたが問題を理解することを願っています:) – Skydreampower
あなたの助言のためにありがとう@computerfreaker。 – Skydreampower