tags:

views:

141

answers:

2

It's pretty well publicised knowledge that _x0020_ replaces spaces in SharePoint internal field names. When working with SharePoint web services this can be a bit of a nightmare until you write a replace rule when comparing field names.

I've just found myself another one of these "encoding exceptions" in a field called SSL2. Bizarrely the internal name ends out being _x0053_SL2. I've tried something like RRL2 which comes out as _x0052_. From this it appears that the number used in the encoding represents the ASCII value of that character. Space would likewise be _x0020_.

My question is twofold:

  1. In this case, whats causing SharePoint to encode these characters.

  2. Broadly, what sort of encoding is being done and is there a general step I can do to decode strings rather than replacing specific occurances which I've come across and know to be a problem.

A: 

Hi Dan

SharePoint XML encodes names because it want to be able to use the field names as attributes in XML.

You can use System.Xml.XmlConvert.EncodeName to encode your names

Per Jakobsen
Doesn't work. Putting SSL2 into EncodeName comes out with SSL_x005F_x0020_2. Not the _x0053_SL_x0020_2 that SharePoint uses.
Dan Revell
'SSL 2' that is
Dan Revell
A: 

You should use System.Xml.XmlConvert.DecodeName

Сергій