[plt-scheme] mzchar and wchar_t

From: Jean-Guillaume (gogomille at yahoo.fr)
Date: Wed Mar 15 13:00:39 EST 2006

Le 15 mars 06 à 14:13, Matthew Flatt a écrit :
> At Tue, 14 Mar 2006 15:55:54 -0800, "Jim Blandy" wrote:
>> On 3/14/06, Matthew Flatt <mflatt at cs.utah.edu> wrote:
>>> At Tue, 14 Mar 2006 12:36:05 +0100, Jean-Guillaume wrote:
>>>> Is there a simple relation between mzchar and wchar_t (and wint_t)
>>>> types ?
>>>
>>> If you have a wchar_t whose value that is in [0, #xD7FF] or [#xE000,
>>> #xFFFF], then you can use it as a mzchar and vice-versa.
>>>
>>> [...]

Thanks, the following code *seems* to work (with some silly example- 
characters such as à é è...). But do you mean it can be unsafe for  
some unicode values ? Maybe it works incidentaly because I set my  
locale to utf-8 ?



// This is part of a mzscheme extension for handling none(-pure)  
ASCII characters
// in the terminal (ncurses doesn't seem to work and I don't like it  
anyway).

#include <wchar.h>

// man getwchar
// Standard C library :
// wint_t getwchar()
static Scheme_Object *sch_getwchar(int argc, Scheme_Object **argv) {
     wchar_t w;
     w = getwchar();
     return scheme_make_character(w);}

// man wcwidth
// Standard C library :
// int wcwidth(wchar_t wc)
static Scheme_Object *sch_wcwidth(int argc, Scheme_Object **argv) {
     mzchar c = SCHEME_CHAR_VAL(argv[0]);
     int lg = wcwidth(c);
     return scheme_make_integer(lg);
}


	

	
		
___________________________________________________________________________ 
Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
Téléchargez sur http://fr.messenger.yahoo.com


Posted on the users mailing list.