chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: utf8 printing problem


From: Mátyás Seress
Subject: Re: utf8 printing problem
Date: Sat, 23 Jul 2022 20:40:35 +0200

Yep, you were right. It indeed had to do with the code page that the Windows command prompt uses by default which is code page 437. And the reason why the equivalent C# program worked, is because when it executes it automatically changes the code page of the terminal to utf-8 which is code page 65001. After that, if I execute the chicken test, it works perfectly. So now I learned something.

Thanks for the help!

Op za 23 jul. 2022 om 20:04 schreef Mario Domenech Goulart <mario@parenteses.org>:
Hi Mátyás,

On Sat, 23 Jul 2022 11:13:39 +0200 Mátyás Seress <serimatyi@gmail.com> wrote:

> I wanted to try out printing some utf8 text to the console, but I ran into some issues. This is my program:
>
> (import utf8)
> (print "őŐűŰ")
>
> And when I run it on the command line with
>
> csi test-utf.scm
>
> then I get this output:
>
> CHICKEN
> (c) 2008-2019, The CHICKEN Team
> (c) 2000-2007, Felix L. Winkelmann
> Version 5.1.0 (rev 8e62f718)
> mingw32-windows-gnu-x86 [ dload ptables ]
>
> ; loading test-utf.scm ...
> ; loading c:/chicken/lib/chicken/11/utf8.import.so ...
>
<snip>
> ; loading c:/chicken/lib/chicken/11/utf8.so ...
> ; loading c:/chicken/lib/chicken/11/regex.so ...
> ; loading c:/chicken/lib/chicken/11/utf8-lolevel.so ...
> őŐűŰ
>
> As you can see, it prints ┼æ┼É┼▒┼░ instead of őŐűŰ. When I write a
> similar program in C# it does it correctly by default. It seems that
> the (import utf8) has no effect at all, because if I comment out the
> (import utf8) line and run it, then I get the same exact weird output.
>
> What am I doing wrong? How can I properly work with strings that
> contain non-English characters? (Btw the file is saved with UTF-8
> encoding and I'm using Windows.)

I cannot reproduce that problem with CHICKEN 5.3 on Debian.

  $ cat u.scm
  (import utf8)
  (print "őŐűŰ")

  $ csi -s u.scm
  őŐűŰ

Isn't the problem related to your terminal?  Maybe redirect the output
of your program to a file and open it in an editor that supports UTF-8
to see if the problem persists.

All the best.
Mario
--
http://parenteses.org/mario


reply via email to

[Prev in Thread] Current Thread [Next in Thread]