Home   |   Products   |   Documentation
 

dev net revision
29 July 2008
 

 
 

UnescapeText Method

static MCD_STR CMarkup::UnescapeText( MCD_CSTR szText, int nTextLength = -1 );

The UnescapeText static utility function is used internally to unescape the Standard Special Characters when extracting a text value from the document. You can use it to unescape special characters when dealing with markup text directly.

The UnescapeText function works for both null terminated strings and strings that are not if nTextLength is specified. The Standard Special Characters are decoded, as are any Numeric Character References. Any unrecognized entity references are left unchanged.

See also EscapeText.

Technical question about CMarkup::UnescapeText(...)Tom 06-Dec-2007

When using CMarkup::UnescapeText(...) I encountered some errors only in a MBCS release build with VC2003 SP1. The ampersand "&" in some (not all eg. ü --> ü) entities is replaced with an unprintable character. In my opinion this could be a compiler bug as I couldn't find any differences in the sourcecode. By the way it would be very nice that this function replaces all available entities (about 100).

It shouldn't be able to convert uuml because it only supports the 5 standard XML entities amp, quot, apos, lt and gt (see Standard Special Characters). To get uuml you would need to use the numeric character reference Ü. There might be a bug in UnescapeText for MBCS where it attempts to generate a character for a zero code point; this is something I will look at and fix in the next release. It could be that wctomb has a different behavior on invalid arguments in the different compilers. It is probably not related to your issue, but I will also mention that CMarkup does not support entities declared in the DTD since it ignores the content of the DTD. I had not thought of putting HTML entities like uuml in CMarkup, but since CMarkup supports forms of non-XML markup (see Other Markup) I will probably add the additional entities in an upcoming release if I can devise a succinct lookup mechanism. Thanks for the suggestion.

 
 

Question or comment about this article?

©Copyright 2008 First Objective Software, Inc. All rights reserved.