Converting sharepoint 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 trunate 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 hexidecimal ascii code for the space character (escaping other characters also use hex ascii codes) - see http://www.lookuptables.com/.
Edit: Using System.Xml.XmlConvert.EncodeSharepoint seems to convert display names to internal names by escaping using System.Xml.XmlConvert.Encode(myFieldNameString). E.g.
string internalName = XmlConvert.EncodeName(displayName);
post a comment / view comments (currently 1 comments)
XmlConvert.EncodeName(displayName); - Does not seem to handle - characters, probably some other special chars also, not sure if they have properietary encoding for sharepoint... any other methods to encode? - should encode to x002d which the above function does not seem to do..