[Gambas-user] Converting a POST string

Tobias Boege taboege at ...626...
Fri Jul 19 19:27:35 CEST 2013


On Fri, 19 Jul 2013, Rolf-Werner Eilert wrote:
> 
> 
> Am 19.07.2013 18:49, schrieb Beno?t Minisini:
> > Le 19/07/2013 18:27, Rolf-Werner Eilert a ?crit :
> >>
> >>
> >> Am 19.07.2013 18:02, schrieb Beno?t Minisini:
> >>> Le 19/07/2013 17:43, Rolf-Werner Eilert a ?crit :
> >>>> Hi,
> >>>>
> >>>> just bounced into this: When doing a POST request on a web form, the
> >>>> string input by the user is encoded in UTF-8 but as %high-byte%lowbyte
> >>>> such as "%C3%BC" for "?".
> >>>>
> >>>> How do I reconvert these worms to UTF-8 strings? Tried conv(), but
> >>>> didn't succeed yet. Is there a quick way, or do I have to pick out all %
> >>>> and convert them one-by-one?
> >>>>
> >>>> Thanks for your help.
> >>>>
> >>>> Rolf
> >>>>
> >>>
> >>> One by one. Or fix your HTTP client!
> >>>
> >>
> >> Err - you mean the server? Apache configuration?
> >>
> >
> > If bytes are swapped in the client request, then the client is buggy.
> > UTF-8 is low byte first.
> >
> 
> Aah ok, we got us wrong here. It's the %something thing which isn't 
> converted back into a Gambas UTF-8 string. It is not a problem about low 
> or high byte first, that was a mistake I made when writing the mail.
> 
> When I read the POST string in, I get for example %C3%BC for "?", so I 
> have to convert these into UTF-8 characters for the string within Gambas 
> to process them further.
> 
> My question should have been: Is there a ready-made function like conv() 
> that is able to receive a 7-bit string in the form of %C3%BC and will 
> convert it into a string with an ??
> 
> And if conv() will do, which types of encoding will I have to use here?
> 

There is Url.Encode() and Url.Decode() in gb.web which can handle this form
of escaping. It apparently works with your samples.

Regards,
Tobi




More information about the User mailing list