On 31-May-05, at 9:14 AM, Dmitry Lizorkin wrote:
Hello!
I am working with Gambit interpreter, and the following result is unexpected for me:
(string (integer->char 127)) ==> "\177"
(string (integer->char 128)) ==> ""
(string (integer->char 256)) ==> "\x100"
I don't understand why the empty string is returned for an integer from the interval [128, 255].
Could you please exlpain this to me? What should I do to obtain the character that corresponds to an integer from the interval [128, 255]?
The string that is returned is of length 1 (it is not the empty string). It is just that the character (integer->char 128) has no graphic representation on your terminal. The Gambit runtime will use escapes for some characters (below 32, or = 127, or greater or equal to 256). In the next release I will bring the upper limit down to 128, so that the output of write is always ASCII characters that have a graphic representation. In the meantime you can do this:
(##vector-set! ##main-readtable 9 127)
#<readtable #25>
"\x80"
"\200"
Marc