我的网站是UTF-8编码的,从sql2k数据库里取出一个词,想做一个链接,用户点击直接在google或baidu或Yahoo中搜索这个词,由于编码是utf-8的,用以下链接出现乱码,请教大家怎么解决?以下只给出google的部分.
string title=;//title从数据库读取
string Google_SearchStr="http://www.google.com/search?hl=zh-CN&ie=GBK&oe=GBK&lr=lang_zh-CN&&q=";"<a href='"+Google_SearchStr+title)+"' Target='_blank'>在googel中搜索 "+Title+"</a>";我该如何解决?帮帮我!

解决方案 »

  1.   

    Response.Charset  ="utf-8";
     string Title="中文";
    string Google_SearchStr="http://www.google.com/search?q=";

    Response.Write("<a href='"+Google_SearchStr+Server.UrlEncode(Title)+"' Target='_blank'>在googel中搜索 "+Title+"</a>");
      

  2.   

    传参数的时候把中文用server.UrlEncode()方法,转码
      

  3.   

    Server.UrlEncode()编码
    Server.UrlDecode()解码
      

  4.   

    cpp2017(幕白兄) :您的回答google问题解决了,那baidu和yahoo的链接如何写?谢谢!!!
      

  5.   


    Response.Charset  ="utf-8";
     string Title="中文";
    string Google_SearchStr="http://www.baidu.com/s?wd=";

    Response.Write("<a href='"+Google_SearchStr+System.Web.HttpUtility.UrlEncode(Title,System.Text.Encoding.GetEncoding("gb2312"))+"' Target='_blank'>在bidu中搜索 "+Title+"</a>");
      

  6.   

    Response.Charset  ="utf-8";
     string Title="中文";
    string Google_SearchStr="http://search.yahoo.com/search?&ei=UTF-8&p=";

    Response.Write("<a href='"+Google_SearchStr+System.Web.HttpUtility.UrlEncode(Title,System.Text.Encoding.UTF8)+"' Target='_blank'>在yahoo中搜索 "+Title+"</a>");