Skip to content

Unable to correctly handle certain unicode/utf-8 characters. #319

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

Closed
dmitshur opened this issue Oct 8, 2015 · 0 comments
Closed

Unable to correctly handle certain unicode/utf-8 characters. #319

dmitshur opened this issue Oct 8, 2015 · 0 comments

Comments

@dmitshur
Copy link
Member

dmitshur commented Oct 8, 2015

Go source code is Unicode text encoded in UTF-8. (Source.)

GopherJS fails to process some unicode characters in Go code and emits JavaScript that does not print the correct characters.

I think it fails on "astral planes", or unicode characters that require more than 2 bytes using utf-8 encoding. But this is just a hypothesis from limited evidence/investigation.

Compare:

console.log("Hello, 世界. 😀!"); // U+1F600 emoji.
package main

import "fmt"

func main() {
    fmt.Println("Hello, 世界. 😀!") // U+1F600 emoji.
}

https://play.golang.org/p/M1rXP8bm6L

http://www.gopherjs.org/playground/

(You'll have to manually paste the code into GopherJS Playground. Due to the bug in GopherJS, the snippet cannot be loaded correctly.)

image

image

Thank you to @peggyl for the original report of this issue at https://gist.github.com/peggyl/72d47f6652d30a4f566a!

Relevant Reading

This was referenced Oct 8, 2015
dmitshur added a commit that referenced this issue Oct 8, 2015
dmitshur added a commit to shurcooL/play that referenced this issue Oct 8, 2015
siongui added a commit to siongui/gopalilib that referenced this issue Jul 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant