~kelemeng/banshee/bug743928

« back to all changes in this revision

Viewing changes to src/Hyena/Hyena/System.Web/HttpUtility.cs

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2011-05-14 22:25:36 UTC
  • mfrom: (6.3.15 experimental)
  • Revision ID: james.westby@ubuntu.com-20110514222536-u1x7ikxdqkmfvyuz
Tags: 2.1.0-1ubuntu1
* [2396c18] Merge from Debian Unstable, remaining changes:
  + Enable SoundMenu and Disable NotificationArea by default
  + Disable boo and karma extensions
  + Enable and recommnd u1ms and soundmenu extensions
  + Move desktop file for Meego UI to /usr/share/une/applications
  + Change the url for the Amazon store redirector
  + Create the U1MS widget earlier and bump libu1 requirement
* [9d7c600] Drop upstreamed u1ms-initialize-earlier patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
//
31
31
 
32
32
using System.Collections;
 
33
using System.Collections.Generic;
33
34
using System.Collections.Specialized;
34
35
using System.Globalization;
35
36
using System.IO;
37
38
using System.Text;
38
39
using System.Web.Util;
39
40
 
40
 
#if NET_2_0
41
 
using System.Collections.Generic;
42
 
#endif
43
 
 
44
41
namespace System.Web {
45
42
 
46
43
#if !MONOTOUCH
409
406
                                e = Encoding.UTF8;
410
407
 
411
408
                        long len = s.Length;
412
 
#if NET_2_0
413
409
                        var bytes = new List <byte> ();
414
 
#else
415
 
                        ArrayList bytes = new ArrayList ();
416
 
#endif
417
410
                        int xchar;
418
411
                        char ch;
419
412
                        
443
436
                                        WriteCharBytes (bytes, ch, e);
444
437
                        }
445
438
                        
446
 
#if NET_2_0
447
439
                        byte[] buf = bytes.ToArray ();
448
 
#else
449
 
                        byte[] buf = (byte[])bytes.ToArray (typeof (byte));
450
 
#endif
451
440
                        bytes = null;
452
441
                        return e.GetString (buf);
453
442
                        
1005
994
                                output.Write (HtmlEncode (s));
1006
995
                }
1007
996
 
1008
 
#if NET_1_1
1009
 
                public static string UrlPathEncode (string s)
1010
 
                {
1011
 
                        if (s == null || s.Length == 0)
1012
 
                                return s;
1013
 
 
1014
 
                        MemoryStream result = new MemoryStream ();
1015
 
                        int length = s.Length;
1016
 
            for (int i = 0; i < length; i++) {
1017
 
                                UrlPathEncodeChar (s [i], result);
1018
 
                        }
1019
 
                        return Encoding.ASCII.GetString (result.ToArray ());
1020
 
                }
1021
 
                
1022
 
                static void UrlPathEncodeChar (char c, Stream result) {
1023
 
#if NET_2_0
1024
 
                        if (c < 33 || c > 126) {
1025
 
#else
1026
 
                        if (c > 127) {
1027
 
#endif
1028
 
                                byte [] bIn = Encoding.UTF8.GetBytes (c.ToString ());
1029
 
                                for (int i = 0; i < bIn.Length; i++) {
1030
 
                                        result.WriteByte ((byte) '%');
1031
 
                                        int idx = ((int) bIn [i]) >> 4;
1032
 
                                        result.WriteByte ((byte) hexChars [idx]);
1033
 
                                        idx = ((int) bIn [i]) & 0x0F;
1034
 
                                        result.WriteByte ((byte) hexChars [idx]);
1035
 
                                }
1036
 
                        }
1037
 
                        else if (c == ' ') {
1038
 
                                result.WriteByte ((byte) '%');
1039
 
                                result.WriteByte ((byte) '2');
1040
 
                                result.WriteByte ((byte) '0');
1041
 
                        }
1042
 
                        else
1043
 
                                result.WriteByte ((byte) c);
1044
 
                }
1045
 
#endif
1046
 
 
1047
 
#if NET_2_0
1048
997
                class HttpQSCollection : NameValueCollection {
1049
998
                        public override string ToString ()
1050
999
                        {
1082
1031
                        ParseQueryString (query, encoding, result);
1083
1032
                        return result;
1084
1033
                }                               
1085
 
#endif
1086
1034
 
1087
1035
                internal static void ParseQueryString (string query, Encoding encoding, NameValueCollection result)
1088
1036
                {