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 http://www.lookuptables.com/.
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);