<div>Oh, many thanks, I prefer your solution ;)<br>
<br>
Greg</div><div><br>
<br>
Le lun. 29 juil. 2024 à 04:14, R. Matthew Emerson <<a href="mailto:rme@clozure.com" target="_blank">rme@clozure.com</a>> a écrit :<br>
><br>
><br>
><br>
> > On Jul 28, 2024, at 6:31 PM, Grégory Vanuxem <<a href="mailto:g.vanuxem@gmail.com" target="_blank">g.vanuxem@gmail.com</a>> wrote:<br>
> ><br>
> > Found!<br>
> ><br>
> > In level-0/l0-misc.lisp there is exactly what i was looking for.<br>
> > (ccl::%get-utf-8-cstring ..) It's a pity I think it is not documented<br>
> > since now UTF-8 is relatively widely used.<br>
> ><br>
> > All is right now!<br>
><br>
><br>
> The exported functionality is ccl:get-encoded-string.<br>
><br>
> (get-encoded-string :utf-8 cname (#_strlen cname))<br>
><br>
> <a href="https://ccl.clozure.com/docs/ccl.html#f_get-encoded-string" rel="noreferrer" target="_blank">https://ccl.clozure.com/docs/ccl.html#f_get-encoded-string</a><br>
><br>
> The manual also contains examples of using both ccl:with-encoded-cstrs and ccl:get-encoded-string:<br>
><br>
> <a href="https://ccl.clozure.com/docs/ccl.html#brief-examples" rel="noreferrer" target="_blank">https://ccl.clozure.com/docs/ccl.html#brief-examples</a><br>
><br>
><br>
><br>
> ><br>
> > Thanks<br>
> ><br>
> > Greg<br>
> ><br>
> > Le lun. 29 juil. 2024 à 01:34, Grégory Vanuxem <<a href="mailto:g.vanuxem@gmail.com" target="_blank">g.vanuxem@gmail.com</a>> a écrit :<br>
> >><br>
> >> Hello Matthew,<br>
> >><br>
> >> Le dim. 28 juil. 2024 à 07:31, R. Matthew Emerson <<a href="mailto:rme@clozure.com" target="_blank">rme@clozure.com</a>> a écrit :<br>
> >>><br>
> >>><br>
> >>><br>
> >>>> On Jul 27, 2024, at 8:23 PM, Grégory Vanuxem <<a href="mailto:g.vanuxem@gmail.com" target="_blank">g.vanuxem@gmail.com</a>> wrote:<br>
> >>>><br>
> >>>> In FriCAS  built on top of Clozure CL I obtain this output in a terminal (WSL2)<br>
> >>>><br>
> >>>> (gamma(x) Ã¢ÃÂàreals && Re(x) > 0) || (x Ã¢ÃÂàintegers &&<br>
> >>>> gamma(x) Ã¢ÃÂàreals)<br>
> >>>><br>
> >>>> instead of (SBCL)<br>
> >>>><br>
> >>>> (gamma(x) ∈ reals && Re(x) > 0) || (x ∉ integers && gamma(x) ∈ reals)<br>
> >>>><br>
> >>>> if I (print ...) a string with, for example, ∈, in a pure Clozure CL<br>
> >>>> (recently git cloned) this is correctly printed, no problem.<br>
> >>>><br>
> >>>> So I wonder if I have to modify the output stream character encoding<br>
> >>>> or the output routine.<br>
> >>><br>
> >>> Check that the external format of the FriCAS output stream is what you expect. In other words, if you pass an explicit :external-format argument to cl:open, make sure it matches what your terminal requires.<br>
> >><br>
> >> I don't think it is at this stage in fact, I was wrong. Better<br>
> >> checking what is going on, since the string comes from C (sorry I<br>
> >> forgot to mention that) I tend to think my problem comes from<br>
> >> ccl::%get-cstring. Tracing it seems to show it's not "decoding" it and<br>
> >> considers it as a 8859-1 string. But to test this i.e. force CCL to<br>
> >> use :utf8 format to "read it" I have not found. There is no option<br>
> >> from what I know to get-cstring like :external-format and using<br>
> >> with-encoded-cstrs does not seem to work.<br>
> >><br>
> >> Right now I am using some FFI macros from FriCAS to simplify my code,<br>
> >> I will try to revert to pure CCL code first to check my claims,<br>
> >> TIMTOWTDI.<br>
> >><br>
> >>> Doing (describe *terminal-io*) might show something interesting. Here’s what it shows for me:<br>
> >>><br>
> >>> ? (describe *terminal-io*)<br>
> >>> #<ECHOING-TWO-WAY-STREAM input #<BASIC-CHARACTER-INPUT-STREAM UTF-8 (TTY/0) #x1824C7D6>, output #<BASIC-CHARACTER-OUTPUT-STREAM UTF-8 (TTY/1) #x1824C2A6> #x1825FBE6><br>
> >>> Class: #<STANDARD-CLASS ECHOING-TWO-WAY-STREAM><br>
> >>> Wrapper: #<CLASS-WRAPPER ECHOING-TWO-WAY-STREAM #x18039A16><br>
> >>> Instance slots<br>
> >>> SHARED-RESOURCE: NIL<br>
> >>> OPEN-P: T<br>
> >>> INPUT-STREAM: #<BASIC-CHARACTER-INPUT-STREAM UTF-8 (TTY/0) #x1824C7D6><br>
> >>> OUTPUT-STREAM: #<BASIC-CHARACTER-OUTPUT-STREAM UTF-8 (TTY/1) #x1824C2A6><br>
> >>><br>
> >>> The default external format has been #<EXTERNAL-FORMAT :UTF-8/:UNIX #x18249C6E> for quite a long time now.<br>
> >>><br>
> >>> <a href="https://ccl.clozure.com/docs/ccl.html#characters-and-external-formats" rel="noreferrer" target="_blank">https://ccl.clozure.com/docs/ccl.html#characters-and-external-formats</a><br>
> >><br>
> >> This is exactly what I have when I use this function in FriCAS. I have<br>
> >> read the documentation and the internal utf32 representation but here<br>
> >> I am stuck. This is not the most important thing I need to do but it<br>
> >> will be imperative for some next stuff.<br>
> >><br>
> >> In anyway, thanks!<br>
> >><br>
> >> Greg<br>
> >><br>
> >>><br>
> >>>><br>
> >>>> And more importantly, how can I achieve that?<br>
> >>>><br>
> >>>> - Greg<br>
> >>>><br>
> >>>> PS:<br>
> >>>> (1) -> )lisp CCL:*DEFAULT-EXTERNAL-FORMAT*<br>
> >>>> Value = :UNIX<br>
> >>><br>
><br>
</div>