Decodes a name. This method does the reverse of the XmlConvert.EncodeName(string) and XmlConvert.EncodeLocalName(string) methods.
The decoded name.
The names are decoded using the following rules:
Names are decoded from left to right.
Any sequence _x HHHH_ (where HHHH stands for a valid, four digit hexadecimal UCS-2 code) that has not been decoded is transformed into the corresponding Unicode 2.1 (Unicode 3.0 if supported by the application) character.
No shortforms are recognized. They are passed on without translation. For example, _x20_ or __ are not decoded.
The actual encoding of the character is application-specific. For example, Order_x0020_Details becomes Order Details. Even escaped characters that are invalid in XML names will be recognized and decoded.
The following example demonstrates the valid and invalid character formats for decoding.
C# Example
using System; using System.Xml; public class App { public static void Main() { Console.WriteLine( "{0} : {1} : {2}", // _x0069_ decodes to i XmlConvert.DecodeName("Order #1_x0069_"), // missing beginning _ XmlConvert.DecodeName("Order #1x0069_"), // short form XmlConvert.DecodeName("Order #1_x69_") ); } }
The output is
Order #1i : Order #1x0069_ : Order #1_x69_