Home   |   Products   |   Documentation
 

dev net revision
29 July 2008
 

 
 

GetDeclaredEncoding Method

static MCD_STR CMarkup::GetDeclaredEncoding( MCD_CSTR szDoc );

This method can be used to obtain the encoding name from the XML Declaration at the beginning of an XML string without having parsed the string. GetDeclaredEncoding parses only the xml processing instruction at the beginning of the document. If no encoding value is found, an empty string is returned.

The reason this is a separate static function, and not a method that operates on the object document, is that often you need to determine the encoding before parsing so you can convert the text encoding before initializing the CMarkup object.

Encoding is a large topic that applies to all text files, and an XML file is a text file. See also ANSI and Unicode Files. When an XML file is not stored in a Unicode encoding, the encoding must be specified in the XML Declaration, .e.g.

<?xml version="1.0" encoding="Windows-1252"?>

CMarkup has always left most of the work for encoding issues up to the developer, and many customers have been provided with individual encoding solutions specific to their circumstances. The challenge with CMarkup is to add support for common encoding needs without complicating or bogging down the product. Most Western users of text files are not concerned with encoding until they discover a character such as the Euro currency symbol getting corrupted.

 
 

Question or comment about this article?

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