unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: <tomas@tuxteam.de>
To: guile-user@gnu.org
Subject: Re: http-client port encoding failed
Date: Sat, 5 Sep 2020 10:55:52 +0200	[thread overview]
Message-ID: <20200905085552.GA12516@tuxteam.de> (raw)
In-Reply-To: <20200904143545.Horde.ifPsqyXMMJ1PsdBw6X4d2Fh@www.stihie.net>

[-- Attachment #1: Type: text/plain, Size: 1558 bytes --]

On Fri, Sep 04, 2020 at 02:35:45PM -0500, mbcladwell@stihie.net wrote:
> 
> Hi,
> 
> I am using http-client to submit requests that contain extended
> Latin characters e.g. "Marjanović+Ž".  I believe I have locales set
> up properly as I don't receive the "can't set locales" error.  Also
> I can regex with the extended Latin characters.
> 
> scheme@(guile-user)> (locale-encoding)
> $11 = "UTF-8"
> 
>  When I submit a url containing the above Serbian name, I get the error:
> 
> Throw to key `encoding-error' with args `("put-char" "conversion to
> port encoding failed" 84 #<input-output: string 7febcf44c2a0> #\ć)'.

I'm not sure and can't double-check at the moment, but: the HTTP header
part (and the URL is part of it) /must/ be 7 bit ASCII. That's why there
is that URL encoding [1] -- basically you take the UTF-8 encoded string
and represent every byte (octet) beyond 0x7f (and some "hot" bytes
beneath that) by %<xx>, where <xx> is the hexadecimal representation
of that byte.

Perhaps you have to URL-encode your URL before "submitting" it.

> If I paste the URL into my browser I receive the correct response.

Your browser does all of the above for you. It just doesn't tell you :)

> Prior to the request I use (set-port-encoding! (current-output-port)
> "UTF-8") without effect.

Hm. I don't know what the "right" encoding for a HTTP connection
is. But the HTTP header part is 7 biz ASCII (which is a subset
of UTF-8, but just that :)

The quintessence is: try url-encoding your URL.

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2020-09-05  8:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-04 19:35 http-client port encoding failed mbcladwell
2020-09-05  8:55 ` tomas [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-09-08 14:26 mbcladwell
2020-09-08 14:33 ` tomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200905085552.GA12516@tuxteam.de \
    --to=tomas@tuxteam.de \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).