从cstring vc ++ mfc替换一些特殊字符(需要引用特殊字符) [英] Replacing some special characters from a cstring vc++ mfc(special characters need to be quoted )
问题描述
我有cstring,它会存储用户输入的详细信息(用户输入的详细信息)。
假设用户输入*&#(%^&((
然后我的字符串就像是
Cstring groupname;
groupname =*&#(%^&(((组名将包含用户字符)
但我想更换一些字符
假设用户输入&然后我将其替换为amp
你能建议我怎么解决这个问题。
我尝试过的事情:
我是mfc的新手,所以我不知道这里
如果你不知道如何使用特定的类有一个首先查看文档。在这种情况下,您可能会找到 CStringT :: Replace [ ^ ]方法。
要TMLifyCString
s使用:
/ * 首先替换'&'。 * /
str.Replace(_T( &), _T( & amp;));
str.Replace(_T( <),_ T( & lt;));
str.Replace(_T( >),_ T( & gt;));
str.Replace(_T( \),_ T( & quot;));对于XML,也替换单引号字符
&安培;者;
I have cstring and it will store the user input details(user entered details).
suppose user enter "*&#(%^&(("
then my string is like
Cstring groupname;
groupname = "*&#(%^&(("(group name will contain user eneter characters)
but I want to replace some characters in that
suppose if user entered as "&" then I have replace that as "amp"
could you please suggest me how to solve this.
What I have tried:
I am new to mfc so I have no idea here
If you don't know how to do such when using a specific class have a look at the documentaion first. In this case you might find the CStringT::Replace[^] method.
To "TMLifyCString
s use:
/* Replace '&' first. */ str.Replace(_T("&"), _T("&")); str.Replace(_T("<"), _T("<")); str.Replace(_T(">"), _T(">")); str.Replace(_T("\""), _T("""));For XML replace also the single quote character with
'
这篇关于从cstring vc ++ mfc替换一些特殊字符(需要引用特殊字符)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!