---------- Forwarded message ---------- From: Vijay Mathew vijay.the.lisper@gmail.com Date: Sun, Jun 26, 2016 at 10:51 AM Subject: Re: [gambit-list] Printing unicode characters in Gambit To: Adam adam.mlmb@gmail.com
Thanks Adam, will try what you suggested. But I really don't understand why a special switch is required to properly print Unicode characters. Even if the user is unaware of this, 'print' going into a loop is bad behavior.
--Vijay
On Jun 26, 2016 8:26 AM, "Adam" adam.mlmb@gmail.com wrote:
You need to switch on unicode output for the output medium (gsc -t8) and maybe also specify the maximum unicode character number that the writer will accept to write. Please report back when you figured.
2016-06-26 10:34 GMT+08:00 Vijay Mathew vijay.the.lisper@gmail.com:
How can I make gambit to print a Unicode character's symbol (or glyph)? For example, I want to display the Unicode infinity symbol ∞ (#\u221E). Calling `(display #\u221E)` or `(print #\u221E)` throws the REPL into an infinite loop. (This happens for most Unicode literals I tried, not just the infinity symbol :-))
$ gsc Gambit v4.8.4
(print #\u221E)
*** ERROR IN ##wr-ch -- Can't convert to C char-string (write-char #*** ERROR IN ##wr-ch -- Can't convert to C char-string (write-char #*** ERROR IN ##wr-ch -- Can't convert to C char-string (write-char #*** ERROR IN ##wr-ch -- Can't convert to C char-string (write-char #*** ERROR IN ##wr-ch -- Can't convert to C char-string
Thanks,
--- Vijay
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Afficher les réponses par date
Indeed the use of the -:t8 runtime option avoids this problem by allowing all Unicode characters to be output to the terminal. However, the REPL should not go into an infinite loop when it tries to display an error message containing a character beyond the highest character encodable by the terminal.
I found that the REPL’s implementation is using the idiom (##write-string (##object->string message) port) to output to the console the Scheme objects in error messages. But ##object->string does not know the limits of the character encoding of the port and can produce an output string with characters that can’t be encoded by the port. So I have added an argument to ##object->string to specify the character encoding limit and fixed the REPL’s implementation accordingly. The REPL now behaves properly:
% gsi Gambit v4.8.5
(println #\u221E)
*** ERROR IN ##wr-ch -- Can't convert to C char-string (write-char #\u221e '#<input-output-port #2 (console)>) 1>
and
% gsi -:t8 Gambit v4.8.5
(println #\u221E)
∞
Marc
On Jun 26, 2016, at 3:12 AM, Vijay Mathew vijay.the.lisper@gmail.com wrote:
---------- Forwarded message ---------- From: Vijay Mathew vijay.the.lisper@gmail.com Date: Sun, Jun 26, 2016 at 10:51 AM Subject: Re: [gambit-list] Printing unicode characters in Gambit To: Adam adam.mlmb@gmail.com
Thanks Adam, will try what you suggested. But I really don't understand why a special switch is required to properly print Unicode characters. Even if the user is unaware of this, 'print' going into a loop is bad behavior.
--Vijay
On Jun 26, 2016 8:26 AM, "Adam" adam.mlmb@gmail.com wrote: You need to switch on unicode output for the output medium (gsc -t8) and maybe also specify the maximum unicode character number that the writer will accept to write. Please report back when you figured.
2016-06-26 10:34 GMT+08:00 Vijay Mathew vijay.the.lisper@gmail.com: How can I make gambit to print a Unicode character's symbol (or glyph)? For example, I want to display the Unicode infinity symbol ∞ (#\u221E). Calling `(display #\u221E)` or `(print #\u221E)` throws the REPL into an infinite loop. (This happens for most Unicode literals I tried, not just the infinity symbol :-))
$ gsc Gambit v4.8.4
(print #\u221E)
*** ERROR IN ##wr-ch -- Can't convert to C char-string (write-char #*** ERROR IN ##wr-ch -- Can't convert to C char-string (write-char #*** ERROR IN ##wr-ch -- Can't convert to C char-string (write-char #*** ERROR IN ##wr-ch -- Can't convert to C char-string (write-char #*** ERROR IN ##wr-ch -- Can't convert to C char-string
Thanks,
--- Vijay
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Thanks Marc for that fix.
How can I configure the build so that the default encoding is always UTF-8? (So that the option -:t8 need not be explicitly passed.)
I guess, after `configure`, gambit.h should contain definitions like
``` #define ___FILE_SETTINGS_INITIAL ___CHAR_ENCODING_UTF_8 #define ___TERMINAL_SETTINGS_INITIAL ___CHAR_ENCODING_UTF_8 #define ___STDIO_SETTINGS_INITIAL ___CHAR_ENCODING_UTF_8 ```
Thanks,
--Vijay
On Sun, Jun 26, 2016 at 6:13 PM, Marc Feeley feeley@iro.umontreal.ca wrote:
Indeed the use of the -:t8 runtime option avoids this problem by allowing all Unicode characters to be output to the terminal. However, the REPL should not go into an infinite loop when it tries to display an error message containing a character beyond the highest character encodable by the terminal.
I found that the REPL’s implementation is using the idiom (##write-string (##object->string message) port) to output to the console the Scheme objects in error messages. But ##object->string does not know the limits of the character encoding of the port and can produce an output string with characters that can’t be encoded by the port. So I have added an argument to ##object->string to specify the character encoding limit and fixed the REPL’s implementation accordingly. The REPL now behaves properly:
% gsi Gambit v4.8.5
(println #\u221E)
*** ERROR IN ##wr-ch -- Can't convert to C char-string (write-char #\u221e '#<input-output-port #2 (console)>) 1>
and
% gsi -:t8 Gambit v4.8.5
(println #\u221E)
∞
Marc
On Jun 26, 2016, at 3:12 AM, Vijay Mathew vijay.the.lisper@gmail.com
wrote:
---------- Forwarded message ---------- From: Vijay Mathew vijay.the.lisper@gmail.com Date: Sun, Jun 26, 2016 at 10:51 AM Subject: Re: [gambit-list] Printing unicode characters in Gambit To: Adam adam.mlmb@gmail.com
Thanks Adam, will try what you suggested. But I really don't understand
why a special switch is required to properly print Unicode characters. Even if the user is unaware of this, 'print' going into a loop is bad behavior.
--Vijay
On Jun 26, 2016 8:26 AM, "Adam" adam.mlmb@gmail.com wrote: You need to switch on unicode output for the output medium (gsc -t8) and
maybe also specify the maximum unicode character number that the writer will accept to write. Please report back when you figured.
2016-06-26 10:34 GMT+08:00 Vijay Mathew vijay.the.lisper@gmail.com: How can I make gambit to print a Unicode character's symbol (or glyph)? For example, I want to display the Unicode infinity symbol ∞ (#\u221E). Calling `(display #\u221E)` or `(print #\u221E)` throws the REPL into an
infinite loop.
(This happens for most Unicode literals I tried, not just the infinity
symbol :-))
$ gsc Gambit v4.8.4
(print #\u221E)
*** ERROR IN ##wr-ch -- Can't convert to C char-string (write-char #*** ERROR IN ##wr-ch -- Can't convert to C char-string (write-char #*** ERROR IN ##wr-ch -- Can't convert to C char-string (write-char #*** ERROR IN ##wr-ch -- Can't convert to C char-string (write-char #*** ERROR IN ##wr-ch -- Can't convert to C char-string
Thanks,
--- Vijay
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Use the GAMBOPT environment variable to specify the default option you want, i.e.
% export GAMBOPT=t8 % gsi
will execute gsi as though you had entered
% gsi -:t8
Of course you should add that setting to your bashrc if you want it to persist.
Marc
On Jun 26, 2016, at 9:47 AM, Vijay Mathew vijay.the.lisper@gmail.com wrote:
Thanks Marc for that fix.
How can I configure the build so that the default encoding is always UTF-8? (So that the option -:t8 need not be explicitly passed.)
I guess, after `configure`, gambit.h should contain definitions like
#define ___FILE_SETTINGS_INITIAL ___CHAR_ENCODING_UTF_8 #define ___TERMINAL_SETTINGS_INITIAL ___CHAR_ENCODING_UTF_8 #define ___STDIO_SETTINGS_INITIAL ___CHAR_ENCODING_UTF_8
Thanks,
--Vijay
On Sun, Jun 26, 2016 at 6:13 PM, Marc Feeley feeley@iro.umontreal.ca wrote: Indeed the use of the -:t8 runtime option avoids this problem by allowing all Unicode characters to be output to the terminal. However, the REPL should not go into an infinite loop when it tries to display an error message containing a character beyond the highest character encodable by the terminal.
I found that the REPL’s implementation is using the idiom (##write-string (##object->string message) port) to output to the console the Scheme objects in error messages. But ##object->string does not know the limits of the character encoding of the port and can produce an output string with characters that can’t be encoded by the port. So I have added an argument to ##object->string to specify the character encoding limit and fixed the REPL’s implementation accordingly. The REPL now behaves properly:
% gsi Gambit v4.8.5
(println #\u221E)
*** ERROR IN ##wr-ch -- Can't convert to C char-string (write-char #\u221e '#<input-output-port #2 (console)>) 1>
and
% gsi -:t8 Gambit v4.8.5
(println #\u221E)
∞
Marc
On Jun 26, 2016, at 3:12 AM, Vijay Mathew vijay.the.lisper@gmail.com wrote:
---------- Forwarded message ---------- From: Vijay Mathew vijay.the.lisper@gmail.com Date: Sun, Jun 26, 2016 at 10:51 AM Subject: Re: [gambit-list] Printing unicode characters in Gambit To: Adam adam.mlmb@gmail.com
Thanks Adam, will try what you suggested. But I really don't understand why a special switch is required to properly print Unicode characters. Even if the user is unaware of this, 'print' going into a loop is bad behavior.
--Vijay
On Jun 26, 2016 8:26 AM, "Adam" adam.mlmb@gmail.com wrote: You need to switch on unicode output for the output medium (gsc -t8) and maybe also specify the maximum unicode character number that the writer will accept to write. Please report back when you figured.
2016-06-26 10:34 GMT+08:00 Vijay Mathew vijay.the.lisper@gmail.com: How can I make gambit to print a Unicode character's symbol (or glyph)? For example, I want to display the Unicode infinity symbol ∞ (#\u221E). Calling `(display #\u221E)` or `(print #\u221E)` throws the REPL into an infinite loop. (This happens for most Unicode literals I tried, not just the infinity symbol :-))
$ gsc Gambit v4.8.4
(print #\u221E)
*** ERROR IN ##wr-ch -- Can't convert to C char-string (write-char #*** ERROR IN ##wr-ch -- Can't convert to C char-string (write-char #*** ERROR IN ##wr-ch -- Can't convert to C char-string (write-char #*** ERROR IN ##wr-ch -- Can't convert to C char-string (write-char #*** ERROR IN ##wr-ch -- Can't convert to C char-string
Thanks,
--- Vijay
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list