Skip to content

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

Closed
@dmitshur

Description

@dmitshur

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions