1 // Copyright 2018 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 // CompactCoreInfo is a compact integer with the three core tags encoded.
8 type CompactCoreInfo uint32
10 // GetCompactCore generates a uint32 value that is guaranteed to be unique for
11 // different language, region, and script values.
12 func GetCompactCore(t Tag) (cci CompactCoreInfo, ok bool) {
13 if t.LangID > langNoIndexOffset {
16 cci |= CompactCoreInfo(t.LangID) << (8 + 12)
17 cci |= CompactCoreInfo(t.ScriptID) << 12
18 cci |= CompactCoreInfo(t.RegionID)
22 // Tag generates a tag from c.
23 func (c CompactCoreInfo) Tag() Tag {
25 LangID: Language(c >> 20),
26 RegionID: Region(c & 0x3ff),
27 ScriptID: Script(c>>12) & 0xff,