Encoding of Generated Patches and Pastebin Plugin

Andreas Pakulat apaku at gmx.de
Thu Dec 22 03:34:47 UTC 2011


On 21.12.11 17:07:20, David Narvaez wrote:
> On Mon, Dec 19, 2011 at 3:43 AM, Andreas Pakulat <apaku at gmx.de> wrote:
> > However since we can assume this is 'binary data', its not necessary to
> > read the file at all. Simply write a conversion-function which works on
> > the binary data. That is, assume plain-ascii for the content and encode
> > based on that. Reading parts of
> > http://en.wikipedia.org/wiki/Percent-encoding I'd assume thats what the
> > browser does when you upload a file to pastebin directly.
> 
> Pastebin's API requires the POST data to be sent in UTF-8, so we'd
> still need to convert from whatever we detect/the user specifies to
> UTF-8. I understand your idea, but there's one detail that wasn't
> working for me. I can't remember right now what was it, but I think it
> stems from the fact that you read a QByteArray from the file but
> QUrl::toPercentEncoding expects a QString, so an implicit conversion
> happens under QString rules (which, I think, interpreted the
> QByteArray as a Latin-1 string in my case) or something of that sort.

Right, see my other mail. I implied that we'd write our own
percent-encoding (since that is a rather easy thing to do after all,
very limited set of rules etc.) that operates directly on the data.

Are you sure about pastebin requiring some specific encoding? Or does it
simply require a properly setup POST request with a
content-transfer-encoding setting? 

Also since I've recently stumbled over this myself, I wonder wether
there's any need for the percent-encoding at all, if its a POST-request
there shouldn't be any necessity to percent-encode any of the elements
(unless again this is specific to the pastebin API, but that would be
strange since a browser also wouldn't percent-encode the data when it
sends a POST request)...

Andreas





More information about the KDevelop-devel mailing list