...
1
2
3
4
5 package language
6
7
8 type CompactCoreInfo uint32
9
10
11
12 func GetCompactCore(t Tag) (cci CompactCoreInfo, ok bool) {
13 if t.LangID > langNoIndexOffset {
14 return 0, false
15 }
16 cci |= CompactCoreInfo(t.LangID) << (8 + 12)
17 cci |= CompactCoreInfo(t.ScriptID) << 12
18 cci |= CompactCoreInfo(t.RegionID)
19 return cci, true
20 }
21
22
23 func (c CompactCoreInfo) Tag() Tag {
24 return Tag{
25 LangID: Language(c >> 20),
26 RegionID: Region(c & 0x3ff),
27 ScriptID: Script(c>>12) & 0xff,
28 }
29 }
30
View as plain text