unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Chris Vine <chris@cvine.freeserve.co.uk>
To: Mike Gran <spk121@yahoo.com>
Cc: "mark@markwitmer.com" <mark@markwitmer.com>,
	"guile-user@gnu.org" <guile-user@gnu.org>
Subject: Re: Trouble w/sockets
Date: Sun, 3 Mar 2013 10:36:31 +0000	[thread overview]
Message-ID: <20130303103631.32f26e62@laptop.homenet> (raw)
In-Reply-To: <1362286125.99740.YahooMailNeo@web120403.mail.ne1.yahoo.com>

On Sat, 2 Mar 2013 20:48:45 -0800 (PST)
Mike Gran <spk121@yahoo.com> wrote:
[snip]
> The problem with `write-char' in Guile 2.0 is that it does all the
> conversion to the current locale.  So, once you start hitting the
> bytes greater than 127 in your string, `write-char' tries to convert
> each byte to something in your encoding.
> 
> If your encoding is "C" or anything that strictly uses ASCII as its
> character encoding, it'll throw an error when its trying to print any
> byte above 127.  If your encoding is UTF-8, those high bytes will
> become two byte strings.
> 
> Ideally you'd be able to use bytevectors or binary ports or some such.
> 
> But you can also fake it by setting the port encoding to ISO-8859-1.
> In that encoding the characters 0 to 255 map one-to-one with the bytes
> from 0 to 255.
> (set-port-encoding! sock "ISO-8859-1")

Whilst this seems to be a side issue with respect to the OP's
problem, with R6RS you can use the 'put-u8' procedure to write
individual octets to a binary port (and 'get-u8' to read them) [1].

I know guile-2.0 doesn't distinguish between text and binary ports, but
presumably these procedures work without causing the port to undertake
charset conversion otherwise they are useless.  For example, I notice
that a port created with the 'pipe' procedure reports itself as both a
binary port and a textual port if 'setlocale' has not been called, but
as a textual port only if (setlocale LC_ALL "") has been called.
However, this does not seem to mean anything: in either case put-u8 and
get-u8 appear to work correctly.

Chris

[1] A someone unfortunate choice of name.  Here u8 presumably means
unsigned octet, not UTF-8 as in C11 and C++11.



  parent reply	other threads:[~2013-03-03 10:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-03  3:38 Trouble w/sockets mark
2013-03-03  4:48 ` Mike Gran
2013-03-03  5:36   ` mark
2013-03-03  6:35     ` Mike Gran
2013-03-03  7:29     ` Thien-Thi Nguyen
2013-03-04  4:18       ` mark.d.witmer
2013-03-04  4:38         ` mark.d.witmer
2013-03-04 10:02         ` Thien-Thi Nguyen
2013-03-03 10:36   ` Chris Vine [this message]
2013-03-04 13:29     ` Ludovic Courtès

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=20130303103631.32f26e62@laptop.homenet \
    --to=chris@cvine.freeserve.co.uk \
    --cc=guile-user@gnu.org \
    --cc=mark@markwitmer.com \
    --cc=spk121@yahoo.com \
    /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).