This commit is contained in:
github-actions[bot]
2022-08-04 06:59:33 +00:00
commit ca571eb691
415 changed files with 125430 additions and 0 deletions

62
tools/mktable.go Normal file
View File

@@ -0,0 +1,62 @@
// Copyright 2013 <chaishushan{AT}gmail.com>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build ingore
package main
import (
"bufio"
"bytes"
"fmt"
"io/ioutil"
"log"
"os"
"strings"
"unicode/utf8"
)
func main() {
f, err := os.Open("./TSCharacters.txt")
if err != nil {
log.Fatal("open failed:", err)
}
defer f.Close()
br := bufio.NewReader(f)
var out bytes.Buffer
fmt.Fprintf(&out, `
// Copyright 2013 <chaishushan{AT}gmail.com>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Auto generated by go generate, DO NOT EDIT !!!
package main
var _TSCharactersMap = map[rune]rune{
`[1:])
for i := 0; i < 1<<20; i++ {
data, isPrefix, err := br.ReadLine()
if err != nil || isPrefix {
break
}
if !utf8.ValidString(string(data)) {
continue
}
line := strings.Replace(string(data), "\t", " ", -1)
ss := strings.Split(string(line), " ")
if len(ss) >= 2 {
tw := strings.TrimSpace(ss[0])
zh := strings.TrimSpace(ss[1])
fmt.Fprintf(&out, "\t'%s': '%s',\n", tw, zh)
}
}
fmt.Fprintf(&out, "}\n")
ioutil.WriteFile("z_TSCharacters.go", []byte(out.Bytes()), 0666)
}