简体   繁体   English

如何将STX / ETX(C0控制代码)写入BSTR缓冲区IXMLDOMElement *

[英]How to write the STX / ETX ( C0 control code) into the BSTR buffer IXMLDOMElement*

I have one application which is passing one (BSTR* ProfileXml) as out parameter. 我有一个应用程序正在传递一个(BSTR * ProfileXml)作为out参数。 So One I am sending the Profile after allocating it using SysAllocString(Profile) 因此,我在使用SysAllocString(Profile)分配配置文件后发送配置文件

WCHAR   Profile[] = 
L"<IhvSecurity xmlns=\"http://www.sampleihv.com/nwifi/profile\">"
L"<IHVSecurityParam2>parameter value</IHVSecurityParam2>"
L"</IhvSecurity>";

It' working fine with paramater values for almost all the ascii character (excluding C0 codes like STX ascii code 2 ETX ascii code 3). 几乎所有ascii字符的参数值都可以正常工作(不包括C0代码,如STX ascii代码2 ETX ascii代码3)。 As soon I send either of STX or ETX that application send error and asking for valid xml buffer, I am using IXMLDOMElement method for loading profile buffer an modifying buffer and saving again buffer. 一旦我发送STX或ETX那个应用程序发送错误并要求有效的xml缓冲区,我就在使用IXMLDOMElement方法来加载配置文件缓冲区,修改缓冲区并再次保存缓冲区。 I haven' mention the encoding in Profile string buffer default is utf - 8. 我没有提到Profile字符串缓冲区中的编码默认为utf-8。

So I am doing some thing wrong here or We cannot use STX / ETX in xml ??? 所以我在这里做错了事,或者我们不能在xml中使用STX / ETX? MSMXL parser cannot parse them. MSMXL解析器无法解析它们。 Or they some way / API is there to write this into param buffer is node. 或者他们以某种方式/ API将其写入到param缓冲区的节点中。

Any help will really appreciated 任何帮助将不胜感激

Thanks 谢谢

You are right, you can't use control characters in XML 1.0 . 没错, 您不能在XML 1.0中使用控制字符 See the specification for the valid range . 有关有效范围,请参阅规格。 XML 1.1 adds support for these control characters, but I don't think MSXML supports XML 1.1. XML 1.1增加了对这些控制字符的支持,但是我不认为MSXML支持XML 1.1。

As a workaround you could implement some kind of escaping scheme and then decode it at the other end. 作为解决方法,您可以实现某种转义方案,然后在另一端对其进行解码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM