Skip to main content

Thinking out aloud - Dave Hunter's SharePoint Blog

Go Search
Home
Blog
  

Locations of visitors to this page


 Useful Links

  Microsoft UK events
  SharePoint 2007 on CodePlex
  SharePoint Community Portal
  SharePoint User Group
  SharePoint Community Portal
  SharePoint Pedia
  SharePoint MSDN Forums
  SharePoint University
Home > Thinking out aloud - Dave Hunter's SharePoint Blog > Posts > SharePoint 2007 Escaped Column Names
My thoughts and findings on Microsoft Information worker technologies, including MCMS and SharePoint 2007 (MOSS).
SharePoint 2007 Escaped Column Names

Most developers who have experience of SharePoint will know that when naming columns using the user interface will result in the actual column name will be an escaped version of what the user entered as the column name. The most common replacement is a space is replaced with "_x0020_". For example: A user enters "Published Date". The display name will remain as "Published Date" but the underlying name of the column will be "Published_x0020_Date".

The table below lists some of the commonly replaced characters

Character

Hex Code

Escaped Version

[space]

20

_X0020_

|

7C

_X007C_

-

2D

_X002D_

\

5C

_X005C_

(

28

_X0028_

)

29

_X0029_

'

27

_X0027_

,

2C

_X002C_

!

21

_X0021_

%

25

_X0025_

&

26

_X0026_

?

3F

_X003F_

$

24

_X0024_

£

A3

_X00A3_

"

22

_X0022_

<

3C

_X003C_

>

3E

_X003E_

=

3D

_X003D_

#

23

_X0023_

 

However there is another way, .NET has a method called EncodeName, which is part of the System.Xml namespace. You can use this method to take in a string that needs to be escaped and returns the escaped string based on the input. For example:

 
using System.Xml; 


// encode the column name 
string escapedString = XmlConvert.EncodeName("Published Date"); 

 
// decode the escaped column name  
string normalString = XmlConvert.DecodeName(escapedString); 

For more information about EncodeName please see http://msdn.microsoft.com/en-us/library/system.xml.xmlconvert.encodename.aspx. Also note that there is a DecodeName method that does the reverse.

One way to get around the escaping is to name a column without spaces or special characters, save the changes and then go back into the column and rename with your desired name. The result is that the name specified first is used for the column name and the latter just changes the display name.

Hope this helps

  Copyright
This work is licenced under a Creative Commons Attribution-Noncommercial-No Derivative Works 2.0 UK: England & Wales License
  Site Map

Comments

There are no comments yet for this post.

 Dave Hunter

I'm currently a Senior Consultant at Netstore 2e2. I specialise in Microsoft Information Worker technologies (especially MOSS, MCMS and .NET), with over 8 years of experience within this area of specialism. 

I have gained two certifications for MOSS and WSS and look to complete the full certification track soon.

View Dave Hunter's profile on LinkedIn

  Subscribe in a reader


 Latest Posts

I’m attending the first ever SharePoint Saturday in the UK31/08/2010 19:43
I’ve re-joined CIBER UK31/08/2010 19:26
I’ve been Awarded a MVP for SharePoint01/04/2010 19:49
SharePoint 2010 Training on Microsoft E-Learning15/03/2010 17:56
SharePoint UK User Group - Thursday 27th August London Meeting25/08/2009 17:56
CAML Query that filters on the current user23/07/2009 17:50
Microsoft Ramp Up Free SharePoint Developer Training22/07/2009 20:59
How To: Change a SharePoint Application Pool Programmatically07/07/2009 18:08
SharePoint Forums Topping 100 Answers06/07/2009 12:29
Find out the SharePoint Internal Name for a Column or Site Column28/05/2009 09:56
1 - 10 Next