2010-07-12 15 views
5

Ben sunucusundan bir URL kodlama dizesi aldık, mesela http% 3a% 2f% 2fstatic.csbew.com% 2f% 2fcreative% 2fpd_test_pptv% 2f320x60.pngWindows Mobile'da bir URL kodlama dizesi nasıl çözülür?

Normal url dizeye deşifre etmek istiyorum . Bu yöntemi buluyorum, ancak bu kompakt bir çerçeve üzerinde çalışmıyor.

string url = System.Web.HttpUtility.UrlDecode(strURL, Encoding.GetEncoding("GB2312")); 

Dizginin nasıl çözüleceği hakkında bir fikrin var mı?

cevap

10

Belki bu size yardımcı olacaktır: Başlangıçta burada bulunan

/// <summary> 
    /// UrlDecodes a string without requiring System.Web 
    /// </summary> 
    /// <param name="text">String to decode.</param> 
    /// <returns>decoded string</returns> 
    public static string UrlDecode(string text) 
    { 
     // pre-process for + sign space formatting since System.Uri doesn't handle it 
     // plus literals are encoded as %2b normally so this should be safe 
     text = text.Replace("+", " "); 
     return System.Uri.UnescapeDataString(text); 
    } 

    /// <summary> 
    /// UrlEncodes a string without the requirement for System.Web 
    /// </summary> 
    /// <param name="String"></param> 
    /// <returns></returns> 
    public static string UrlEncode(string text) 
    { 
     // Sytem.Uri provides reliable parsing 
     return System.Uri.EscapeDataString(text); 
    } 

: geekstoolbox

İlgili konular