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

x/text: Get unicode script name in addition to script code #31862

Open
jeremieSimon opened this issue May 6, 2019 · 1 comment
Open

x/text: Get unicode script name in addition to script code #31862

jeremieSimon opened this issue May 6, 2019 · 1 comment

Comments

@jeremieSimon
Copy link

@jeremieSimon jeremieSimon commented May 6, 2019

What version of Go are you using (go version)?

$ go version = 1.12.4

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env GOARCH="amd64"
GOBIN="/Users/user/dev/apl/pp/parsec/fed/_vendor/bin"
GOCACHE="/Users/user/go/cache"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/user/dev/apl/pp/parsec/fed:/Users/user/dev/apl/pp/parsec/fed/_vendor"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.4/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wm/mbpr1q9j5vsb67r0yn4zl4m40000gn/T/go-build893585754=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I want to get the RangeTable of a script given a specific language.

import (
    "golang.org/x/text/language"
    "unicode"
)

...

script, confidence := language.French.Script() 
scriptAsString := script.String() // here scriptAsString = "Latn"
rangeTable, ok := unicode.Scripts[scriptAsString] // here ok = false, because the Scripts map has key "Latin" and not "Latn"

The problem is that the following function returns the script code
func (s Script) String() string

Whereas the map unicode.Scripts has all of its keys using the script name

FIY: https://en.wikipedia.org/wiki/ISO_15924#List_of_codes

What did you expect to see?

I would expect one of those:

  1. Be able to get a script name in addition to get the script code.
  2. Have a translation table between script code and script name
  3. Have a map unicode.Scripts that goes from script code to RangeTable

Open thread on stack overflow here:
https://stackoverflow.com/questions/56003838/get-unicode-script-name-in-go

@jeremieSimon jeremieSimon changed the title Get unicode script name in addition to script code [x/text] Get unicode script name in addition to script code May 6, 2019
@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented May 6, 2019

CC @mpvl

@bradfitz bradfitz changed the title [x/text] Get unicode script name in addition to script code x/text: Get unicode script name in addition to script code May 6, 2019
@gopherbot gopherbot added this to the Unreleased milestone May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.