From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: Decoding URLs input Date: Sat, 3 Jul 2021 18:10:47 +0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2891"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Help GNU Emacs To: Jean Louis Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 03 13:11:31 2021 Return-path: Envelope-to: geh-help-gnu-emacs@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 1lzdYZ-0000d9-GL for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 03 Jul 2021 13:11:31 +0200 Original-Received: from localhost ([::1]:48944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lzdYX-0006l9-NE for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 03 Jul 2021 07:11:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46602) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lzdY5-0006l0-IW for help-gnu-emacs@gnu.org; Sat, 03 Jul 2021 07:11:01 -0400 Original-Received: from mail-vs1-xe33.google.com ([2607:f8b0:4864:20::e33]:38652) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lzdY3-0002bx-R2 for help-gnu-emacs@gnu.org; Sat, 03 Jul 2021 07:11:01 -0400 Original-Received: by mail-vs1-xe33.google.com with SMTP id o7so7311236vss.5 for ; Sat, 03 Jul 2021 04:10:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=UROxzBGzMZpaib6CqK8+mXiyI9dh41HpqUIh3RIj2go=; b=b/ky+bIDhJRM/Shhh17feWtXwRMP1UmuuR3422fGmSqgm6O+loBFnJBTuSAua7GhKE wLY8mHSherY7WxtJtmA6lQk4T7NuVoWejj1uLP1qHnFTuwdG/fZ+XHqenZz+WX3vDyU1 vIteESw01ufnqz8w2X4O33gpSMgubRsfp0EdxwAGaG2ANeGQe+NlqDRevjI9sQrmgbT8 ZuP6bKFNJYlQW4gU5r14kOEhQyUYboLnJsQpYNA4w5ClcUdyh46HPrqIPvQ+Y/E4ZwP8 EILFDgi9L0k2xgX7aCdk5yr317vCd9ccfbn4sc42J9nuObVYPoQ+Its+gY6c/Ibpeppr PkeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=UROxzBGzMZpaib6CqK8+mXiyI9dh41HpqUIh3RIj2go=; b=j95bhujawA2z8kgLXsLKlmguhHxoqdkeibr13aWitk+qlC/KY57Gnw0Yt79mJGkn3P HG4RLwbzdEcKXgftvNZ/pIQx6FYZirIfyoZ/4rqagTxaw1GWViqofcyyRhO0IRaSIYVh vp4Z4Hjptjg1xtRUr97sPRexISMn/ZqJTPiHY6hrFBOOBinm3Do1huhJ8NDdFFXkiRit VBO04X/TPkNJn4RNPFBYobeIUMUOSyt2OZcK2IiKsmr2RN/H/x74lVScAYBjIwJlVn9k 09hJBjDEfhDCqKHl7VZJOiUTyR/0FMOZAQrHuhfNklcDVMDz5tb4goJuMMlsDdarWWzQ tRIg== X-Gm-Message-State: AOAM531AdWugduaWRXEBs9ym1YkFKhMMJG2n3Oyeg7tmQae8xsikx6Dz 3XQ86TP2MXtqtYD8AuJ2uEtHxzb/C9Z0WN5FuXc= X-Google-Smtp-Source: ABdhPJzFaOM6G/POxne0yabmPVCmGDKAlb9711ArhAvfkggkn0kPRJaICh9Wtf/NWmfJiyRSpyY0ENWIgJZP2Ag4Rwg= X-Received: by 2002:a67:8783:: with SMTP id j125mr3701194vsd.42.1625310658787; Sat, 03 Jul 2021 04:10:58 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::e33; envelope-from=yurivkhan@gmail.com; helo=mail-vs1-xe33.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:131435 Archived-At: On Sat, 3 Jul 2021 at 16:41, Jean Louis wrote: > As I am developing Double Opt-In CGI script served by Emacs I am > unsure if this function is correct to be used the encoded strings that > come from URL GET requests, like http://www.example.com/?message=3DHello%= 20There > > (rfc2231-decode-encoded-string "Hello%20there") =E2=87=92 "Hello there" > > If anybody knows or have clues, let me know. In other programming > languages I have not been thinking of RFC, I don't know which RFC > applies there. Why not look at the RFC referenced in order to see whether it is or is not relevant to your task? https://datatracker.ietf.org/doc/html/rfc2231 It talks about encoding MIME headers, which is not what you=E2=80=99re deal= ing with; and its encoded strings look like '', which is not what you have. What you are dealing with is a URL, specifically, its query string part. These are described in RFC 3986, and its percent-encoding scheme in sections 2.1 and 2.5. (url-unhex-string =E2=80=A6) will do half the work for you: It will decode percent-encoded sequences into bytes. By convention, in URLs, characters are UTF-8-encoded before percent-encoding (see RFC 3986 =C2=A7 2.5), so you=E2=80=99ll need to use: (decode-coding-string (url-unhex-string s) 'utf-8) to get a fully decoded text string.