[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 16/23: eports: add put-utf8-char, put-utf8-string
From: |
Andy Wingo |
Subject: |
[Guile-commits] 16/23: eports: add put-utf8-char, put-utf8-string |
Date: |
Thu, 24 Mar 2016 14:26:04 +0000 |
wingo pushed a commit to branch wip-ethreads
in repository guile.
commit f00836531282b66a30dfe9ae9ec6dca6b860d733
Author: Andy Wingo <address@hidden>
Date: Tue Mar 27 16:15:36 2012 +0200
eports: add put-utf8-char, put-utf8-string
* module/ice-9/eports.scm (put-latin1-string): Fix a bug.
(put-utf8-char, put-utf8-string): New functions.
---
module/ice-9/eports.scm | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/module/ice-9/eports.scm b/module/ice-9/eports.scm
index 2ca8656..c6300d3 100644
--- a/module/ice-9/eports.scm
+++ b/module/ice-9/eports.scm
@@ -55,7 +55,10 @@
get-latin1-string-n!
get-latin1-string-delimited
put-latin1-char
- put-latin1-string))
+ put-latin1-string
+
+ put-utf8-char
+ put-utf8-string))
(define-record-type <eport>
(make-eport fd readbuf writebuf file-port)
@@ -546,10 +549,18 @@
(define (put-latin1-string eport str)
(if (string-every (lambda (c) (< (char->integer c) 128)) str)
- (put-bytevector eport (string->utf8 eport))
+ (put-bytevector eport (string->utf8 str))
;; Need a string->latin1.
(let ((len (string-length str)))
(let lp ((n 0))
(when (< n len)
(put-u8 eport (char->integer (string-ref str n)))
(lp (1+ n)))))))
+
+(define (put-utf8-char eport c)
+ (if (< (char->integer c) 128)
+ (put-u8 eport (char->integer c))
+ (put-utf8-string eport (string c))))
+
+(define (put-utf8-string eport str)
+ (put-bytevector eport (string->utf8 str)))
- [Guile-commits] 19/23: nio: add non-blocking connect, (continued)
- [Guile-commits] 19/23: nio: add non-blocking connect, Andy Wingo, 2016/03/24
- [Guile-commits] 08/23: add #:limit to get-bytevector-delimited, Andy Wingo, 2016/03/24
- [Guile-commits] 11/23: socket: TCP_CORK, TCP_NODELAY, Andy Wingo, 2016/03/24
- [Guile-commits] 23/23: virtualize read/write/close operations in <eport>, Andy Wingo, 2016/03/24
- [Guile-commits] 15/23: (web server ethreads): more use of latin1 accessors, Andy Wingo, 2016/03/24
- [Guile-commits] 01/23: add (ice-9 nio), Andy Wingo, 2016/03/24
- [Guile-commits] 20/23: eports: nonblocking connect-eport, Andy Wingo, 2016/03/24
- [Guile-commits] 14/23: refactoring to (web server ethreads) read-http-line, Andy Wingo, 2016/03/24
- [Guile-commits] 02/23: add (ice-9 eports), Andy Wingo, 2016/03/24
- [Guile-commits] 17/23: getsockopt: allow raw file descriptors, Andy Wingo, 2016/03/24
- [Guile-commits] 16/23: eports: add put-utf8-char, put-utf8-string,
Andy Wingo <=
- [Guile-commits] 03/23: add (ice-9 epoll), Andy Wingo, 2016/03/24
- [Guile-commits] 21/23: eports tweak, Andy Wingo, 2016/03/24
- [Guile-commits] 07/23: add (web server ethreads), Andy Wingo, 2016/03/24
- [Guile-commits] 22/23: add examples/ethreads/memcached-{client, server}, Andy Wingo, 2016/03/24