Invalid SharePoint URL Character Cheat Sheet

A few days ago I posted some code to clean out invalid characters in SharePoint URLs. Someone suggested using the SPEncode.IsLegalCharInUrl method to do this. While this might be easy if you're in SharePoint land, I don't like having a dependency on SharePoint assemblies for this sort of thing and want it in my own validation code (besides, the hoops SPEncode.IsLegalCharInUrl goes through, you can't unit test it, trust me).

After some digging I determined the list of valid and invalid characters. Only the first 128 characters in the ASCII character set are processed for validation so anything beyond that is considered invalid. It's fairly simple, pretty much everything from "@" through to "z" is valid (with a few exceptions). Here's the list as I couldn't find it posted anywhere and thought it would be useful as a cheat sheet.

Valid? Character Hex Value
No [NULL] 0
No 1
No 2
No 3
No 4
No 5
No 6
No   7
No [BS] 8
No [TAB] 9
No [CR] A
No B
No C
No [LF] D
No E
No F
No 10
No 11
No 12
No 13
No 14
No § 15
No 16
No 17
No 18
No 19
No 1A
No 1B
No 1C
No 1D
No 1E
No 1F
Yes [SPC] 20
Yes ! 21
No " 22
No # 23
Yes $ 24
No % 25
No & 26
Yes ' 27
Yes ( 28
Yes ) 29
No * 2A
Yes + 2B
Yes , 2C
Yes - 2D
Yes . 2E
Yes / 2F
Yes 0 30
Yes 1 31
Yes 2 32
Yes 3 33
Yes 4 34
Yes 5 35
Yes 6 36
Yes 7 37
Yes 8 38
Yes 9 39
No : 3A
Yes ; 3B
No < 3C
Yes = 3D
No > 3E
No ? 3F
Yes @ 40
Yes A 41
Yes B 42
Yes C 43
Yes D 44
Yes E 45
Yes F 46
Yes G 47
Yes H 48
Yes I 49
Yes J 4A
Yes K 4B
Yes L 4C
Yes M 4D
Yes N 4E
Yes O 4F
Yes P 50
Yes Q 51
Yes R 52
Yes S 53
Yes T 54
Yes U 55
Yes V 56
Yes W 57
Yes X 58
Yes Y 59
Yes Z 5A
Yes [ 5B
No \ 5C
Yes ] 5D
Yes ^ 5E
Yes _ 5F
Yes ` 60
Yes a 61
Yes b 62
Yes c 63
Yes d 64
Yes e 65
Yes f 66
Yes g 67
Yes h 68
Yes i 69
Yes j 6A
Yes k 6B
Yes l 6C
Yes m 6D
Yes n 6E
Yes o 6F
Yes p 70
Yes q 71
Yes r 72
Yes s 73
Yes t 74
Yes u 75
Yes v 76
Yes w 77
Yes x 78
Yes y 79
Yes z 7A
No { 7B
No | 7C
No } 7D
No ~ 7E
No 7F
Published Wednesday, April 30, 2008 8:36 PM by Bil Simser
Filed under:

Comments

No Comments