Hello David, Here is a proposal of URL_Decode, this one gets Encoding parameter: function URL_Decode (S : String; Encoding : String := "") return String is C : Integer := S'First;
function Translate_Character return Character; function Translate_Character return Character is R : Character := S (C); begin if R = '+' then R := ' '; elsif R = '%' and C < S'Last - 1 then R := Character'Val (Integer'Value ("16#" & S (C + 1 .. C + 2) & "#")); C := C + 2; end if; C := C + 1; return R; end Translate_Character; R : Ada.Strings.Unbounded.Unbounded_String; begin while C in S'Range loop Ada.Strings.Unbounded.Append (R, Translate_Character); end loop; if Encoding = "UTF-8" then return Ada.Strings.UTF_Encoding.Strings.Decode (Ada.Strings.Unbounded.To_String (R)); else return Ada.Strings.Unbounded.To_String (R); end if; end URL_Decode; I suppose Unescape_Quotes should be also encoding aware. Shouldn't it? Regards, Pascal. http://blady.pagesperso-orange.fr Le 4 août 2015 à 20:47, Rabbi David Botton <da...@botton.com> a écrit : > Oh could be, sorry was on the go. So we can add a URL_Encode and URL_Decode > to gnoga.ads > > David Botton > > On Tue, Aug 4, 2015 at 2:34 PM, Pascal <blady-...@users.sf.net> wrote: > Hello David, > in my understanding, Unescape_Quotes processes "\x.." escaped characters but > not "%.."? > Does it? > > Thanks, Pascal. > http://blady.pagesperso-orange.fr > > > Le 3 août 2015 à 21:50, Rabbi David Botton <da...@botton.com> a écrit : > > > Did you look at Gnoga.ads - function Unescape_Quotes (S : String) return > > String; ? > > It already does these translations. > > > > David Botton > > > > > > > > On Mon, Aug 3, 2015 at 3:21 PM Pascal <blady-...@users.sf.net> wrote: > > Hello, > > > > For using easily GET parameters, I want to add in Gnoga an URL decoder > > function: > > The encoded string google.com/search?q=%60Abdu%27l-Bah%C3%A1 should revert > > to the unencoded form google.com/search?q=`Abdu'l-Bahá > > > > I found this from Rosetta code: > > http://rosettacode.org/wiki/URL_decoding#Ada > > > > There is also a function AWS.URL.Decode. > > > > I don't think Gnoga should again include AWS just for that. > > > > Should I copy Rosetta function or AWS one in Gnoga Code? > > > > Or other ideas? > > > > Thanks, Pascal. > > http://blady.pagesperso-orange.fr > > > > > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > > Gnoga-list mailing list > > Gnoga-list@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/gnoga-list > > ------------------------------------------------------------------------------ > > _______________________________________________ > > Gnoga-list mailing list > > Gnoga-list@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/gnoga-list > > > ------------------------------------------------------------------------------ > _______________________________________________ > Gnoga-list mailing list > Gnoga-list@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gnoga-list > > ------------------------------------------------------------------------------ > _______________________________________________ > Gnoga-list mailing list > Gnoga-list@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gnoga-list ------------------------------------------------------------------------------ _______________________________________________ Gnoga-list mailing list Gnoga-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gnoga-list