From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joseph Turner Newsgroups: gmane.emacs.devel Subject: Re: How to get buffer byte length (not number of characters)? Date: Wed, 21 Aug 2024 16:52:39 -0700 Message-ID: <871q2hfn7c.fsf@ushin.org> References: <87wmkbekjp.fsf@ushin.org> <86o75nwilg.fsf@gnu.org> <87bk1lhkvg.fsf@ushin.org> <86y14pu5rp.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="439"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, schwab@suse.de, adam@alphapapa.net To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Aug 22 05:11:42 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sgyEf-000AYa-LG for ged-emacs-devel@m.gmane-mx.org; Thu, 22 Aug 2024 05:11:42 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sgyDs-0000DA-SO; Wed, 21 Aug 2024 23:10:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sgv8H-0007Ts-0v for emacs-devel@gnu.org; Wed, 21 Aug 2024 19:52:53 -0400 Original-Received: from out-171.mta0.migadu.com ([2001:41d0:1004:224b::ab]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sgv8E-0006ds-01 for emacs-devel@gnu.org; Wed, 21 Aug 2024 19:52:52 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ushin.org; s=key1; t=1724284365; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1m96cRijIQiaLm0gai5NzbY93//iAM3L4DRBDWdFM4s=; b=lfpzR12U3MdlQravk5Cy7p/1d0SiwpT7VaRcWFWH0JkF5XFNwv71Ug3zojCe7gjyK+7ZF9 Hb0Oif2cgmfAeexvNblYKJMjn7e9hEp/42h1oA9WyT8+IWBLzFfnf+RuXCeMqUWiQ5+1dn REC1oLUmgqYKuf04vrcmNrtkEHoK5lJeHDjxHLiLn02/pG2B+56tn+yAXajYipSWyKJFQn 8ZENy2UZ+MybcdM10imfoq8+erlpc8iZgG83mZKCED8FidcihRO02gfDsoL49Knr3E1lbB BK+LhfG+8yqtOfnuR1aKCCPvZ5pEMfpLjDEFUpX8wJ4RCEAThxf2vvgMy1LgGA== In-Reply-To: <86y14pu5rp.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 21 Aug 2024 20:47:54 +0300") X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:1004:224b::ab; envelope-from=joseph@ushin.org; helo=out-171.mta0.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 21 Aug 2024 23:10:51 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:323033 Archived-At: Eli Zaretskii writes: >> From: Joseph Turner >> Cc: emacs-devel@gnu.org, Andreas Schwab , Adam Porter >> >> Date: Wed, 21 Aug 2024 02:20:09 -0700 >> >> Let's say I create a textual hyperdrive file using hyperdrive.el, and >> then I upload it by sending its contents via curl to the local HTTP >> server. What coding system should be used when the file is uploaded? >> >> Let's say I have a `iso-latin-1'-encoded file "foo.txt" on my local >> filesystem. I upload this encoded file to my hyperdrive by passing the >> filename to curl, which uploads the bytes with no conversion. Then I >> open the "foo.txt" hyperdrive file using hyperdrive.el, which receives >> the contents via curl from the local HTTP server. In the hyperdrive >> file buffer, buffer-file-coding-system should be `iso-latin-1' (right?). > > It's what I would expect, yes. But you can try it yourself, of course > and make sure it is indeed what happens. > >> Then, I edit the buffer and save it to the hyperdrive again with >> hyperdrive.el, which this time sends the modified contents over the wire >> to curl. The uploaded file should be `iso-latin-1'-encoded (right?). > > Again, that'd be my expectation. But it's better to test this > assumption. > >> Currently, plz.el always creates the curl subprocess like so: >> >> (make-process :coding 'binary ...) >> >> https://git.savannah.gnu.org/cgit/emacs/elpa.git/tree/plz.el?h=externals-release/plz#n519 >> >> Does this DTRT? > > It could be TRT if plz.el encodes the buffer text "by hand" before > sending the results to curl and decodes it when it receives text from > curl. Which I think is what happens there. plz.el does not manually encode buffer text *within Emacs* when sending requests to curl, but by default, plz.el sends data to curl with --data, which tells curl to strip CR and newlines. With the :body-type 'binary argument, plz.el instead uses --data-binary, which does no conversion. We don't want to strip newlines from hyperdrive files, so we always use :body-type 'binary when sending buffer contents. Should hyperdrive.el encode data with `buffer-file-coding-system' before passing to plz.el? When receiving text from curl, plz.el optionally decodes the text according to the charset in the 'Content-Type' header, e.g., "text/html; charset=utf-8" or utf-8 if no charset is found. Perhaps hyperdrive.el should check the 'Content-Type' header charset, then fallback to guessing the coding system based on filename and file contents with `set-auto-coding' (to avoid decoding images, etc.), and then finally fallback to something else? Thank you! Joseph