Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: print, println and panic always write utf-8 on windows #7864

Closed
gopherbot opened this issue Apr 25, 2014 · 13 comments
Closed

runtime: print, println and panic always write utf-8 on windows #7864

gopherbot opened this issue Apr 25, 2014 · 13 comments

Comments

@gopherbot
Copy link
Contributor

by zr95.vip:

What does 'go version' print?
go version go1.2.1 windows/amd64

What steps reproduce the problem?
If possible, include a link to a program on play.golang.org.

1. Write a program that passes a string with non-Ascii characters to print, println or
panic.

package main

import "fmt"

func main() {
    fmt.Println("Hello, 世界")
    println("Hello, 世界")
    panic("Hello, 世界")
}

2. Run the program in Windows console.

What happened?

It prints

Hello, 世界
Hello, 世界
panic: Hello, 世界

goroutine 1 [running]:
runtime.panic(0x41f7a0, 0xc084006040)
        C:/Users/ADMINI~1/AppData/Local/Temp/2/makerelease250988475/go/src/pkg/runtime/panic.c:266 +0xc8
main.main()
        c:/a.go:6 +0x93

What should have happened instead?

The first three lines of the output should be:

Hello, 世界
Hello, 世界
panic: Hello, 世界

Please provide any additional information below.

The code page is cp437. Output may be different with other code page.

fmt.Println did the right thing, so print and println can be (and should be) avoided.

But how about panic?
@minux
Copy link
Member

minux commented Apr 25, 2014

Comment 1:

It's possible to fix this, but it will complicate the runtime a lot
with not a lot of benefit (workaround is that you always redirect
the stderr to a file and view it with utf-8 capable tools)
basically, before we write to stderr, we need to determine if it's a
terminal or not, and use WriteConsole or WriteFile respectively
(Like what we did for the os package).
This kind of change is too late for 1.3, mark this issue for 1.4.

Labels changed: added release-go1.4, repo-main.

Status changed to Accepted.

@minux
Copy link
Member

minux commented Apr 25, 2014

Comment 2:

Labels changed: added os-windows.

@rsc
Copy link
Contributor

rsc commented Oct 3, 2014

Comment 3:

Labels changed: added release-go1.5, removed release-go1.4.

@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014
@rsc rsc added OS-Windows and removed os-windows labels Apr 10, 2015
@rsc rsc modified the milestones: Go1.6Early, Go1.5 Jul 21, 2015
@kardianos
Copy link
Contributor

@gopherbot
Copy link
Contributor Author

CL https://golang.org/cl/16714 mentions this issue.

@rsc rsc closed this as completed in d958881 Nov 12, 2015
@techtonik
Copy link

It is said in https://groups.google.com/forum/#!msg/golang-codereviews/hq63SCACMJo/KL97UzWeEQAJ that windows console is extremely slow. Have you got FPS improvements after switching to WriteConsole?

@kardianos
Copy link
Contributor

The windows console is slow to display chars. Different pipe. I was just saying if println and panic take a few ms longer, it probably won't be the bottleneck.

@alexbrainman
Copy link
Member

@techtonik I don't see how speed of println and panic is important.

Alex

@techtonik
Copy link

Do you have any tests to measure FPS and compare between Windows console and Linux? This ASCII Madness II runs at 60 FPS on average on my machine, and what means slow for you?

@techtonik
Copy link

It is important because people are now using https://groups.google.com/forum/#!msg/golang-codereviews/hq63SCACMJo/KL97UzWeEQAJ as a proof that Windows console is extremely slow compared to Linux and I find my experience with Gnome terminal completely opposite.

@kardianos
Copy link
Contributor

That is irrelevant to this issue. Feel free to open a topic on go-nuts
however. This issue only addresses the builtin println and panic functions.

On Tue, Nov 17, 2015 at 3:28 PM anatoly techtonik notifications@github.com
wrote:

Do you have any comparison/tests to measure FPS and compare between
Windows console and Linux? This ASCII Madness II
http://www.pouet.net/prod.php?which=18381 runs at 60 FPS on average on
my machine, and what means slow for you?


Reply to this email directly or view it on GitHub
#7864 (comment).

@techtonik
Copy link

Here is the thread that is still important for this project #13104 (comment)

@alexbrainman
Copy link
Member

I am confused now. But, @techtonik , never mind that. I am easily confused. If you have some problem feel free to open new issue. Let's not continue here. Thank you.

Alex

@golang golang locked and limited conversation to collaborators Nov 16, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants