We have been making a lot of use of Managed Metadata lately. This was working fine until we tested a CSV import in Sharepoint where the Company Name field contained an ampersand (&). It unexpectedly returned comparison as null even if that term did exist in term store. I had noticed previously that the ampersand looked a little unusual in SharePoint but thought nothing more of it until now.
It transpires that the ampersand (&) is automatically converted to a Unicode/wide character version (&) when it is added to the Term Store. This is represented using hex code FF06 or integer 65286. The only documentation I have found confirming this so far is in theTaxonomyItem.NormalizeName method which “Normalizes a name of a TaxonomyItem object”, or in other words, converts the given string to the format used in the Term Store.??
The remarks section says:
The name will be normalized to trim consecutive spaces into one and replace the & character with the wide character version of the character (\uFF06).
However upon reflecting the method I found the following code:
return CommonValidator.trimSpacesRegex.Replace(name, ” “).Replace(‘&’, 0xff06)
To fix this, Use following code where you need to get taxonomy term:
|var result = TaxonomyItem.NormalizeName(clientContext, c);clientContext.ExecuteQuery();
c = result.Value;