From 9d2ef3ae156f06fd89291d4fe6edd4b806d40184 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Tue, 7 Mar 2006 19:56:25 +0000 Subject: [PATCH] Implement UTF8-STRING->STRING. --- v7/src/runtime/runtime.pkg | 3 ++- v7/src/runtime/unicode.scm | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/v7/src/runtime/runtime.pkg b/v7/src/runtime/runtime.pkg index e575a0e3e..ee20de1c1 100644 --- a/v7/src/runtime/runtime.pkg +++ b/v7/src/runtime/runtime.pkg @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: runtime.pkg,v 14.576 2006/03/07 06:40:24 cph Exp $ +$Id: runtime.pkg,v 14.577 2006/03/07 19:56:21 cph Exp $ Copyright 1988,1989,1990,1991,1992,1993 Massachusetts Institute of Technology Copyright 1994,1995,1996,1997,1998,1999 Massachusetts Institute of Technology @@ -4759,6 +4759,7 @@ USA. utf32-string-length utf32-string-valid? utf32-string? + utf8-string->string utf8-string->wide-string utf8-string-length utf8-string-valid? diff --git a/v7/src/runtime/unicode.scm b/v7/src/runtime/unicode.scm index 73308ec42..d670f6b9c 100644 --- a/v7/src/runtime/unicode.scm +++ b/v7/src/runtime/unicode.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: unicode.scm,v 1.25 2005/12/13 15:29:52 cph Exp $ +$Id: unicode.scm,v 1.26 2006/03/07 19:56:25 cph Exp $ Copyright 2001,2003,2004,2005 Massachusetts Institute of Technology @@ -1059,6 +1059,18 @@ USA. (fix:or #x80 (fix:and (vector-8b-ref string i) #x3F))) (loop (fix:+ i 1) (fix:+ i* 2)))))) string*))) + +(define (utf8-string->string string #!optional start end) + (let ((input (open-input-string string start end))) + (port/set-coding input 'UTF-8) + (call-with-output-string + (lambda (output) + (let loop () + (let ((c (read-char input))) + (if (not (eof-object? c)) + (begin + (write-char c output) + (loop))))))))) (define (validate-utf8-char string start end) -- 2.25.1