From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chris Vine Newsgroups: gmane.lisp.guile.user Subject: Re: Trouble w/sockets Date: Sun, 3 Mar 2013 10:36:31 +0000 Message-ID: <20130303103631.32f26e62@laptop.homenet> References: <871ubxxie3.fsf@markwitmer.com> <1362286125.99740.YahooMailNeo@web120403.mail.ne1.yahoo.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1362307003 9037 80.91.229.3 (3 Mar 2013 10:36:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 3 Mar 2013 10:36:43 +0000 (UTC) Cc: "mark@markwitmer.com" , "guile-user@gnu.org" To: Mike Gran Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Mar 03 11:37:06 2013 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UC6Hy-0006Zg-Em for guile-user@m.gmane.org; Sun, 03 Mar 2013 11:37:06 +0100 Original-Received: from localhost ([::1]:33523 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UC6Hd-00058f-5D for guile-user@m.gmane.org; Sun, 03 Mar 2013 05:36:45 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:60897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UC6HU-00058P-Mm for guile-user@gnu.org; Sun, 03 Mar 2013 05:36:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UC6HT-0006F7-FK for guile-user@gnu.org; Sun, 03 Mar 2013 05:36:36 -0500 Original-Received: from avasout08.plus.net ([212.159.14.20]:58656) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UC6HT-0006Em-6p for guile-user@gnu.org; Sun, 03 Mar 2013 05:36:35 -0500 Original-Received: from laptop.homenet ([87.115.58.27]) by avasout08 with smtp id 6ycX1l0040bEtAn01ycYC9; Sun, 03 Mar 2013 10:36:32 +0000 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.0 cv=b6RsFK6x c=1 sm=1 a=WJRMs+V0pJ4E5qLh5r4pHQ==:17 a=a7_E5ZZ9eK8A:10 a=8nJEP1OIZ-IA:10 a=g_0wNEBgAAAA:8 a=EptUY7iHEiYA:10 a=CjxXgO3LAAAA:8 a=dweg8Ci28DBOdAXPX-0A:9 a=wPNLvfGTeEIA:10 a=rC2wZJ5BpNYA:10 a=WJRMs+V0pJ4E5qLh5r4pHQ==:117 Original-Received: from laptop.homenet (localhost [127.0.0.1]) by laptop.homenet (Postfix) with ESMTP id DA7AD540D31; Sun, 3 Mar 2013 10:36:32 +0000 (GMT) In-Reply-To: <1362286125.99740.YahooMailNeo@web120403.mail.ne1.yahoo.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.15; i686-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 212.159.14.20 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:10164 Archived-At: On Sat, 2 Mar 2013 20:48:45 -0800 (PST) Mike Gran wrote: [snip] > The problem with `write-char' in Guile 2.0 is that it does all the > conversion to the current locale.=A0 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. >=20 > 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.=A0 If your encoding is UTF-8, those high bytes will > become two byte strings. >=20 > Ideally you'd be able to use bytevectors or binary ports or some such. >=20 > 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.