// findIndex tries to find the given tag in idx and returns a standardized error // if it could not be found. func findIndex(idx tag.Index, key []byte, form string) (index int, err error) { … } func searchUint(imap []uint16, key uint16) int { … } type Language … // getLangID returns the langID of s if s is a canonical subtag // or langUnknown if s is not a canonical subtag. func getLangID(s []byte) (Language, error) { … } func (id Language) Canonicalize() (Language, AliasType) { … } // normLang returns the mapped langID of id according to mapping m. func normLang(id Language) (Language, AliasType) { … } // getLangISO2 returns the langID for the given 2-letter ISO language code // or unknownLang if this does not exist. func getLangISO2(s []byte) (Language, error) { … } const base … func strToInt(s []byte) uint { … } // converts the given integer to the original ASCII string passed to strToInt. // len(s) must match the number of characters obtained. func intToStr(v uint, s []byte) { … } // getLangISO3 returns the langID for the given 3-letter ISO language code // or unknownLang if this does not exist. func getLangISO3(s []byte) (Language, error) { … } // StringToBuf writes the string to b and returns the number of bytes // written. cap(b) must be >= 3. func (id Language) StringToBuf(b []byte) int { … } // String returns the BCP 47 representation of the langID. // Use b as variable name, instead of id, to ensure the variable // used is consistent with that of Base in which this type is embedded. func (b Language) String() string { … } // ISO3 returns the ISO 639-3 language code. func (b Language) ISO3() string { … } // IsPrivateUse reports whether this language code is reserved for private use. func (b Language) IsPrivateUse() bool { … } // SuppressScript returns the script marked as SuppressScript in the IANA // language tag repository, or 0 if there is no such script. func (b Language) SuppressScript() Script { … } type Region … // getRegionID returns the region id for s if s is a valid 2-letter region code // or unknownRegion. func getRegionID(s []byte) (Region, error) { … } // getRegionISO2 returns the regionID for the given 2-letter ISO country code // or unknownRegion if this does not exist. func getRegionISO2(s []byte) (Region, error) { … } // getRegionISO3 returns the regionID for the given 3-letter ISO country code // or unknownRegion if this does not exist. func getRegionISO3(s []byte) (Region, error) { … } func getRegionM49(n int) (Region, error) { … } // normRegion returns a region if r is deprecated or 0 otherwise. // TODO: consider supporting BYS (-> BLR), CSK (-> 200 or CZ), PHI (-> PHL) and AFI (-> DJ). // TODO: consider mapping split up regions to new most populous one (like CLDR). func normRegion(r Region) Region { … } const iso3166UserAssigned … const ccTLD … const bcp47Region … func (r Region) typ() byte { … } // String returns the BCP 47 representation for the region. // It returns "ZZ" for an unspecified region. func (r Region) String() string { … } // ISO3 returns the 3-letter ISO code of r. // Note that not all regions have a 3-letter ISO code. // In such cases this method returns "ZZZ". func (r Region) ISO3() string { … } // M49 returns the UN M.49 encoding of r, or 0 if this encoding // is not defined for r. func (r Region) M49() int { … } // IsPrivateUse reports whether r has the ISO 3166 User-assigned status. This // may include private-use tags that are assigned by CLDR and used in this // implementation. So IsPrivateUse and IsCountry can be simultaneously true. func (r Region) IsPrivateUse() bool { … } type Script … // getScriptID returns the script id for string s. It assumes that s // is of the format [A-Z][a-z]{3}. func getScriptID(idx tag.Index, s []byte) (Script, error) { … } // String returns the script code in title case. // It returns "Zzzz" for an unspecified script. func (s Script) String() string { … } // IsPrivateUse reports whether this script code is reserved for private use. func (s Script) IsPrivateUse() bool { … } const maxAltTaglen … const maxLen … var grandfatheredMap … var altTagIndex … var altTags … func grandfathered(s [maxAltTaglen]byte) (t Tag, ok bool) { … }