Converting share point display name to internal name

Note to self: to convert from a SharePoint display name to the internal name, you must escape space characters with _x0020_ and truncate to 32 characters (if more). Note I am not sure if there are any other characters other than space that you need to escape.

string mappedName = displayName.Replace(" ", "_x0020_");
if (mappedName.Length > 32)
mappedName = mappedName.Substring(0, 32);

Thanks to Nick Grieff for this tip. Note that _x0020_ corresponds to the hexadecimal ascii code for the space character (escaping other characters also use hex ascii codes) – see

Edit: Using System.Xml.XmlConvert.Encode

Sharepoint seems to convert display names to internal names by escaping using System.Xml.XmlConvert.Encode(myFieldNameString). E.g.

string internalName = XmlConvert.EncodeName(displayName);

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>