如何在BlogEngine.NET中发表标题为纯汉语的文章

今天我来做回妙手回春的庸医!

症状:
BlogEngine.NET 1.0.0.0(1.3已经失效)中发表题目为纯汉字的文章(不包含数字字母等),他生成的连接方式为:.aspx,就是标题中把汉字给过滤掉(我的第一感觉)

下药:
查看他的源码,结果发现在Utils.cs中有如下对国人不妥之处:

public static string RemoveIlegalCharacters(string text)
    {
      
if (string.IsNullOrEmpty(text))
        
return text;

      StringBuilder sb 
= new StringBuilder();
      text 
= text.Replace(" ""-");
      
foreach (char c in text)
      {
          
if (IsAllowedCharacter(c))//把此处注释掉整个世界就和平拉
          sb.Append(c);
      }

      
return sb.ToString();
    }

    
private static bool IsAllowedCharacter(char character)
    {
      
string allowedChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-";
      
foreach (char c in allowedChars)
      {
        
if (c == character)
          
return true;
      }

      
return false;
    }

oh yeah,病是好拉,但是他失去拉过滤的功能,看来我只能做庸医!(大家根据需要改吧)
posted @ 2007-06-13 11:25 overred 阅读(1023) 评论(6)  编辑 收藏 所属分类: ⑤ OpenSoft

  回复  引用    
#1楼 2007-06-13 15:32 | yoyo [未注册用户]
能不能中文用它的Asii 码代替?
  回复  引用  查看    
#2楼 2007-06-13 16:44 | overred      
@yoyo
当然可以,不过只是为拉便于搜索引擎搜索
  回复  引用  查看    
#3楼 2007-06-27 11:16 | 武眉博<活靶子.Net>      
今天看了看代码这部分已经做了修改
 1
 2    /// <summary>
 3    /// Strips all illegal characters from the specified title.
 4    /// </summary>

 5    public static string RemoveIlegalCharacters(string text)
 6    {
 7      if (string.IsNullOrEmpty(text))
 8        return text;
 9
10      text = text.Replace(":"string.Empty);
11      text = text.Replace("/"string.Empty);
12      text = text.Replace("?"string.Empty);
13      text = text.Replace("#"string.Empty);
14      text = text.Replace("["string.Empty);
15      text = text.Replace("]"string.Empty);
16      text = text.Replace("@"string.Empty);
17      return HttpUtility.UrlEncode(text.Replace(" ""-"));
18
19      //StringBuilder sb = new StringBuilder();
20      //text = text.Replace(" ", "-");
21      //foreach (char c in text)
22      //{
23      //  if (IsAllowedCharacter(c))
24      //    sb.Append(c);
25      //}
26
27      //return sb.ToString();
28    }

  回复  引用  查看    
#4楼 [楼主]2007-06-27 12:47 | overred      
@武眉博&lt;活靶子.Net&gt;
^T^
  回复  引用    
#5楼 2008-02-12 08:55 | aidi [未注册用户]
请问“查看他的源码,结果发现在Utils.cs中有如下对国人不妥之处:”中的utils.cs在哪个文件中?我怎么找不到啊?想改也不知道在哪里改!

  回复  引用  查看    
#6楼 [楼主]2008-02-12 12:03 | overred      
@aidi
在BlogEngine.NET 1.3 里已经没有了

标题  
姓名  
主页
Email (只有博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2008-02-12 12:11 编辑过
 
历史上的今天:

另存  打印