Path: blob/main/vendor/golang.org/x/text/internal/language/compact.go
2893 views
// Copyright 2018 The Go Authors. All rights reserved.1// Use of this source code is governed by a BSD-style2// license that can be found in the LICENSE file.34package language56// CompactCoreInfo is a compact integer with the three core tags encoded.7type CompactCoreInfo uint3289// GetCompactCore generates a uint32 value that is guaranteed to be unique for10// different language, region, and script values.11func GetCompactCore(t Tag) (cci CompactCoreInfo, ok bool) {12if t.LangID > langNoIndexOffset {13return 0, false14}15cci |= CompactCoreInfo(t.LangID) << (8 + 12)16cci |= CompactCoreInfo(t.ScriptID) << 1217cci |= CompactCoreInfo(t.RegionID)18return cci, true19}2021// Tag generates a tag from c.22func (c CompactCoreInfo) Tag() Tag {23return Tag{24LangID: Language(c >> 20),25RegionID: Region(c & 0x3ff),26ScriptID: Script(c>>12) & 0xff,27}28}293031