This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Swedish Characters in the Scala REPL on Windows 7 cmd

6 replies
bjornr
Joined: 2011-11-28,
User offline. Last seen 35 weeks 5 days ago.

I have struggled for a while to get Swedish Characters to work in the
Scala REPL using the cmd command window in Windows 7.

Two problems:
1) When I write small letters åäö and ÖÄ in the REPL they print
correctly, BUT the "Å" letter prints a "?" - this seems to be a
strange inconsistency with only one letter not working... Is it a bug
in the REPL or what am I doing wrong?
2) When I compile code with Swedish Characters in a string in a UTF-8
encoded file, import the package in the scala REPL then it prints like
uggly escape sequences.

I have tried to start the scala REPL using
> scala -Dfile.encoding="UTF-8"
but it does not help.

I have tried starting the cmd window with the /u option for UTF-8
encoding but that does not help either.

This is a show stopper for my project so I really would appreciate
some hints on how to read and print Swedish characters from streams
and in the REPL on Windows 7.

/Bjorn

bjornr
Joined: 2011-11-28,
User offline. Last seen 35 weeks 5 days ago.
Re: Swedish Characters in the Scala REPL on Windows 7 cmd

Hi again folks.

I found a partial work-around for the string printing after some
exhaustive web searching :-)
At the windows cmd prompt write:
> chcp 1252
to change the active code page
and then start the scala REPL
> scala
Now imported strings with "ÅÄÖåäö" can be printed correctly :-)

HOWEVER; the letter "Å" is still echoed as a "?" in the REPL when
entered at the scala prompt :-(
It looks like a bug to me in the character mappings, or am I just
missing something?

/Bjorn

On Nov 28, 4:31 pm, Bjorn Regnell wrote:
> I have struggled for a while to get Swedish Characters to work in the
> Scala REPL using the cmd command window in Windows 7.
>
> Two problems:
> 1) When I write small letters åäö and ÖÄ in the REPL they print
> correctly, BUT the "Å" letter prints a "?" - this seems to be a
> strange inconsistency with only one letter not working... Is it a bug
> in the REPL or what am I doing wrong?
> 2) When I compile code with Swedish Characters in a string in a UTF-8
> encoded file, import the package in the scala REPL then it prints like
> uggly escape sequences.
>
> I have tried to start the scala REPL using> scala -Dfile.encoding="UTF-8"
>
> but it does not help.
>
> I have tried starting the cmd window with the /u option for UTF-8
> encoding but that does not help either.
>
> This is a show stopper for my project so I really would appreciate
> some hints on how to read and print Swedish characters from streams
> and in the REPL on Windows 7.
>
> /Bjorn

vpatryshev
Joined: 2009-02-16,
User offline. Last seen 1 year 24 weeks ago.
Re: Re: Swedish Characters in the Scala REPL on Windows 7 cmd
So this seems to be a specific windows console issue. Or rather not an issue but a feature, a tradition in Windows. In my Ubuntu it's utf8 by default:

scala> val x="фигасе"
x: java.lang.String = фигасе

scala> val y = "letters åäö and ÖÄ in the REPL "
y: java.lang.String = "letters åäö and ÖÄ in the REPL "


Thanks,
-Vlad


On Mon, Nov 28, 2011 at 8:01 AM, Bjorn Regnell <bjorn.regnell@cs.lth.se> wrote:
Hi again folks.

I found a partial work-around for the string printing after some
exhaustive web searching :-)
At the windows cmd prompt write:
> chcp 1252
to change the active code page
and then start the scala REPL
> scala
Now imported strings with "ÅÄÖåäö" can be printed correctly :-)

HOWEVER; the letter "Å" is still echoed as a "?" in the REPL when
entered at the scala prompt :-(
It  looks like a bug to me in the character mappings, or am I just
missing something?

/Bjorn

On Nov 28, 4:31 pm, Bjorn Regnell <bjorn.regn...@cs.lth.se> wrote:
> I have struggled for a while to get Swedish Characters to work in the
> Scala REPL using the cmd command window in Windows 7.
>
> Two problems:
> 1) When I write small letters åäö and ÖÄ in the REPL they print
> correctly, BUT the "Å" letter prints a "?" - this seems to be a
> strange inconsistency with only one letter not working... Is it a bug
> in the REPL or what am I doing wrong?
> 2) When I compile code with Swedish Characters in a string in a UTF-8
> encoded file, import the package in the scala REPL then it prints like
> uggly escape sequences.
>
> I have tried to start the scala REPL using> scala -Dfile.encoding="UTF-8"
>
> but it does not help.
>
> I have tried starting the cmd window with the /u option for UTF-8
> encoding but that does not help either.
>
> This is a show stopper for my project so I really would appreciate
> some hints on how to read and print Swedish characters from streams
> and in the REPL on Windows 7.
>
> /Bjorn

bjornr
Joined: 2011-11-28,
User offline. Last seen 35 weeks 5 days ago.
Re: Swedish Characters in the Scala REPL on Windows 7 cmd

I'm unfortunately stuck with Windows...
Can you also press the Å button and get an A with a ring over?
That is the one character that is not working, and that is really
strange because if Ä and Ö works, so should Å...
/Bjorn

On Nov 28, 5:11 pm, Vlad Patryshev wrote:
> So this seems to be a specific windows console issue. Or rather not an
> issue but a feature, a tradition in Windows. In my Ubuntu it's utf8 by
> default:
>
> scala> val x="фигасе"
> x: java.lang.String = фигасе
>
> scala> val y = "letters åäö and ÖÄ in the REPL "
> y: java.lang.String = "letters åäö and ÖÄ in the REPL "
>
> Thanks,
> -Vlad
>
> On Mon, Nov 28, 2011 at 8:01 AM, Bjorn Regnell wrote:
>
>
>
>
>
>
>
> > Hi again folks.
>
> > I found a partial work-around for the string printing after some
> > exhaustive web searching :-)
> > At the windows cmd prompt write:
> > > chcp 1252
> > to change the active code page
> > and then start the scala REPL
> > > scala
> > Now imported strings with "ÅÄÖåäö" can be printed correctly :-)
>
> > HOWEVER; the letter "Å" is still echoed as a "?" in the REPL when
> > entered at the scala prompt :-(
> > It  looks like a bug to me in the character mappings, or am I just
> > missing something?
>
> > /Bjorn
>
> > On Nov 28, 4:31 pm, Bjorn Regnell wrote:
> > > I have struggled for a while to get Swedish Characters to work in the
> > > Scala REPL using the cmd command window in Windows 7.
>
> > > Two problems:
> > > 1) When I write small letters åäö and ÖÄ in the REPL they print
> > > correctly, BUT the "Å" letter prints a "?" - this seems to be a
> > > strange inconsistency with only one letter not working... Is it a bug
> > > in the REPL or what am I doing wrong?
> > > 2) When I compile code with Swedish Characters in a string in a UTF-8
> > > encoded file, import the package in the scala REPL then it prints like
> > > uggly escape sequences.
>
> > > I have tried to start the scala REPL using> scala -Dfile.encoding="UTF-8"
>
> > > but it does not help.
>
> > > I have tried starting the cmd window with the /u option for UTF-8
> > > encoding but that does not help either.
>
> > > This is a show stopper for my project so I really would appreciate
> > > some hints on how to read and print Swedish characters from streams
> > > and in the REPL on Windows 7.
>
> > > /Bjorn

Kevin Wright 2
Joined: 2010-05-30,
User offline. Last seen 26 weeks 4 days ago.
Re: Swedish Characters in the Scala REPL on Windows 7 cmd
There's always the native RXVT client available via cygwin, or perhaps a virtual machine (I find VirtualBox works best here, thanks to the "seamless windowing" capability)


On Monday, 28 November 2011, Bjorn Regnell wrote:
I'm unfortunately stuck with Windows...
Can you also press the Å button and get an A with a ring over?
That is the one character that is not working, and that is really
strange because if Ä and Ö works, so should Å...
/Bjorn

On Nov 28, 5:11 pm, Vlad Patryshev <vpatrys...@gmail.com> wrote:
> So this seems to be a specific windows console issue. Or rather not an
> issue but a feature, a tradition in Windows. In my Ubuntu it's utf8 by
> default:
>
> scala> val x="фигасе"
> x: java.lang.String = фигасе
>
> scala> val y = "letters åäö and ÖÄ in the REPL "
> y: java.lang.String = "letters åäö and ÖÄ in the REPL "
>
> Thanks,
> -Vlad
>
> On Mon, Nov 28, 2011 at 8:01 AM, Bjorn Regnell <bjorn.regn...@cs.lth.se>wrote:
>
>
>
>
>
>
>
> > Hi again folks.
>
> > I found a partial work-around for the string printing after some
> > exhaustive web searching :-)
> > At the windows cmd prompt write:
> > > chcp 1252
> > to change the active code page
> > and then start the scala REPL
> > > scala
> > Now imported strings with "ÅÄÖåäö" can be printed correctly :-)
>
> > HOWEVER; the letter "Å" is still echoed as a "?" in the REPL when
> > entered at the scala prompt :-(
> > It  looks like a bug to me in the character mappings, or am I just
> > missing something?
>
> > /Bjorn
>
> > On Nov 28, 4:31 pm, Bjorn Regnell <bjorn.regn...@cs.lth.se> wrote:
> > > I have struggled for a while to get Swedish Characters to work in the
> > > Scala REPL using the cmd command window in Windows 7.
>
> > > Two problems:
> > > 1) When I write small letters åäö and ÖÄ in the REPL they print
> > > correctly, BUT the "Å" letter prints a "?" - this seems to be a
> > > strange inconsistency with only one letter not working... Is it a bug
> > > in the REPL or what am I doing wrong?
> > > 2) When I compile code with Swedish Characters in a string in a UTF-8
> > > encoded file, import the package in the scala REPL then it prints like
> > > uggly escape sequences.
>
> > > I have tried to start the scala REPL using> scala -Dfile.encoding="UTF-8"
>
> > > but it does not help.
>
> > > I have tried starting the cmd window with the /u option for UTF-8
> > > encoding but that does not help either.
>
> > > This is a show stopper for my project so I really would appreciate
> > > some hints on how to read and print Swedish characters from streams
> > > and in the REPL on Windows 7.
>
> > > /Bjorn


--
Kevin Wright
mail: kevin.wright@scalatechnology.com
gtalk / msn : kev.lee.wright@gmail.com quora: http://www.quora.com/Kevin-Wrightgoogle+: http://gplus.to/thecoda
kev.lee.wright@gmail.com twitter: @thecoda
vibe / skype: kev.lee.wrightsteam: kev_lee_wright
"My point today is that, if we wish to count lines of code, we should not regard them as "lines produced" but as "lines spent": the current conventional wisdom is so foolish as to book that count on the wrong side of the ledger" ~ Dijkstra
bjornr
Joined: 2011-11-28,
User offline. Last seen 35 weeks 5 days ago.
Re: Swedish Characters in the Scala REPL on Windows 7 cmd

Thanks for the info, Kevin and Vlad. I will try to install cygwin
eventually.

The windows command for changing the coding page e.g.:
> chcp 1252
should go to the FAQ of how to run scala on Windows with other
character codings than ANSI;
perhaps someone from the Scala team sees this and think it is useful
to put on the Windows pages.
/Bjorn

On Nov 28, 8:59 pm, Kevin Wright wrote:
> There's always the native RXVT client available via cygwin, or perhaps a
> virtual machine (I find VirtualBox works best here, thanks to the "seamless
> windowing" capability)
>
>
>
>
>
>
>
>
>
> On Monday, 28 November 2011, Bjorn Regnell wrote:
> > I'm unfortunately stuck with Windows...
> > Can you also press the Å button and get an A with a ring over?
> > That is the one character that is not working, and that is really
> > strange because if Ä and Ö works, so should Å...
> > /Bjorn
>
> > On Nov 28, 5:11 pm, Vlad Patryshev >
> > wrote:
> > > So this seems to be a specific windows console issue. Or rather not an
> > > issue but a feature, a tradition in Windows. In my Ubuntu it's utf8 by
> > > default:
>
> > > scala> val x="фигасе"
> > > x: java.lang.String = фигасе
>
> > > scala> val y = "letters åäö and ÖÄ in the REPL "
> > > y: java.lang.String = "letters åäö and ÖÄ in the REPL "
>
> > > Thanks,
> > > -Vlad
>
> > > On Mon, Nov 28, 2011 at 8:01 AM, Bjorn Regnell
> > >wrote:
>
> > > > Hi again folks.
>
> > > > I found a partial work-around for the string printing after some
> > > > exhaustive web searching :-)
> > > > At the windows cmd prompt write:
> > > > > chcp 1252
> > > > to change the active code page
> > > > and then start the scala REPL
> > > > > scala
> > > > Now imported strings with "ÅÄÖåäö" can be printed correctly :-)
>
> > > > HOWEVER; the letter "Å" is still echoed as a "?" in the REPL when
> > > > entered at the scala prompt :-(
> > > > It  looks like a bug to me in the character mappings, or am I just
> > > > missing something?
>
> > > > /Bjorn
>
> > > > On Nov 28, 4:31 pm, Bjorn Regnell >
> > wrote:
> > > > > I have struggled for a while to get Swedish Characters to work in the
> > > > > Scala REPL using the cmd command window in Windows 7.
>
> > > > > Two problems:
> > > > > 1) When I write small letters åäö and ÖÄ in the REPL they print
> > > > > correctly, BUT the "Å" letter prints a "?" - this seems to be a
> > > > > strange inconsistency with only one letter not working... Is it a bug
> > > > > in the REPL or what am I doing wrong?
> > > > > 2) When I compile code with Swedish Characters in a string in a UTF-8
> > > > > encoded file, import the package in the scala REPL then it prints
> > like
> > > > > uggly escape sequences.
>
> > > > > I have tried to start the scala REPL using> scala
> > -Dfile.encoding="UTF-8"
>
> > > > > but it does not help.
>
> > > > > I have tried starting the cmd window with the /u option for UTF-8
> > > > > encoding but that does not help either.
>
> > > > > This is a show stopper for my project so I really would appreciate
> > > > > some hints on how to read and print Swedish characters from streams
> > > > > and in the REPL on Windows 7.
>
> > > > > /Bjorn
>
> --
> Kevin Wright
> mail: kevin.wri...@scalatechnology.com
> gtalk / msn : kev.lee.wri...@gmail.com
> quora:http://www.quora.com/Kevin-Wright
> google+:http://gplus.to/thecoda
>
> twitter: @thecoda
> vibe / skype: kev.lee.wright
> steam: kev_lee_wright
>
> "My point today is that, if we wish to count lines of code, we should not
> regard them as "lines produced" but as "lines spent": the current
> conventional wisdom is so foolish as to book that count on the wrong side
> of the ledger" ~ Dijkstra

Stefan Zeiger
Joined: 2008-12-21,
User offline. Last seen 27 weeks 4 days ago.
Re: Re: Swedish Characters in the Scala REPL on Windows 7 cmd

On 2011-11-28 17:01, Bjorn Regnell wrote:
> Hi again folks.
>
> I found a partial work-around for the string printing after some
> exhaustive web searching :-)
> At the windows cmd prompt write:
>> chcp 1252
> to change the active code page
> and then start the scala REPL
>> scala
> Now imported strings with "ÅÄÖåäö" can be printed correctly :-)
>
> HOWEVER; the letter "Å" is still echoed as a "?" in the REPL when
> entered at the scala prompt :-(
> It looks like a bug to me in the character mappings, or am I just
> missing something?

Are you sure the codepage change worked? I can reproduce the problem
with the default codepage 437 (on my US-English Windows 7). I assume
it's caused by Java using Cp1252 instead of the actual Cp437 (and
scala's -J option does not work on Windows, so you cannot easily change
the encoding that way). If I chcp the console to 1252, it works fine.

Cheers,
Stefan

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland