您目前尚未登陆,请选择【登陆】或【注册
首页->博客论坛->LiveBlog v1.0测试版源码>>LiveBlog.Core/Utils.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:LiveBlog v1.0测试版源码
当前文件:文件类型 LiveBlog/LiveBlog.Core/Utils.cs打开代码结构图
普通视图
		            
1Using 14 15namespace LiveBlog.Core 16{ 17 /// <summary> 18 /// Utilities for the entire solution to use. 19 /// </summary> 20 public static class Utils 21 { 22 23 /// <summary> 24 /// Strips all illegal characters from the specified title. 25 /// </summary> 26 public static string RemoveIllegalCharacters(string text) 27 { 28 if (string.IsNullOrEmpty(text)) 29 return text; 30 31 text = text.Replace(":", string.Empty); 32 text = text.Replace("/", string.Empty); 33 text = text.Replace("?", string.Empty); 34 text = text.Replace("#", string.Empty); 35 text = text.Replace("[", string.Empty); 36 text = text.Replace("]", string.Empty); 37 text = text.Replace("@", string.Empty); 38 text = text.Replace(".", string.Empty); 39 text = text.Replace("\"", string.Empty); 40 text = text.Replace("&", string.Empty); 41 text = text.Replace("'", string.Empty); 42 text = text.Replace(" ", "-"); 43 text = RemoveDiacritics(text); 44 45 return HttpUtility.UrlEncode(text).Replace("%", string.Empty); 46 } 47 48 private static String RemoveDiacritics(string text) 49 { 50 String normalized = text.Normalize(NormalizationForm.FormD); 51 StringBuilder sb = new StringBuilder(); 52 53 for (int i = 0; i < normalized.Length; i++) 54 { 55 Char c = normalized[i]; 56 if (CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark) 57 sb.Append(c); 58 } 59 60 return sb.ToString(); 61 } 62 63 URL handling 135 136 Is mobile device 164 165 Is Mono/Linux 202 203 Send e-mail