2010-07-12 9 views
5

मैं सर्वर से एक यूआरएल एन्कोडिंग स्ट्रिंग प्राप्त हुआ है, जैसे http% 3a% 2f% 2fstatic.csbew.com% 2f% 2fcreative% 2fpd_test_pptv% 2f320x60.pngविंडोज मोबाइल पर यूआरएल एन्कोडिंग स्ट्रिंग को डीकोड कैसे करें?

मैं सामान्य यूआरएल स्ट्रिंग के लिए यह डिकोड करने के लिए चाहते हैं । मुझे यह विधि मिलती है, लेकिन यह कॉम्पैक्ट फ्रेमवर्क पर काम नहीं करती है।

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

स्ट्रिंग को डीकोड करने के बारे में कोई विचार?

उत्तर

10

हो सकता है कि यह तुम्हारी मदद करेगा:

/// <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

संबंधित मुद्दे