feat: geo ip.
This commit is contained in:
@@ -3,11 +3,14 @@ package qqwry
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"regexp"
|
||||
|
||||
"golang.org/x/text/encoding/simplifiedchinese"
|
||||
"golang.org/x/text/transform"
|
||||
)
|
||||
|
||||
var regSpiltAddress = regexp.MustCompile(`.+?(省|市|自治区|自治州|盟|县|区|管委会|街道|镇|乡)`)
|
||||
|
||||
func gb18030Decode(src []byte) string {
|
||||
in := bytes.NewReader(src)
|
||||
out := transform.NewReader(in, simplifiedchinese.GB18030.NewDecoder())
|
||||
@@ -26,3 +29,7 @@ func byte3ToUInt32(data []byte) uint32 {
|
||||
i |= (uint32(data[2]) << 16) & 0xff0000
|
||||
return i
|
||||
}
|
||||
|
||||
func SpiltAddress(addr string) []string {
|
||||
return regSpiltAddress.FindAllString(addr, -1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user