<div dir="ltr">On Mon, Apr 1, 2013 at 12:31 AM, Matthew Flatt <span dir="ltr"><<a href="mailto:mflatt@cs.utah.edu" target="_blank">mflatt@cs.utah.edu</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5">At Tue, 26 Mar 2013 18:29:00 +0100, Pierpaolo Bernardi wrote:<br>
> On Tue, Mar 26, 2013 at 5:25 PM, Pierpaolo Bernardi <<a href="mailto:olopierpa@gmail.com">olopierpa@gmail.com</a>> wrote:<br>
> > On Tue, Mar 26, 2013 at 5:00 PM, Matthew Flatt <<a href="mailto:mflatt@cs.utah.edu">mflatt@cs.utah.edu</a>> wrote:<br>
> ><br>
> >> I think you want `reencode-output-port', probably using "" (which<br>
> >> represents the user's default encoding) as the target encoding.<br>
> ><br>
> > I tried the following:<br>
> ><br>
> > ====<br>
> > #lang racket<br>
> ><br>
> > (current-output-port (reencode-output-port (current-output-port) ""))<br>
> ><br>
> > (display "à")<br>
> > ====<br>
> ><br>
> > but this displays nothing both in DrRacket and in the console.<br>
> > Also "program >tempfile" from the console produces a file of length 0.<br>
><br>
> Adding a (flush-output) after the display makes it work from inside DrRacket.<br>
><br>
> In the console there's no change, and redirecting the output to a file<br>
> still produces a 0-length file, though.<br>
<br>
</div></div>Ok, while `reencode-output-port' might be the right direction, there<br>
are several complications:<br>
<br>
* On Windows, Racket uses UTF-8 for "". So, reencoding to "" doesn't<br>
do anything.<br>
<br>
That's the right choice for DrRacket, through, since DrRacket's<br>
interaction window uses UTF-8.<br>
<br>
* In a Windows console, the right encoding depends on how the console<br>
is configured. Use `chcp' to find out your code page. It will be a<br>
number N, and then the locale you want is "Windows-N".<br></blockquote><div><br></div><div style>I discovered that this would be too simple for microsoft. 8^)</div><div style><br></div><div style>The codepage that my system uses is 850, and the magic word is "ibm850"</div>
<div style>(from: <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756(v=vs.85).aspx">http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756(v=vs.85).aspx</a>)</div><div style><br></div><div style>
In the end, this works in my console:</div><div style>====<br></div><div style><div>#lang racket</div><div><br></div><div>(current-output-port </div><div> (reencode-output-port (current-output-port) "ibm850"))</div>
<div><br></div><div>(display "à")</div><div>(flush-output)</div><div>====<br></div><div><br></div><div style>But then, of course, it does not work in the DrRacket listener.</div><div style><br></div></div><div style>
<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
You could also set your console to UTF-8 with `chcp 65001', and then<br>
the console and DrRacket will work the same (as long as you also pick a<br>
suitable font in the console).<br></blockquote><div><br></div><div style>This would be the most rational solution (even microsoft agrees, in the page above!), but after 'chcp 65001' the console acts weirdly (lines are skipped at random, strings are displayed twice...), and it seems there's not an easy way to change the default console cp (here there are some infos, but not very reassuring: <a href="http://superuser.com/questions/269818/change-default-code-page-of-windows-console-to-utf-8">http://superuser.com/questions/269818/change-default-code-page-of-windows-console-to-utf-8</a>)</div>
<div style><br></div><div style>It seems that for now is still better to stick to ASCII if we need to write to the console. :(</div><div style><br></div><div style>Thanks!</div><div style>P.</div><div style><br></div></div>
</div></div>