No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
753 changed files with 76 additions and 473112 deletions
-
45.drone.yml
-
33.gitea/workflows/release-tag.yml
-
43.gitea/workflows/test.yml
-
26vendor/gitea.com/lunny/log/.gitignore
-
27vendor/gitea.com/lunny/log/LICENSE
-
51vendor/gitea.com/lunny/log/README.md
-
54vendor/gitea.com/lunny/log/README_CN.md
-
36vendor/gitea.com/lunny/log/dbwriter.go
-
112vendor/gitea.com/lunny/log/filewriter.go
-
5vendor/gitea.com/lunny/log/go.mod
-
2vendor/gitea.com/lunny/log/go.sum
-
595vendor/gitea.com/lunny/log/logext.go
-
674vendor/github.com/ahl5esoft/golang-underscore/LICENSE
-
1121vendor/github.com/ahl5esoft/golang-underscore/README.md
-
17vendor/github.com/ahl5esoft/golang-underscore/aggregate.go
-
25vendor/github.com/ahl5esoft/golang-underscore/all.go
-
25vendor/github.com/ahl5esoft/golang-underscore/any.go
-
76vendor/github.com/ahl5esoft/golang-underscore/chain.go
-
11vendor/github.com/ahl5esoft/golang-underscore/count.go
-
44vendor/github.com/ahl5esoft/golang-underscore/distinct.go
-
14vendor/github.com/ahl5esoft/golang-underscore/each.go
-
9vendor/github.com/ahl5esoft/golang-underscore/enumerable.go
-
25vendor/github.com/ahl5esoft/golang-underscore/enumerator.go
-
7vendor/github.com/ahl5esoft/golang-underscore/facade.go
-
9vendor/github.com/ahl5esoft/golang-underscore/filter.go
-
28vendor/github.com/ahl5esoft/golang-underscore/find-index.go
-
27vendor/github.com/ahl5esoft/golang-underscore/find.go
-
12vendor/github.com/ahl5esoft/golang-underscore/first.go
-
53vendor/github.com/ahl5esoft/golang-underscore/group.go
-
46vendor/github.com/ahl5esoft/golang-underscore/i-enumerable.go
-
10vendor/github.com/ahl5esoft/golang-underscore/i-enumerator.go
-
31vendor/github.com/ahl5esoft/golang-underscore/index.go
-
9vendor/github.com/ahl5esoft/golang-underscore/is-array.go
-
12vendor/github.com/ahl5esoft/golang-underscore/is-match.go
-
23vendor/github.com/ahl5esoft/golang-underscore/keys.go
-
1vendor/github.com/ahl5esoft/golang-underscore/last.go
-
9vendor/github.com/ahl5esoft/golang-underscore/map-many.go
-
9vendor/github.com/ahl5esoft/golang-underscore/map.go
-
25vendor/github.com/ahl5esoft/golang-underscore/null-enumerator.go
-
21vendor/github.com/ahl5esoft/golang-underscore/object.go
-
44vendor/github.com/ahl5esoft/golang-underscore/property.go
-
6vendor/github.com/ahl5esoft/golang-underscore/query.go
-
34vendor/github.com/ahl5esoft/golang-underscore/range.go
-
5vendor/github.com/ahl5esoft/golang-underscore/reduce.go
-
1vendor/github.com/ahl5esoft/golang-underscore/reject.go
-
1vendor/github.com/ahl5esoft/golang-underscore/reverse.go
-
45vendor/github.com/ahl5esoft/golang-underscore/select-many.go
-
31vendor/github.com/ahl5esoft/golang-underscore/select.go
-
5vendor/github.com/ahl5esoft/golang-underscore/size.go
-
26vendor/github.com/ahl5esoft/golang-underscore/skip.go
-
1vendor/github.com/ahl5esoft/golang-underscore/sort.go
-
26vendor/github.com/ahl5esoft/golang-underscore/take.go
-
9vendor/github.com/ahl5esoft/golang-underscore/uniq.go
-
29vendor/github.com/ahl5esoft/golang-underscore/util.go
-
44vendor/github.com/ahl5esoft/golang-underscore/value.go
-
23vendor/github.com/ahl5esoft/golang-underscore/values.go
-
16vendor/github.com/ahl5esoft/golang-underscore/variable.go
-
31vendor/github.com/ahl5esoft/golang-underscore/where.go
-
15vendor/github.com/davecgh/go-spew/LICENSE
-
145vendor/github.com/davecgh/go-spew/spew/bypass.go
-
38vendor/github.com/davecgh/go-spew/spew/bypasssafe.go
-
341vendor/github.com/davecgh/go-spew/spew/common.go
-
306vendor/github.com/davecgh/go-spew/spew/config.go
-
211vendor/github.com/davecgh/go-spew/spew/doc.go
-
509vendor/github.com/davecgh/go-spew/spew/dump.go
-
419vendor/github.com/davecgh/go-spew/spew/format.go
-
148vendor/github.com/davecgh/go-spew/spew/spew.go
-
8vendor/github.com/denisenkom/go-mssqldb/.gitignore
-
10vendor/github.com/denisenkom/go-mssqldb/.golangci.yml
-
27vendor/github.com/denisenkom/go-mssqldb/LICENSE.txt
-
309vendor/github.com/denisenkom/go-mssqldb/README.md
-
30vendor/github.com/denisenkom/go-mssqldb/accesstokenconnector.go
-
68vendor/github.com/denisenkom/go-mssqldb/appveyor.yml
-
271vendor/github.com/denisenkom/go-mssqldb/buf.go
-
588vendor/github.com/denisenkom/go-mssqldb/bulkcopy.go
-
93vendor/github.com/denisenkom/go-mssqldb/bulkcopy_sql.go
-
500vendor/github.com/denisenkom/go-mssqldb/conn_str.go
-
306vendor/github.com/denisenkom/go-mssqldb/convert.go
-
14vendor/github.com/denisenkom/go-mssqldb/doc.go
-
73vendor/github.com/denisenkom/go-mssqldb/error.go
-
82vendor/github.com/denisenkom/go-mssqldb/fedauth.go
-
8vendor/github.com/denisenkom/go-mssqldb/go.mod
-
5vendor/github.com/denisenkom/go-mssqldb/go.sum
-
113vendor/github.com/denisenkom/go-mssqldb/internal/cp/charset.go
-
20vendor/github.com/denisenkom/go-mssqldb/internal/cp/collation.go
-
262vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1250.go
-
262vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1251.go
-
262vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1252.go
-
262vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1253.go
-
262vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1254.go
-
262vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1255.go
-
262vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1256.go
-
262vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1257.go
-
262vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp1258.go
-
262vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp437.go
-
262vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp850.go
-
262vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp874.go
-
7988vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp932.go
-
22055vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp936.go
-
17312vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp949.go
@ -1,45 +0,0 @@ |
|||||
--- |
|
||||
kind: pipeline |
|
||||
name: testing |
|
||||
trigger: |
|
||||
event: |
|
||||
- push |
|
||||
- pull_request |
|
||||
|
|
||||
steps: |
|
||||
- name: test |
|
||||
image: golang:1.15 |
|
||||
commands: |
|
||||
- go build -mod=vendor |
|
||||
- go test -mod=vendor -v -race -coverprofile=coverage.txt -covermode=atomic ./... |
|
||||
|
|
||||
--- |
|
||||
kind: pipeline |
|
||||
name: release-tag |
|
||||
trigger: |
|
||||
event: |
|
||||
- tag |
|
||||
depends_on: |
|
||||
- testing |
|
||||
|
|
||||
steps: |
|
||||
- name: release-build |
|
||||
pull: always |
|
||||
image: golang:1.15 |
|
||||
commands: |
|
||||
- go build -mod=vendor -ldflags="-s -w -X 'main.Version=${DRONE_TAG}'" -o bin/reverse-${DRONE_TAG}-linux-amd64 |
|
||||
- GOOS=windows GOARCH=amd64 go build -mod=vendor -ldflags="-s -w -X 'main.Version=${DRONE_TAG}'" -o bin/reverse-${DRONE_TAG}-windows-amd64.exe |
|
||||
- GOOS=darwin GOARCH=amd64 go build -mod=vendor -ldflags="-s -w -X 'main.Version=${DRONE_TAG}'" -o bin/reverse-${DRONE_TAG}-darwin-amd64 |
|
||||
environment: |
|
||||
GO111MODULE: on |
|
||||
|
|
||||
- name: release-tag-gitea |
|
||||
pull: always |
|
||||
image: plugins/gitea-release:latest |
|
||||
settings: |
|
||||
files: |
|
||||
- "bin/*" |
|
||||
base_url: https://gitea.com |
|
||||
title: '${DRONE_TAG} is released' |
|
||||
api_key: |
|
||||
from_secret: gitea_token |
|
@ -0,0 +1,33 @@ |
|||||
|
name: goreleaser |
||||
|
|
||||
|
on: |
||||
|
push: |
||||
|
tags: |
||||
|
- '*' |
||||
|
|
||||
|
jobs: |
||||
|
goreleaser: |
||||
|
runs-on: ubuntu-latest |
||||
|
steps: |
||||
|
- uses: actions/checkout@v3 |
||||
|
with: |
||||
|
fetch-depth: 0 |
||||
|
- run: git fetch --force --tags |
||||
|
- name: setup go |
||||
|
uses: https://github.com/actions/setup-go@v4 |
||||
|
with: |
||||
|
go-version: '>=1.20.1' |
||||
|
- run: make generate |
||||
|
- name: release-build |
||||
|
run: go build -mod=vendor -ldflags="-s -w -X 'main.Version=${DRONE_TAG}'" -o bin/reverse-${DRONE_TAG}-linux-amd64 |
||||
|
- name: release-build-windows |
||||
|
run: GOOS=windows GOARCH=amd64 go build -mod=vendor -ldflags="-s -w -X 'main.Version=${DRONE_TAG}'" -o bin/reverse-${DRONE_TAG}-windows-amd64.exe |
||||
|
- name: release-build-darwin |
||||
|
run: GOOS=darwin GOARCH=amd64 go build -mod=vendor -ldflags="-s -w -X 'main.Version=${DRONE_TAG}'" -o bin/reverse-${DRONE_TAG}-darwin-amd64 |
||||
|
- name: Use Go Action |
||||
|
id: use-go-action |
||||
|
uses: actions/release-action@main |
||||
|
with: |
||||
|
files: |- |
||||
|
bin/** |
||||
|
api_key: '${{secrets.RELEASE_TOKEN}}' |
@ -0,0 +1,43 @@ |
|||||
|
name: checks |
||||
|
on: |
||||
|
- push |
||||
|
- pull_request |
||||
|
|
||||
|
env: |
||||
|
GOPROXY: https://goproxy.io,direct |
||||
|
GOPATH: /go_path |
||||
|
GOCACHE: /go_cache |
||||
|
|
||||
|
jobs: |
||||
|
lint: |
||||
|
name: check and test |
||||
|
runs-on: ubuntu-latest |
||||
|
steps: |
||||
|
- name: cache go path |
||||
|
id: cache-go-path |
||||
|
uses: https://github.com/actions/cache@v3 |
||||
|
with: |
||||
|
path: /go_path |
||||
|
key: go_path-${{ github.repository }}-${{ github.ref_name }} |
||||
|
restore-keys: | |
||||
|
go_path-${{ github.repository }}- |
||||
|
go_path- |
||||
|
- name: cache go cache |
||||
|
id: cache-go-cache |
||||
|
uses: https://github.com/actions/cache@v3 |
||||
|
with: |
||||
|
path: /go_cache |
||||
|
key: go_cache-${{ github.repository }}-${{ github.ref_name }} |
||||
|
restore-keys: | |
||||
|
go_cache-${{ github.repository }}- |
||||
|
go_cache- |
||||
|
- uses: actions/setup-go@v3 |
||||
|
with: |
||||
|
go-version: 1.20 |
||||
|
- uses: actions/checkout@v3 |
||||
|
- name: lint |
||||
|
run: go install golang.org/x/lint/golint@latest && golint ./... |
||||
|
- name: vet |
||||
|
run: go vet |
||||
|
- name: test |
||||
|
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... |
@ -1,26 +0,0 @@ |
|||||
# Compiled Object files, Static and Dynamic libs (Shared Objects) |
|
||||
*.o |
|
||||
*.a |
|
||||
*.so |
|
||||
|
|
||||
# Folders |
|
||||
_obj |
|
||||
_test |
|
||||
|
|
||||
# Architecture specific extensions/prefixes |
|
||||
*.[568vq] |
|
||||
[568vq].out |
|
||||
|
|
||||
*.cgo1.go |
|
||||
*.cgo2.c |
|
||||
_cgo_defun.c |
|
||||
_cgo_gotypes.go |
|
||||
_cgo_export.* |
|
||||
|
|
||||
_testmain.go |
|
||||
|
|
||||
*.exe |
|
||||
log.db |
|
||||
*.log |
|
||||
logs |
|
||||
.vscode |
|
@ -1,27 +0,0 @@ |
|||||
Copyright (c) 2014 - 2016 lunny |
|
||||
All rights reserved. |
|
||||
|
|
||||
Redistribution and use in source and binary forms, with or without |
|
||||
modification, are permitted provided that the following conditions are met: |
|
||||
|
|
||||
* Redistributions of source code must retain the above copyright notice, this |
|
||||
list of conditions and the following disclaimer. |
|
||||
|
|
||||
* Redistributions in binary form must reproduce the above copyright notice, |
|
||||
this list of conditions and the following disclaimer in the documentation |
|
||||
and/or other materials provided with the distribution. |
|
||||
|
|
||||
* Neither the name of the {organization} nor the names of its |
|
||||
contributors may be used to endorse or promote products derived from |
|
||||
this software without specific prior written permission. |
|
||||
|
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
@ -1,51 +0,0 @@ |
|||||
## log |
|
||||
|
|
||||
[](https://goreportcard.com/report/gitea.com/lunny/log) |
|
||||
[](https://godoc.org/gitea.com/lunny/log) |
|
||||
|
|
||||
[简体中文](https://gitea.com/lunny/log/blob/master/README_CN.md) |
|
||||
|
|
||||
# Installation |
|
||||
|
|
||||
``` |
|
||||
go get gitea.com/lunny/log |
|
||||
``` |
|
||||
|
|
||||
# Features |
|
||||
|
|
||||
* Add color support for unix console |
|
||||
* Implemented dbwriter to save log to database |
|
||||
* Implemented FileWriter to save log to file by date or time. |
|
||||
* Location configuration |
|
||||
|
|
||||
# Example |
|
||||
|
|
||||
For Single File: |
|
||||
```Go |
|
||||
f, _ := os.Create("my.log") |
|
||||
log.Std.SetOutput(f) |
|
||||
``` |
|
||||
|
|
||||
For Multiple Writer: |
|
||||
```Go |
|
||||
f, _ := os.Create("my.log") |
|
||||
log.Std.SetOutput(io.MultiWriter(f, os.Stdout)) |
|
||||
``` |
|
||||
|
|
||||
For log files by date or time: |
|
||||
```Go |
|
||||
w := log.NewFileWriter(log.FileOptions{ |
|
||||
ByType:log.ByDay, |
|
||||
Dir:"./logs", |
|
||||
}) |
|
||||
log.Std.SetOutput(w) |
|
||||
``` |
|
||||
|
|
||||
# About |
|
||||
|
|
||||
This repo is an extension of Golang log. |
|
||||
|
|
||||
# LICENSE |
|
||||
|
|
||||
BSD License |
|
||||
[http://creativecommons.org/licenses/BSD/](http://creativecommons.org/licenses/BSD/) |
|
@ -1,54 +0,0 @@ |
|||||
## log |
|
||||
|
|
||||
[](https://goreportcard.com/report/gitea.com/lunny/log) |
|
||||
[](https://godoc.org/gitea.com/lunny/log) |
|
||||
|
|
||||
[English](https://gitea.com/lunny/log/blob/master/README.md) |
|
||||
|
|
||||
# 安装 |
|
||||
|
|
||||
``` |
|
||||
go get gitea.com/lunny/log |
|
||||
``` |
|
||||
|
|
||||
# 特性 |
|
||||
|
|
||||
* 对unix增加控制台颜色支持 |
|
||||
* 实现了保存log到数据库支持 |
|
||||
* 实现了保存log到按日期的文件支持 |
|
||||
* 实现了设置日期的地区 |
|
||||
|
|
||||
# 例子 |
|
||||
|
|
||||
保存到单个文件: |
|
||||
|
|
||||
```Go |
|
||||
f, _ := os.Create("my.log") |
|
||||
log.Std.SetOutput(f) |
|
||||
``` |
|
||||
|
|
||||
保存到数据库: |
|
||||
|
|
||||
```Go |
|
||||
f, _ := os.Create("my.log") |
|
||||
log.Std.SetOutput(io.MultiWriter(f, os.Stdout)) |
|
||||
``` |
|
||||
|
|
||||
保存到按时间分隔的文件: |
|
||||
|
|
||||
```Go |
|
||||
w := log.NewFileWriter(log.FileOptions{ |
|
||||
ByType:log.ByDay, |
|
||||
Dir:"./logs", |
|
||||
}) |
|
||||
log.Std.SetOutput(w) |
|
||||
``` |
|
||||
|
|
||||
# 关于 |
|
||||
|
|
||||
本 Log 是在 golang 的 log 之上的扩展 |
|
||||
|
|
||||
# LICENSE |
|
||||
|
|
||||
BSD License |
|
||||
[http://creativecommons.org/licenses/BSD/](http://creativecommons.org/licenses/BSD/) |
|
@ -1,36 +0,0 @@ |
|||||
package log |
|
||||
|
|
||||
import ( |
|
||||
"database/sql" |
|
||||
"time" |
|
||||
) |
|
||||
|
|
||||
type DBWriter struct { |
|
||||
db *sql.DB |
|
||||
stmt *sql.Stmt |
|
||||
content chan []byte |
|
||||
} |
|
||||
|
|
||||
func NewDBWriter(db *sql.DB) (*DBWriter, error) { |
|
||||
_, err := db.Exec("CREATE TABLE IF NOT EXISTS log (id int, content text, created datetime)") |
|
||||
if err != nil { |
|
||||
return nil, err |
|
||||
} |
|
||||
stmt, err := db.Prepare("INSERT INTO log (content, created) values (?, ?)") |
|
||||
if err != nil { |
|
||||
return nil, err |
|
||||
} |
|
||||
return &DBWriter{db, stmt, make(chan []byte, 1000)}, nil |
|
||||
} |
|
||||
|
|
||||
func (w *DBWriter) Write(p []byte) (n int, err error) { |
|
||||
_, err = w.stmt.Exec(string(p), time.Now()) |
|
||||
if err == nil { |
|
||||
n = len(p) |
|
||||
} |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
func (w *DBWriter) Close() { |
|
||||
w.stmt.Close() |
|
||||
} |
|
@ -1,112 +0,0 @@ |
|||||
package log |
|
||||
|
|
||||
import ( |
|
||||
"io" |
|
||||
"os" |
|
||||
"path/filepath" |
|
||||
"sync" |
|
||||
"time" |
|
||||
) |
|
||||
|
|
||||
var _ io.Writer = &Files{} |
|
||||
|
|
||||
type ByType int |
|
||||
|
|
||||
const ( |
|
||||
ByDay ByType = iota |
|
||||
ByHour |
|
||||
ByMonth |
|
||||
) |
|
||||
|
|
||||
var ( |
|
||||
formats = map[ByType]string{ |
|
||||
ByDay: "2006-01-02", |
|
||||
ByHour: "2006-01-02-15", |
|
||||
ByMonth: "2006-01", |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
func SetFileFormat(t ByType, format string) { |
|
||||
formats[t] = format |
|
||||
} |
|
||||
|
|
||||
func (b ByType) Format() string { |
|
||||
return formats[b] |
|
||||
} |
|
||||
|
|
||||
type Files struct { |
|
||||
FileOptions |
|
||||
f *os.File |
|
||||
lastFormat string |
|
||||
lock sync.Mutex |
|
||||
} |
|
||||
|
|
||||
type FileOptions struct { |
|
||||
Dir string |
|
||||
ByType ByType |
|
||||
Loc *time.Location |
|
||||
} |
|
||||
|
|
||||
func prepareFileOption(opts []FileOptions) FileOptions { |
|
||||
var opt FileOptions |
|
||||
if len(opts) > 0 { |
|
||||
opt = opts[0] |
|
||||
} |
|
||||
if opt.Dir == "" { |
|
||||
opt.Dir = "./" |
|
||||
} |
|
||||
err := os.MkdirAll(opt.Dir, os.ModePerm) |
|
||||
if err != nil { |
|
||||
panic(err.Error()) |
|
||||
} |
|
||||
|
|
||||
if opt.Loc == nil { |
|
||||
opt.Loc = time.Local |
|
||||
} |
|
||||
return opt |
|
||||
} |
|
||||
|
|
||||
func NewFileWriter(opts ...FileOptions) *Files { |
|
||||
opt := prepareFileOption(opts) |
|
||||
return &Files{ |
|
||||
FileOptions: opt, |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
func (f *Files) getFile() (*os.File, error) { |
|
||||
var err error |
|
||||
t := time.Now().In(f.Loc) |
|
||||
if f.f == nil { |
|
||||
f.lastFormat = t.Format(f.ByType.Format()) |
|
||||
f.f, err = os.OpenFile(filepath.Join(f.Dir, f.lastFormat+".log"), |
|
||||
os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600) |
|
||||
return f.f, err |
|
||||
} |
|
||||
if f.lastFormat != t.Format(f.ByType.Format()) { |
|
||||
f.f.Close() |
|
||||
f.lastFormat = t.Format(f.ByType.Format()) |
|
||||
f.f, err = os.OpenFile(filepath.Join(f.Dir, f.lastFormat+".log"), |
|
||||
os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600) |
|
||||
return f.f, err |
|
||||
} |
|
||||
return f.f, nil |
|
||||
} |
|
||||
|
|
||||
func (f *Files) Write(bs []byte) (int, error) { |
|
||||
f.lock.Lock() |
|
||||
defer f.lock.Unlock() |
|
||||
|
|
||||
w, err := f.getFile() |
|
||||
if err != nil { |
|
||||
return 0, err |
|
||||
} |
|
||||
return w.Write(bs) |
|
||||
} |
|
||||
|
|
||||
func (f *Files) Close() { |
|
||||
if f.f != nil { |
|
||||
f.f.Close() |
|
||||
f.f = nil |
|
||||
} |
|
||||
f.lastFormat = "" |
|
||||
} |
|
@ -1,5 +0,0 @@ |
|||||
module gitea.com/lunny/log |
|
||||
|
|
||||
go 1.12 |
|
||||
|
|
||||
require github.com/mattn/go-sqlite3 v1.10.0 |
|
@ -1,2 +0,0 @@ |
|||||
github.com/mattn/go-sqlite3 v1.10.0 h1:jbhqpg7tQe4SupckyijYiy0mJJ/pRyHvXf7JdWK860o= |
|
||||
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= |
|
@ -1,595 +0,0 @@ |
|||||
package log |
|
||||
|
|
||||
import ( |
|
||||
"bytes" |
|
||||
"fmt" |
|
||||
"io" |
|
||||
"os" |
|
||||
"runtime" |
|
||||
"strings" |
|
||||
"sync" |
|
||||
"time" |
|
||||
) |
|
||||
|
|
||||
// These flags define which text to prefix to each log entry generated by the Logger.
|
|
||||
const ( |
|
||||
// Bits or'ed together to control what's printed. There is no control over the
|
|
||||
// order they appear (the order listed here) or the format they present (as
|
|
||||
// described in the comments). A colon appears after these items:
|
|
||||
// 2009/0123 01:23:23.123123 /a/b/c/d.go:23: message
|
|
||||
Ldate = 1 << iota // the date: 2009/0123
|
|
||||
Ltime // the time: 01:23:23
|
|
||||
Lmicroseconds // microsecond resolution: 01:23:23.123123. assumes Ltime.
|
|
||||
Llongfile // full file name and line number: /a/b/c/d.go:23
|
|
||||
Lshortfile // final file name element and line number: d.go:23. overrides Llongfile
|
|
||||
Lmodule // module name
|
|
||||
Llevel // level: 0(Debug), 1(Info), 2(Warn), 3(Error), 4(Panic), 5(Fatal)
|
|
||||
Llongcolor // color will start [info] end of line
|
|
||||
Lshortcolor // color only include [info]
|
|
||||
LstdFlags = Ldate | Ltime // initial values for the standard logger
|
|
||||
//Ldefault = Llevel | LstdFlags | Lshortfile | Llongcolor
|
|
||||
) // [prefix][time][level][module][shortfile|longfile]
|
|
||||
|
|
||||
func Ldefault() int { |
|
||||
if runtime.GOOS == "windows" { |
|
||||
return Llevel | LstdFlags | Lshortfile |
|
||||
} |
|
||||
return Llevel | LstdFlags | Lshortfile | Llongcolor |
|
||||
} |
|
||||
|
|
||||
func Version() string { |
|
||||
return "0.2.0.1121" |
|
||||
} |
|
||||
|
|
||||
const ( |
|
||||
Lall = iota |
|
||||
) |
|
||||
const ( |
|
||||
Ldebug = iota |
|
||||
Linfo |
|
||||
Lwarn |
|
||||
Lerror |
|
||||
Lpanic |
|
||||
Lfatal |
|
||||
Lnone |
|
||||
) |
|
||||
|
|
||||
const ( |
|
||||
ForeBlack = iota + 30 //30
|
|
||||
ForeRed //31
|
|
||||
ForeGreen //32
|
|
||||
ForeYellow //33
|
|
||||
ForeBlue //34
|
|
||||
ForePurple //35
|
|
||||
ForeCyan //36
|
|
||||
ForeWhite //37
|
|
||||
) |
|
||||
|
|
||||
const ( |
|
||||
BackBlack = iota + 40 //40
|
|
||||
BackRed //41
|
|
||||
BackGreen //42
|
|
||||
BackYellow //43
|
|
||||
BackBlue //44
|
|
||||
BackPurple //45
|
|
||||
BackCyan //46
|
|
||||
BackWhite //47
|
|
||||
) |
|
||||
|
|
||||
var levels = []string{ |
|
||||
"[Debug]", |
|
||||
"[Info]", |
|
||||
"[Warn]", |
|
||||
"[Error]", |
|
||||
"[Panic]", |
|
||||
"[Fatal]", |
|
||||
} |
|
||||
|
|
||||
// MUST called before all logs
|
|
||||
func SetLevels(lvs []string) { |
|
||||
levels = lvs |
|
||||
} |
|
||||
|
|
||||
var colors = []int{ |
|
||||
ForeCyan, |
|
||||
ForeGreen, |
|
||||
ForeYellow, |
|
||||
ForeRed, |
|
||||
ForePurple, |
|
||||
ForeBlue, |
|
||||
} |
|
||||
|
|
||||
// MUST called before all logs
|
|
||||
func SetColors(cls []int) { |
|
||||
colors = cls |
|
||||
} |
|
||||
|
|
||||
// A Logger represents an active logging object that generates lines of
|
|
||||
// output to an io.Writer. Each logging operation makes a single call to
|
|
||||
// the Writer's Write method. A Logger can be used simultaneously from
|
|
||||
// multiple goroutines; it guarantees to serialize access to the Writer.
|
|
||||
type Logger struct { |
|
||||
mu sync.Mutex // ensures atomic writes; protects the following fields
|
|
||||
prefix string // prefix to write at beginning of each line
|
|
||||
flag int // properties
|
|
||||
Level int |
|
||||
out io.Writer // destination for output
|
|
||||
buf bytes.Buffer // for accumulating text to write
|
|
||||
levelStats [6]int64 |
|
||||
loc *time.Location |
|
||||
} |
|
||||
|
|
||||
// New creates a new Logger. The out variable sets the
|
|
||||
// destination to which log data will be written.
|
|
||||
// The prefix appears at the beginning of each generated log line.
|
|
||||
// The flag argument defines the logging properties.
|
|
||||
func New(out io.Writer, prefix string, flag int) *Logger { |
|
||||
l := &Logger{out: out, prefix: prefix, Level: 1, flag: flag, loc: time.Local} |
|
||||
if out != os.Stdout { |
|
||||
l.flag = RmColorFlags(l.flag) |
|
||||
} |
|
||||
return l |
|
||||
} |
|
||||
|
|
||||
var Std = New(os.Stderr, "", Ldefault()) |
|
||||
|
|
||||
// Cheap integer to fixed-width decimal ASCII. Give a negative width to avoid zero-padding.
|
|
||||
// Knows the buffer has capacity.
|
|
||||
func itoa(buf *bytes.Buffer, i int, wid int) { |
|
||||
var u uint = uint(i) |
|
||||
if u == 0 && wid <= 1 { |
|
||||
buf.WriteByte('0') |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
// Assemble decimal in reverse order.
|
|
||||
var b [32]byte |
|
||||
bp := len(b) |
|
||||
for ; u > 0 || wid > 0; u /= 10 { |
|
||||
bp-- |
|
||||
wid-- |
|
||||
b[bp] = byte(u%10) + '0' |
|
||||
} |
|
||||
|
|
||||
// avoid slicing b to avoid an allocation.
|
|
||||
for bp < len(b) { |
|
||||
buf.WriteByte(b[bp]) |
|
||||
bp++ |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
func moduleOf(file string) string { |
|
||||
pos := strings.LastIndex(file, "/") |
|
||||
if pos != -1 { |
|
||||
pos1 := strings.LastIndex(file[:pos], "/src/") |
|
||||
if pos1 != -1 { |
|
||||
return file[pos1+5 : pos] |
|
||||
} |
|
||||
} |
|
||||
return "UNKNOWN" |
|
||||
} |
|
||||
|
|
||||
func (l *Logger) formatHeader(buf *bytes.Buffer, t time.Time, |
|
||||
file string, line int, lvl int, reqId string) { |
|
||||
if l.prefix != "" { |
|
||||
buf.WriteString(l.prefix) |
|
||||
} |
|
||||
if l.flag&(Ldate|Ltime|Lmicroseconds) != 0 { |
|
||||
if l.flag&Ldate != 0 { |
|
||||
year, month, day := t.Date() |
|
||||
itoa(buf, year, 4) |
|
||||
buf.WriteByte('/') |
|
||||
itoa(buf, int(month), 2) |
|
||||
buf.WriteByte('/') |
|
||||
itoa(buf, day, 2) |
|
||||
buf.WriteByte(' ') |
|
||||
} |
|
||||
if l.flag&(Ltime|Lmicroseconds) != 0 { |
|
||||
hour, min, sec := t.Clock() |
|
||||
itoa(buf, hour, 2) |
|
||||
buf.WriteByte(':') |
|
||||
itoa(buf, min, 2) |
|
||||
buf.WriteByte(':') |
|
||||
itoa(buf, sec, 2) |
|
||||
if l.flag&Lmicroseconds != 0 { |
|
||||
buf.WriteByte('.') |
|
||||
itoa(buf, t.Nanosecond()/1e3, 6) |
|
||||
} |
|
||||
buf.WriteByte(' ') |
|
||||
} |
|
||||
} |
|
||||
if reqId != "" { |
|
||||
buf.WriteByte('[') |
|
||||
buf.WriteString(reqId) |
|
||||
buf.WriteByte(']') |
|
||||
buf.WriteByte(' ') |
|
||||
} |
|
||||
|
|
||||
if l.flag&(Lshortcolor|Llongcolor) != 0 { |
|
||||
buf.WriteString(fmt.Sprintf("\033[1;%dm", colors[lvl])) |
|
||||
} |
|
||||
if l.flag&Llevel != 0 { |
|
||||
buf.WriteString(levels[lvl]) |
|
||||
buf.WriteByte(' ') |
|
||||
} |
|
||||
if l.flag&Lshortcolor != 0 { |
|
||||
buf.WriteString("\033[0m") |
|
||||
} |
|
||||
|
|
||||
if l.flag&Lmodule != 0 { |
|
||||
buf.WriteByte('[') |
|
||||
buf.WriteString(moduleOf(file)) |
|
||||
buf.WriteByte(']') |
|
||||
buf.WriteByte(' ') |
|
||||
} |
|
||||
if l.flag&(Lshortfile|Llongfile) != 0 { |
|
||||
if l.flag&Lshortfile != 0 { |
|
||||
short := file |
|
||||
for i := len(file) - 1; i > 0; i-- { |
|
||||
if file[i] == '/' { |
|
||||
short = file[i+1:] |
|
||||
break |
|
||||
} |
|
||||
} |
|
||||
file = short |
|
||||
} |
|
||||
buf.WriteString(file) |
|
||||
buf.WriteByte(':') |
|
||||
itoa(buf, line, -1) |
|
||||
buf.WriteByte(' ') |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// Output writes the output for a logging event. The string s contains
|
|
||||
// the text to print after the prefix specified by the flags of the
|
|
||||
// Logger. A newline is appended if the last character of s is not
|
|
||||
// already a newline. Calldepth is used to recover the PC and is
|
|
||||
// provided for generality, although at the moment on all pre-defined
|
|
||||
// paths it will be 2.
|
|
||||
func (l *Logger) Output(reqId string, lvl int, calldepth int, s string) error { |
|
||||
if lvl < l.Level { |
|
||||
return nil |
|
||||
} |
|
||||
now := time.Now().In(l.loc) // get this early.
|
|
||||
var file string |
|
||||
var line int |
|
||||
l.mu.Lock() |
|
||||
defer l.mu.Unlock() |
|
||||
if l.flag&(Lshortfile|Llongfile|Lmodule) != 0 { |
|
||||
// release lock while getting caller info - it's expensive.
|
|
||||
l.mu.Unlock() |
|
||||
var ok bool |
|
||||
_, file, line, ok = runtime.Caller(calldepth) |
|
||||
if !ok { |
|
||||
file = "???" |
|
||||
line = 0 |
|
||||
} |
|
||||
l.mu.Lock() |
|
||||
} |
|
||||
l.levelStats[lvl]++ |
|
||||
l.buf.Reset() |
|
||||
l.formatHeader(&l.buf, now, file, line, lvl, reqId) |
|
||||
l.buf.WriteString(s) |
|
||||
if l.flag&Llongcolor != 0 { |
|
||||
l.buf.WriteString("\033[0m") |
|
||||
} |
|
||||
if len(s) > 0 && s[len(s)-1] != '\n' { |
|
||||
l.buf.WriteByte('\n') |
|
||||
} |
|
||||
_, err := l.out.Write(l.buf.Bytes()) |
|
||||
return err |
|
||||
} |
|
||||
|
|
||||
// -----------------------------------------
|
|
||||
|
|
||||
// Printf calls l.Output to print to the logger.
|
|
||||
// Arguments are handled in the manner of fmt.Printf.
|
|
||||
func (l *Logger) Printf(format string, v ...interface{}) { |
|
||||
l.Output("", Linfo, 2, fmt.Sprintf(format, v...)) |
|
||||
} |
|
||||
|
|
||||
// Print calls l.Output to print to the logger.
|
|
||||
// Arguments are handled in the manner of fmt.Print.
|
|
||||
func (l *Logger) Print(v ...interface{}) { |
|
||||
l.Output("", Linfo, 2, fmt.Sprint(v...)) |
|
||||
} |
|
||||
|
|
||||
// Println calls l.Output to print to the logger.
|
|
||||
// Arguments are handled in the manner of fmt.Println.
|
|
||||
func (l *Logger) Println(v ...interface{}) { |
|
||||
l.Output("", Linfo, 2, fmt.Sprintln(v...)) |
|
||||
} |
|
||||
|
|
||||
// -----------------------------------------
|
|
||||
|
|
||||
func (l *Logger) Debugf(format string, v ...interface{}) { |
|
||||
l.Output("", Ldebug, 2, fmt.Sprintf(format, v...)) |
|
||||
} |
|
||||
|
|
||||
func (l *Logger) Debug(v ...interface{}) { |
|
||||
l.Output("", Ldebug, 2, fmt.Sprintln(v...)) |
|
||||
} |
|
||||
|
|
||||
// -----------------------------------------
|
|
||||
func (l *Logger) Infof(format string, v ...interface{}) { |
|
||||
l.Output("", Linfo, 2, fmt.Sprintf(format, v...)) |
|
||||
} |
|
||||
|
|
||||
func (l *Logger) Info(v ...interface{}) { |
|
||||
l.Output("", Linfo, 2, fmt.Sprintln(v...)) |
|
||||
} |
|
||||
|
|
||||
// -----------------------------------------
|
|
||||
func (l *Logger) Warnf(format string, v ...interface{}) { |
|
||||
l.Output("", Lwarn, 2, fmt.Sprintf(format, v...)) |
|
||||
} |
|
||||
|
|
||||
func (l *Logger) Warn(v ...interface{}) { |
|
||||
l.Output("", Lwarn, 2, fmt.Sprintln(v...)) |
|
||||
} |
|
||||
|
|
||||
// -----------------------------------------
|
|
||||
|
|
||||
func (l *Logger) Errorf(format string, v ...interface{}) { |
|
||||
l.Output("", Lerror, 2, fmt.Sprintf(format, v...)) |
|
||||
} |
|
||||
|
|
||||
func (l *Logger) Error(v ...interface{}) { |
|
||||
l.Output("", Lerror, 2, fmt.Sprintln(v...)) |
|
||||
} |
|
||||
|
|
||||
// -----------------------------------------
|
|
||||
|
|
||||
func (l *Logger) Fatal(v ...interface{}) { |
|
||||
l.Output("", Lfatal, 2, fmt.Sprintln(v...)) |
|
||||
os.Exit(1) |
|
||||
} |
|
||||
|
|
||||
// Fatalf is equivalent to l.Printf() followed by a call to os.Exit(1).
|
|
||||
func (l *Logger) Fatalf(format string, v ...interface{}) { |
|
||||
l.Output("", Lfatal, 2, fmt.Sprintf(format, v...)) |
|
||||
os.Exit(1) |
|
||||
} |
|
||||
|
|
||||
// -----------------------------------------
|
|
||||
// Panic is equivalent to l.Print() followed by a call to panic().
|
|
||||
func (l *Logger) Panic(v ...interface{}) { |
|
||||
s := fmt.Sprintln(v...) |
|
||||
l.Output("", Lpanic, 2, s) |
|
||||
panic(s) |
|
||||
} |
|
||||
|
|
||||
// Panicf is equivalent to l.Printf() followed by a call to panic().
|
|
||||
func (l *Logger) Panicf(format string, v ...interface{}) { |
|
||||
s := fmt.Sprintf(format, v...) |
|
||||
l.Output("", Lpanic, 2, s) |
|
||||
panic(s) |
|
||||
} |
|
||||
|
|
||||
// -----------------------------------------
|
|
||||
func (l *Logger) Stack(v ...interface{}) { |
|
||||
s := fmt.Sprint(v...) |
|
||||
s += "\n" |
|
||||
buf := make([]byte, 1024*1024) |
|
||||
n := runtime.Stack(buf, true) |
|
||||
s += string(buf[:n]) |
|
||||
s += "\n" |
|
||||
l.Output("", Lerror, 2, s) |
|
||||
} |
|
||||
|
|
||||
// -----------------------------------------
|
|
||||
func (l *Logger) Stat() (stats []int64) { |
|
||||
l.mu.Lock() |
|
||||
v := l.levelStats |
|
||||
l.mu.Unlock() |
|
||||
return v[:] |
|
||||
} |
|
||||
|
|
||||
// Flags returns the output flags for the logger.
|
|
||||
func (l *Logger) Flags() int { |
|
||||
l.mu.Lock() |
|
||||
defer l.mu.Unlock() |
|
||||
return l.flag |
|
||||
} |
|
||||
|
|
||||
func RmColorFlags(flag int) int { |
|
||||
// for un std out, it should not show color since almost them don't support
|
|
||||
if flag&Llongcolor != 0 { |
|
||||
flag = flag ^ Llongcolor |
|
||||
} |
|
||||
if flag&Lshortcolor != 0 { |
|
||||
flag = flag ^ Lshortcolor |
|
||||
} |
|
||||
return flag |
|
||||
} |
|
||||
|
|
||||
func (l *Logger) Location() *time.Location { |
|
||||
return l.loc |
|
||||
} |
|
||||
|
|
||||
func (l *Logger) SetLocation(loc *time.Location) { |
|
||||
l.loc = loc |
|
||||
} |
|
||||
|
|
||||
// SetFlags sets the output flags for the logger.
|
|
||||
func (l *Logger) SetFlags(flag int) { |
|
||||
l.mu.Lock() |
|
||||
defer l.mu.Unlock() |
|
||||
if l.out != os.Stdout { |
|
||||
flag = RmColorFlags(flag) |
|
||||
} |
|
||||
l.flag = flag |
|
||||
} |
|
||||
|
|
||||
// Prefix returns the output prefix for the logger.
|
|
||||
func (l *Logger) Prefix() string { |
|
||||
l.mu.Lock() |
|
||||
defer l.mu.Unlock() |
|
||||
return l.prefix |
|
||||
} |
|
||||
|
|
||||
// SetPrefix sets the output prefix for the logger.
|
|
||||
func (l *Logger) SetPrefix(prefix string) { |
|
||||
l.mu.Lock() |
|
||||
defer l.mu.Unlock() |
|
||||
l.prefix = prefix |
|
||||
} |
|
||||
|
|
||||
// SetOutputLevel sets the output level for the logger.
|
|
||||
func (l *Logger) SetOutputLevel(lvl int) { |
|
||||
l.mu.Lock() |
|
||||
defer l.mu.Unlock() |
|
||||
l.Level = lvl |
|
||||
} |
|
||||
|
|
||||
func (l *Logger) OutputLevel() int { |
|
||||
return l.Level |
|
||||
} |
|
||||
|
|
||||
func (l *Logger) SetOutput(w io.Writer) { |
|
||||
l.mu.Lock() |
|
||||
defer l.mu.Unlock() |
|
||||
l.out = w |
|
||||
if w != os.Stdout { |
|
||||
l.flag = RmColorFlags(l.flag) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// SetOutput sets the output destination for the standard logger.
|
|
||||
func SetOutput(w io.Writer) { |
|
||||
Std.SetOutput(w) |
|
||||
} |
|
||||
|
|
||||
func SetLocation(loc *time.Location) { |
|
||||
Std.SetLocation(loc) |
|
||||
} |
|
||||
|
|
||||
func Location() *time.Location { |
|
||||
return Std.Location() |
|
||||
} |
|
||||
|
|
||||
// Flags returns the output flags for the standard logger.
|
|
||||
func Flags() int { |
|
||||
return Std.Flags() |
|
||||
} |
|
||||
|
|
||||
// SetFlags sets the output flags for the standard logger.
|
|
||||
func SetFlags(flag int) { |
|
||||
Std.SetFlags(flag) |
|
||||
} |
|
||||
|
|
||||
// Prefix returns the output prefix for the standard logger.
|
|
||||
func Prefix() string { |
|
||||
return Std.Prefix() |
|
||||
} |
|
||||
|
|
||||
// SetPrefix sets the output prefix for the standard logger.
|
|
||||
func SetPrefix(prefix string) { |
|
||||
Std.SetPrefix(prefix) |
|
||||
} |
|
||||
|
|
||||
func SetOutputLevel(lvl int) { |
|
||||
Std.SetOutputLevel(lvl) |
|
||||
} |
|
||||
|
|
||||
func OutputLevel() int { |
|
||||
return Std.OutputLevel() |
|
||||
} |
|
||||
|
|
||||
// -----------------------------------------
|
|
||||
|
|
||||
// Print calls Output to print to the standard logger.
|
|
||||
// Arguments are handled in the manner of fmt.Print.
|
|
||||
func Print(v ...interface{}) { |
|
||||
Std.Output("", Linfo, 2, fmt.Sprintln(v...)) |
|
||||
} |
|
||||
|
|
||||
// Printf calls Output to print to the standard logger.
|
|
||||
// Arguments are handled in the manner of fmt.Printf.
|
|
||||
func Printf(format string, v ...interface{}) { |
|
||||
Std.Output("", Linfo, 2, fmt.Sprintf(format, v...)) |
|
||||
} |
|
||||
|
|
||||
// Println calls Output to print to the standard logger.
|
|
||||
// Arguments are handled in the manner of fmt.Println.
|
|
||||
func Println(v ...interface{}) { |
|
||||
Std.Output("", Linfo, 2, fmt.Sprintln(v...)) |
|
||||
} |
|
||||
|
|
||||
// -----------------------------------------
|
|
||||
|
|
||||
func Debugf(format string, v ...interface{}) { |
|
||||
Std.Output("", Ldebug, 2, fmt.Sprintf(format, v...)) |
|
||||
} |
|
||||
|
|
||||
func Debug(v ...interface{}) { |
|
||||
Std.Output("", Ldebug, 2, fmt.Sprintln(v...)) |
|
||||
} |
|
||||
|
|
||||
// -----------------------------------------
|
|
||||
|
|
||||
func Infof(format string, v ...interface{}) { |
|
||||
Std.Output("", Linfo, 2, fmt.Sprintf(format, v...)) |
|
||||
} |
|
||||
|
|
||||
func Info(v ...interface{}) { |
|
||||
Std.Output("", Linfo, 2, fmt.Sprintln(v...)) |
|
||||
} |
|
||||
|
|
||||
// -----------------------------------------
|
|
||||
|
|
||||
func Warnf(format string, v ...interface{}) { |
|
||||
Std.Output("", Lwarn, 2, fmt.Sprintf(format, v...)) |
|
||||
} |
|
||||
|
|
||||
func Warn(v ...interface{}) { |
|
||||
Std.Output("", Lwarn, 2, fmt.Sprintln(v...)) |
|
||||
} |
|
||||
|
|
||||
// -----------------------------------------
|
|
||||
|
|
||||
func Errorf(format string, v ...interface{}) { |
|
||||
Std.Output("", Lerror, 2, fmt.Sprintf(format, v...)) |
|
||||
} |
|
||||
|
|
||||
func Error(v ...interface{}) { |
|
||||
Std.Output("", Lerror, 2, fmt.Sprintln(v...)) |
|
||||
} |
|
||||
|
|
||||
// -----------------------------------------
|
|
||||
|
|
||||
// Fatal is equivalent to Print() followed by a call to os.Exit(1).
|
|
||||
func Fatal(v ...interface{}) { |
|
||||
Std.Output("", Lfatal, 2, fmt.Sprintln(v...)) |
|
||||
} |
|
||||
|
|
||||
// Fatalf is equivalent to Printf() followed by a call to os.Exit(1).
|
|
||||
func Fatalf(format string, v ...interface{}) { |
|
||||
Std.Output("", Lfatal, 2, fmt.Sprintf(format, v...)) |
|
||||
} |
|
||||
|
|
||||
// -----------------------------------------
|
|
||||
|
|
||||
// Panic is equivalent to Print() followed by a call to panic().
|
|
||||
func Panic(v ...interface{}) { |
|
||||
Std.Output("", Lpanic, 2, fmt.Sprintln(v...)) |
|
||||
} |
|
||||
|
|
||||
// Panicf is equivalent to Printf() followed by a call to panic().
|
|
||||
func Panicf(format string, v ...interface{}) { |
|
||||
Std.Output("", Lpanic, 2, fmt.Sprintf(format, v...)) |
|
||||
} |
|
||||
|
|
||||
// -----------------------------------------
|
|
||||
|
|
||||
func Stack(v ...interface{}) { |
|
||||
s := fmt.Sprint(v...) |
|
||||
s += "\n" |
|
||||
buf := make([]byte, 1024*1024) |
|
||||
n := runtime.Stack(buf, true) |
|
||||
s += string(buf[:n]) |
|
||||
s += "\n" |
|
||||
Std.Output("", Lerror, 2, s) |
|
||||
} |
|
||||
|
|
||||
// -----------------------------------------
|
|
@ -1,674 +0,0 @@ |
|||||
GNU GENERAL PUBLIC LICENSE |
|
||||
Version 3, 29 June 2007 |
|
||||
|
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> |
|
||||
Everyone is permitted to copy and distribute verbatim copies |
|
||||
of this license document, but changing it is not allowed. |
|
||||
|
|
||||
Preamble |
|
||||
|
|
||||
The GNU General Public License is a free, copyleft license for |
|
||||
software and other kinds of works. |
|
||||
|
|
||||
The licenses for most software and other practical works are designed |
|
||||
to take away your freedom to share and change the works. By contrast, |
|
||||
the GNU General Public License is intended to guarantee your freedom to |
|
||||
share and change all versions of a program--to make sure it remains free |
|
||||
software for all its users. We, the Free Software Foundation, use the |
|
||||
GNU General Public License for most of our software; it applies also to |
|
||||
any other work released this way by its authors. You can apply it to |
|
||||
your programs, too. |
|
||||
|
|
||||
When we speak of free software, we are referring to freedom, not |
|
||||
price. Our General Public Licenses are designed to make sure that you |
|
||||
have the freedom to distribute copies of free software (and charge for |
|
||||
them if you wish), that you receive source code or can get it if you |
|
||||
want it, that you can change the software or use pieces of it in new |
|
||||
free programs, and that you know you can do these things. |
|
||||
|
|
||||
To protect your rights, we need to prevent others from denying you |
|
||||
these rights or asking you to surrender the rights. Therefore, you have |
|
||||
certain responsibilities if you distribute copies of the software, or if |
|
||||
you modify it: responsibilities to respect the freedom of others. |
|
||||
|
|
||||
For example, if you distribute copies of such a program, whether |
|
||||
gratis or for a fee, you must pass on to the recipients the same |
|
||||
freedoms that you received. You must make sure that they, too, receive |
|
||||
or can get the source code. And you must show them these terms so they |
|
||||
know their rights. |
|
||||
|
|
||||
Developers that use the GNU GPL protect your rights with two steps: |
|
||||
(1) assert copyright on the software, and (2) offer you this License |
|
||||
giving you legal permission to copy, distribute and/or modify it. |
|
||||
|
|
||||
For the developers' and authors' protection, the GPL clearly explains |
|
||||
that there is no warranty for this free software. For both users' and |
|
||||
authors' sake, the GPL requires that modified versions be marked as |
|
||||
changed, so that their problems will not be attributed erroneously to |
|
||||
authors of previous versions. |
|
||||
|
|
||||
Some devices are designed to deny users access to install or run |
|
||||
modified versions of the software inside them, although the manufacturer |
|
||||
can do so. This is fundamentally incompatible with the aim of |
|
||||
protecting users' freedom to change the software. The systematic |
|
||||
pattern of such abuse occurs in the area of products for individuals to |
|
||||
use, which is precisely where it is most unacceptable. Therefore, we |
|
||||
have designed this version of the GPL to prohibit the practice for those |
|
||||
products. If such problems arise substantially in other domains, we |
|
||||
stand ready to extend this provision to those domains in future versions |
|
||||
of the GPL, as needed to protect the freedom of users. |
|
||||
|
|
||||
Finally, every program is threatened constantly by software patents. |
|
||||
States should not allow patents to restrict development and use of |
|
||||
software on general-purpose computers, but in those that do, we wish to |
|
||||
avoid the special danger that patents applied to a free program could |
|
||||
make it effectively proprietary. To prevent this, the GPL assures that |
|
||||
patents cannot be used to render the program non-free. |
|
||||
|
|
||||
The precise terms and conditions for copying, distribution and |
|
||||
modification follow. |
|
||||
|
|
||||
TERMS AND CONDITIONS |
|
||||
|
|
||||
0. Definitions. |
|
||||
|
|
||||
"This License" refers to version 3 of the GNU General Public License. |
|
||||
|
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of |
|
||||
works, such as semiconductor masks. |
|
||||
|
|
||||
"The Program" refers to any copyrightable work licensed under this |
|
||||
License. Each licensee is addressed as "you". "Licensees" and |
|
||||
"recipients" may be individuals or organizations. |
|
||||
|
|
||||
To "modify" a work means to copy from or adapt all or part of the work |
|
||||
in a fashion requiring copyright permission, other than the making of an |
|
||||
exact copy. The resulting work is called a "modified version" of the |
|
||||
earlier work or a work "based on" the earlier work. |
|
||||
|
|
||||
A "covered work" means either the unmodified Program or a work based |
|
||||
on the Program. |
|
||||
|
|
||||
To "propagate" a work means to do anything with it that, without |
|
||||
permission, would make you directly or secondarily liable for |
|
||||
infringement under applicable copyright law, except executing it on a |
|
||||
computer or modifying a private copy. Propagation includes copying, |
|
||||
distribution (with or without modification), making available to the |
|
||||
public, and in some countries other activities as well. |
|
||||
|
|
||||
To "convey" a work means any kind of propagation that enables other |
|
||||
parties to make or receive copies. Mere interaction with a user through |
|
||||
a computer network, with no transfer of a copy, is not conveying. |
|
||||
|
|
||||
An interactive user interface displays "Appropriate Legal Notices" |
|
||||
to the extent that it includes a convenient and prominently visible |
|
||||
feature that (1) displays an appropriate copyright notice, and (2) |
|
||||
tells the user that there is no warranty for the work (except to the |
|
||||
extent that warranties are provided), that licensees may convey the |
|
||||
work under this License, and how to view a copy of this License. If |
|
||||
the interface presents a list of user commands or options, such as a |
|
||||
menu, a prominent item in the list meets this criterion. |
|
||||
|
|
||||
1. Source Code. |
|
||||
|
|
||||
The "source code" for a work means the preferred form of the work |
|
||||
for making modifications to it. "Object code" means any non-source |
|
||||
form of a work. |
|
||||
|
|
||||
A "Standard Interface" means an interface that either is an official |
|
||||
standard defined by a recognized standards body, or, in the case of |
|
||||
interfaces specified for a particular programming language, one that |
|
||||
is widely used among developers working in that language. |
|
||||
|
|
||||
The "System Libraries" of an executable work include anything, other |
|
||||
than the work as a whole, that (a) is included in the normal form of |
|
||||
packaging a Major Component, but which is not part of that Major |
|
||||
Component, and (b) serves only to enable use of the work with that |
|
||||
Major Component, or to implement a Standard Interface for which an |
|
||||
implementation is available to the public in source code form. A |
|
||||
"Major Component", in this context, means a major essential component |
|
||||
(kernel, window system, and so on) of the specific operating system |
|
||||
(if any) on which the executable work runs, or a compiler used to |
|
||||
produce the work, or an object code interpreter used to run it. |
|
||||
|
|
||||
The "Corresponding Source" for a work in object code form means all |
|
||||
the source code needed to generate, install, and (for an executable |
|
||||
work) run the object code and to modify the work, including scripts to |
|
||||
control those activities. However, it does not include the work's |
|
||||
System Libraries, or general-purpose tools or generally available free |
|
||||
programs which are used unmodified in performing those activities but |
|
||||
which are not part of the work. For example, Corresponding Source |
|
||||
includes interface definition files associated with source files for |
|
||||
the work, and the source code for shared libraries and dynamically |
|
||||
linked subprograms that the work is specifically designed to require, |
|
||||
such as by intimate data communication or control flow between those |
|
||||
subprograms and other parts of the work. |
|
||||
|
|
||||
The Corresponding Source need not include anything that users |
|
||||
can regenerate automatically from other parts of the Corresponding |
|
||||
Source. |
|
||||
|
|
||||
The Corresponding Source for a work in source code form is that |
|
||||
same work. |
|
||||
|
|
||||
2. Basic Permissions. |
|
||||
|
|
||||
All rights granted under this License are granted for the term of |
|
||||
copyright on the Program, and are irrevocable provided the stated |
|
||||
conditions are met. This License explicitly affirms your unlimited |
|
||||
permission to run the unmodified Program. The output from running a |
|
||||
covered work is covered by this License only if the output, given its |
|
||||
content, constitutes a covered work. This License acknowledges your |
|
||||
rights of fair use or other equivalent, as provided by copyright law. |
|
||||
|
|
||||
You may make, run and propagate covered works that you do not |
|
||||
convey, without conditions so long as your license otherwise remains |
|
||||
in force. You may convey covered works to others for the sole purpose |
|
||||
of having them make modifications exclusively for you, or provide you |
|
||||
with facilities for running those works, provided that you comply with |
|
||||
the terms of this License in conveying all material for which you do |
|
||||
not control copyright. Those thus making or running the covered works |
|
||||
for you must do so exclusively on your behalf, under your direction |
|
||||
and control, on terms that prohibit them from making any copies of |
|
||||
your copyrighted material outside their relationship with you. |
|
||||
|
|
||||
Conveying under any other circumstances is permitted solely under |
|
||||
the conditions stated below. Sublicensing is not allowed; section 10 |
|
||||
makes it unnecessary. |
|
||||
|
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law. |
|
||||
|
|
||||
No covered work shall be deemed part of an effective technological |
|
||||
measure under any applicable law fulfilling obligations under article |
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or |
|
||||
similar laws prohibiting or restricting circumvention of such |
|
||||
measures. |
|
||||
|
|
||||
When you convey a covered work, you waive any legal power to forbid |
|
||||
circumvention of technological measures to the extent such circumvention |
|
||||
is effected by exercising rights under this License with respect to |
|
||||
the covered work, and you disclaim any intention to limit operation or |
|
||||
modification of the work as a means of enforcing, against the work's |
|
||||
users, your or third parties' legal rights to forbid circumvention of |
|
||||
technological measures. |
|
||||
|
|
||||
4. Conveying Verbatim Copies. |
|
||||
|
|
||||
You may convey verbatim copies of the Program's source code as you |
|
||||
receive it, in any medium, provided that you conspicuously and |
|
||||
appropriately publish on each copy an appropriate copyright notice; |
|
||||
keep intact all notices stating that this License and any |
|
||||
non-permissive terms added in accord with section 7 apply to the code; |
|
||||
keep intact all notices of the absence of any warranty; and give all |
|
||||
recipients a copy of this License along with the Program. |
|
||||
|
|
||||
You may charge any price or no price for each copy that you convey, |
|
||||
and you may offer support or warranty protection for a fee. |
|
||||
|
|
||||
5. Conveying Modified Source Versions. |
|
||||
|
|
||||
You may convey a work based on the Program, or the modifications to |
|
||||
produce it from the Program, in the form of source code under the |
|
||||
terms of section 4, provided that you also meet all of these conditions: |
|
||||
|
|
||||
a) The work must carry prominent notices stating that you modified |
|
||||
it, and giving a relevant date. |
|
||||
|
|
||||
b) The work must carry prominent notices stating that it is |
|
||||
released under this License and any conditions added under section |
|
||||
7. This requirement modifies the requirement in section 4 to |
|
||||
"keep intact all notices". |
|
||||
|
|
||||
c) You must license the entire work, as a whole, under this |
|
||||
License to anyone who comes into possession of a copy. This |
|
||||
License will therefore apply, along with any applicable section 7 |
|
||||
additional terms, to the whole of the work, and all its parts, |
|
||||
regardless of how they are packaged. This License gives no |
|
||||
permission to license the work in any other way, but it does not |
|
||||
invalidate such permission if you have separately received it. |
|
||||
|
|
||||
d) If the work has interactive user interfaces, each must display |
|
||||
Appropriate Legal Notices; however, if the Program has interactive |
|
||||
interfaces that do not display Appropriate Legal Notices, your |
|
||||
work need not make them do so. |
|
||||
|
|
||||
A compilation of a covered work with other separate and independent |
|
||||
works, which are not by their nature extensions of the covered work, |
|
||||
and which are not combined with it such as to form a larger program, |
|
||||
in or on a volume of a storage or distribution medium, is called an |
|
||||
"aggregate" if the compilation and its resulting copyright are not |
|
||||
used to limit the access or legal rights of the compilation's users |
|
||||
beyond what the individual works permit. Inclusion of a covered work |
|
||||
in an aggregate does not cause this License to apply to the other |
|
||||
parts of the aggregate. |
|
||||
|
|
||||
6. Conveying Non-Source Forms. |
|
||||
|
|
||||
You may convey a covered work in object code form under the terms |
|
||||
of sections 4 and 5, provided that you also convey the |
|
||||
machine-readable Corresponding Source under the terms of this License, |
|
||||
in one of these ways: |
|
||||
|
|
||||
a) Convey the object code in, or embodied in, a physical product |
|
||||
(including a physical distribution medium), accompanied by the |
|
||||
Corresponding Source fixed on a durable physical medium |
|
||||
customarily used for software interchange. |
|
||||
|
|
||||
b) Convey the object code in, or embodied in, a physical product |
|
||||
(including a physical distribution medium), accompanied by a |
|
||||
written offer, valid for at least three years and valid for as |
|
||||
long as you offer spare parts or customer support for that product |
|
||||
model, to give anyone who possesses the object code either (1) a |
|
||||
copy of the Corresponding Source for all the software in the |
|
||||
product that is covered by this License, on a durable physical |
|
||||
medium customarily used for software interchange, for a price no |
|
||||
more than your reasonable cost of physically performing this |
|
||||
conveying of source, or (2) access to copy the |
|
||||
Corresponding Source from a network server at no charge. |
|
||||
|
|
||||
c) Convey individual copies of the object code with a copy of the |
|
||||
written offer to provide the Corresponding Source. This |
|
||||
alternative is allowed only occasionally and noncommercially, and |
|
||||
only if you received the object code with such an offer, in accord |
|
||||
with subsection 6b. |
|
||||
|
|
||||
d) Convey the object code by offering access from a designated |
|
||||
place (gratis or for a charge), and offer equivalent access to the |
|
||||
Corresponding Source in the same way through the same place at no |
|
||||
further charge. You need not require recipients to copy the |
|
||||
Corresponding Source along with the object code. If the place to |
|
||||
copy the object code is a network server, the Corresponding Source |
|
||||
may be on a different server (operated by you or a third party) |
|
||||
that supports equivalent copying facilities, provided you maintain |
|
||||
clear directions next to the object code saying where to find the |
|
||||
Corresponding Source. Regardless of what server hosts the |
|
||||
Corresponding Source, you remain obligated to ensure that it is |
|
||||
available for as long as needed to satisfy these requirements. |
|
||||
|
|
||||
e) Convey the object code using peer-to-peer transmission, provided |
|
||||
you inform other peers where the object code and Corresponding |
|
||||
Source of the work are being offered to the general public at no |
|
||||
charge under subsection 6d. |
|
||||
|
|
||||
A separable portion of the object code, whose source code is excluded |
|
||||
from the Corresponding Source as a System Library, need not be |
|
||||
included in conveying the object code work. |
|
||||
|
|
||||
A "User Product" is either (1) a "consumer product", which means any |
|
||||
tangible personal property which is normally used for personal, family, |
|
||||
or household purposes, or (2) anything designed or sold for incorporation |
|
||||
into a dwelling. In determining whether a product is a consumer product, |
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular |
|
||||
product received by a particular user, "normally used" refers to a |
|
||||
typical or common use of that class of product, regardless of the status |
|
||||
of the particular user or of the way in which the particular user |
|
||||
actually uses, or expects or is expected to use, the product. A product |
|
||||
is a consumer product regardless of whether the product has substantial |
|
||||
commercial, industrial or non-consumer uses, unless such uses represent |
|
||||
the only significant mode of use of the product. |
|
||||
|
|
||||
"Installation Information" for a User Product means any methods, |
|
||||
procedures, authorization keys, or other information required to install |
|
||||
and execute modified versions of a covered work in that User Product from |
|
||||
a modified version of its Corresponding Source. The information must |
|
||||
suffice to ensure that the continued functioning of the modified object |
|
||||
code is in no case prevented or interfered with solely because |
|
||||
modification has been made. |
|
||||
|
|
||||
If you convey an object code work under this section in, or with, or |
|
||||
specifically for use in, a User Product, and the conveying occurs as |
|
||||
part of a transaction in which the right of possession and use of the |
|
||||
User Product is transferred to the recipient in perpetuity or for a |
|
||||
fixed term (regardless of how the transaction is characterized), the |
|
||||
Corresponding Source conveyed under this section must be accompanied |
|
||||
by the Installation Information. But this requirement does not apply |
|
||||
if neither you nor any third party retains the ability to install |
|
||||
modified object code on the User Product (for example, the work has |
|
||||
been installed in ROM). |
|
||||
|
|
||||
The requirement to provide Installation Information does not include a |
|
||||
requirement to continue to provide support service, warranty, or updates |
|
||||
for a work that has been modified or installed by the recipient, or for |
|
||||
the User Product in which it has been modified or installed. Access to a |
|
||||
network may be denied when the modification itself materially and |
|
||||
adversely affects the operation of the network or violates the rules and |
|
||||
protocols for communication across the network. |
|
||||
|
|
||||
Corresponding Source conveyed, and Installation Information provided, |
|
||||
in accord with this section must be in a format that is publicly |
|
||||
documented (and with an implementation available to the public in |
|
||||
source code form), and must require no special password or key for |
|
||||
unpacking, reading or copying. |
|
||||
|
|
||||
7. Additional Terms. |
|
||||
|
|
||||
"Additional permissions" are terms that supplement the terms of this |
|
||||
License by making exceptions from one or more of its conditions. |
|
||||
Additional permissions that are applicable to the entire Program shall |
|
||||
be treated as though they were included in this License, to the extent |
|
||||
that they are valid under applicable law. If additional permissions |
|
||||
apply only to part of the Program, that part may be used separately |
|
||||
under those permissions, but the entire Program remains governed by |
|
||||
this License without regard to the additional permissions. |
|
||||
|
|
||||
When you convey a copy of a covered work, you may at your option |
|
||||
remove any additional permissions from that copy, or from any part of |
|
||||
it. (Additional permissions may be written to require their own |
|
||||
removal in certain cases when you modify the work.) You may place |
|
||||
additional permissions on material, added by you to a covered work, |
|
||||
for which you have or can give appropriate copyright permission. |
|
||||
|
|
||||
Notwithstanding any other provision of this License, for material you |
|
||||
add to a covered work, you may (if authorized by the copyright holders of |
|
||||
that material) supplement the terms of this License with terms: |
|
||||
|
|
||||
a) Disclaiming warranty or limiting liability differently from the |
|
||||
terms of sections 15 and 16 of this License; or |
|
||||
|
|
||||
b) Requiring preservation of specified reasonable legal notices or |
|
||||
author attributions in that material or in the Appropriate Legal |
|
||||
Notices displayed by works containing it; or |
|
||||
|
|
||||
c) Prohibiting misrepresentation of the origin of that material, or |
|
||||
requiring that modified versions of such material be marked in |
|
||||
reasonable ways as different from the original version; or |
|
||||
|
|
||||
d) Limiting the use for publicity purposes of names of licensors or |
|
||||
authors of the material; or |
|
||||
|
|
||||
e) Declining to grant rights under trademark law for use of some |
|
||||
trade names, trademarks, or service marks; or |
|
||||
|
|
||||
f) Requiring indemnification of licensors and authors of that |
|
||||
material by anyone who conveys the material (or modified versions of |
|
||||
it) with contractual assumptions of liability to the recipient, for |
|
||||
any liability that these contractual assumptions directly impose on |
|
||||
those licensors and authors. |
|
||||
|
|
||||
All other non-permissive additional terms are considered "further |
|
||||
restrictions" within the meaning of section 10. If the Program as you |
|
||||
received it, or any part of it, contains a notice stating that it is |
|
||||
governed by this License along with a term that is a further |
|
||||
restriction, you may remove that term. If a license document contains |
|
||||
a further restriction but permits relicensing or conveying under this |
|
||||
License, you may add to a covered work material governed by the terms |
|
||||
of that license document, provided that the further restriction does |
|
||||
not survive such relicensing or conveying. |
|
||||
|
|
||||
If you add terms to a covered work in accord with this section, you |
|
||||
must place, in the relevant source files, a statement of the |
|
||||
additional terms that apply to those files, or a notice indicating |
|
||||
where to find the applicable terms. |
|
||||
|
|
||||
Additional terms, permissive or non-permissive, may be stated in the |
|
||||
form of a separately written license, or stated as exceptions; |
|
||||
the above requirements apply either way. |
|
||||
|
|
||||
8. Termination. |
|
||||
|
|
||||
You may not propagate or modify a covered work except as expressly |
|
||||
provided under this License. Any attempt otherwise to propagate or |
|
||||
modify it is void, and will automatically terminate your rights under |
|
||||
this License (including any patent licenses granted under the third |
|
||||
paragraph of section 11). |
|
||||
|
|
||||
However, if you cease all violation of this License, then your |
|
||||
license from a particular copyright holder is reinstated (a) |
|
||||
provisionally, unless and until the copyright holder explicitly and |
|
||||
finally terminates your license, and (b) permanently, if the copyright |
|
||||
holder fails to notify you of the violation by some reasonable means |
|
||||
prior to 60 days after the cessation. |
|
||||
|
|
||||
Moreover, your license from a particular copyright holder is |
|
||||
reinstated permanently if the copyright holder notifies you of the |
|
||||
violation by some reasonable means, this is the first time you have |
|
||||
received notice of violation of this License (for any work) from that |
|
||||
copyright holder, and you cure the violation prior to 30 days after |
|
||||
your receipt of the notice. |
|
||||
|
|
||||
Termination of your rights under this section does not terminate the |
|
||||
licenses of parties who have received copies or rights from you under |
|
||||
this License. If your rights have been terminated and not permanently |
|
||||
reinstated, you do not qualify to receive new licenses for the same |
|
||||
material under section 10. |
|
||||
|
|
||||
9. Acceptance Not Required for Having Copies. |
|
||||
|
|
||||
You are not required to accept this License in order to receive or |
|
||||
run a copy of the Program. Ancillary propagation of a covered work |
|
||||
occurring solely as a consequence of using peer-to-peer transmission |
|
||||
to receive a copy likewise does not require acceptance. However, |
|
||||
nothing other than this License grants you permission to propagate or |
|
||||
modify any covered work. These actions infringe copyright if you do |
|
||||
not accept this License. Therefore, by modifying or propagating a |
|
||||
covered work, you indicate your acceptance of this License to do so. |
|
||||
|
|
||||
10. Automatic Licensing of Downstream Recipients. |
|
||||
|
|
||||
Each time you convey a covered work, the recipient automatically |
|
||||
receives a license from the original licensors, to run, modify and |
|
||||
propagate that work, subject to this License. You are not responsible |
|
||||
for enforcing compliance by third parties with this License. |
|
||||
|
|
||||
An "entity transaction" is a transaction transferring control of an |
|
||||
organization, or substantially all assets of one, or subdividing an |
|
||||
organization, or merging organizations. If propagation of a covered |
|
||||
work results from an entity transaction, each party to that |
|
||||
transaction who receives a copy of the work also receives whatever |
|
||||
licenses to the work the party's predecessor in interest had or could |
|
||||
give under the previous paragraph, plus a right to possession of the |
|
||||
Corresponding Source of the work from the predecessor in interest, if |
|
||||
the predecessor has it or can get it with reasonable efforts. |
|
||||
|
|
||||
You may not impose any further restrictions on the exercise of the |
|
||||
rights granted or affirmed under this License. For example, you may |
|
||||
not impose a license fee, royalty, or other charge for exercise of |
|
||||
rights granted under this License, and you may not initiate litigation |
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that |
|
||||
any patent claim is infringed by making, using, selling, offering for |
|
||||
sale, or importing the Program or any portion of it. |
|
||||
|
|
||||
11. Patents. |
|
||||
|
|
||||
A "contributor" is a copyright holder who authorizes use under this |
|
||||
License of the Program or a work on which the Program is based. The |
|
||||
work thus licensed is called the contributor's "contributor version". |
|
||||
|
|
||||
A contributor's "essential patent claims" are all patent claims |
|
||||
owned or controlled by the contributor, whether already acquired or |
|
||||
hereafter acquired, that would be infringed by some manner, permitted |
|
||||
by this License, of making, using, or selling its contributor version, |
|
||||
but do not include claims that would be infringed only as a |
|
||||
consequence of further modification of the contributor version. For |
|
||||
purposes of this definition, "control" includes the right to grant |
|
||||
patent sublicenses in a manner consistent with the requirements of |
|
||||
this License. |
|
||||
|
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free |
|
||||
patent license under the contributor's essential patent claims, to |
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and |
|
||||
propagate the contents of its contributor version. |
|
||||
|
|
||||
In the following three paragraphs, a "patent license" is any express |
|
||||
agreement or commitment, however denominated, not to enforce a patent |
|
||||
(such as an express permission to practice a patent or covenant not to |
|
||||
sue for patent infringement). To "grant" such a patent license to a |
|
||||
party means to make such an agreement or commitment not to enforce a |
|
||||
patent against the party. |
|
||||
|
|
||||
If you convey a covered work, knowingly relying on a patent license, |
|
||||
and the Corresponding Source of the work is not available for anyone |
|
||||
to copy, free of charge and under the terms of this License, through a |
|
||||
publicly available network server or other readily accessible means, |
|
||||
then you must either (1) cause the Corresponding Source to be so |
|
||||
available, or (2) arrange to deprive yourself of the benefit of the |
|
||||
patent license for this particular work, or (3) arrange, in a manner |
|
||||
consistent with the requirements of this License, to extend the patent |
|
||||
license to downstream recipients. "Knowingly relying" means you have |
|
||||
actual knowledge that, but for the patent license, your conveying the |
|
||||
covered work in a country, or your recipient's use of the covered work |
|
||||
in a country, would infringe one or more identifiable patents in that |
|
||||
country that you have reason to believe are valid. |
|
||||
|
|
||||
If, pursuant to or in connection with a single transaction or |
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a |
|
||||
covered work, and grant a patent license to some of the parties |
|
||||
receiving the covered work authorizing them to use, propagate, modify |
|
||||
or convey a specific copy of the covered work, then the patent license |
|
||||
you grant is automatically extended to all recipients of the covered |
|
||||
work and works based on it. |
|
||||
|
|
||||
A patent license is "discriminatory" if it does not include within |
|
||||
the scope of its coverage, prohibits the exercise of, or is |
|
||||
conditioned on the non-exercise of one or more of the rights that are |
|
||||
specifically granted under this License. You may not convey a covered |
|
||||
work if you are a party to an arrangement with a third party that is |
|
||||
in the business of distributing software, under which you make payment |
|
||||
to the third party based on the extent of your activity of conveying |
|
||||
the work, and under which the third party grants, to any of the |
|
||||
parties who would receive the covered work from you, a discriminatory |
|
||||
patent license (a) in connection with copies of the covered work |
|
||||
conveyed by you (or copies made from those copies), or (b) primarily |
|
||||
for and in connection with specific products or compilations that |
|
||||
contain the covered work, unless you entered into that arrangement, |
|
||||
or that patent license was granted, prior to 28 March 2007. |
|
||||
|
|
||||
Nothing in this License shall be construed as excluding or limiting |
|
||||
any implied license or other defenses to infringement that may |
|
||||
otherwise be available to you under applicable patent law. |
|
||||
|
|
||||
12. No Surrender of Others' Freedom. |
|
||||
|
|
||||
If conditions are imposed on you (whether by court order, agreement or |
|
||||
otherwise) that contradict the conditions of this License, they do not |
|
||||
excuse you from the conditions of this License. If you cannot convey a |
|
||||
covered work so as to satisfy simultaneously your obligations under this |
|
||||
License and any other pertinent obligations, then as a consequence you may |
|
||||
not convey it at all. For example, if you agree to terms that obligate you |
|
||||
to collect a royalty for further conveying from those to whom you convey |
|
||||
the Program, the only way you could satisfy both those terms and this |
|
||||
License would be to refrain entirely from conveying the Program. |
|
||||
|
|
||||
13. Use with the GNU Affero General Public License. |
|
||||
|
|
||||
Notwithstanding any other provision of this License, you have |
|
||||
permission to link or combine any covered work with a work licensed |
|
||||
under version 3 of the GNU Affero General Public License into a single |
|
||||
combined work, and to convey the resulting work. The terms of this |
|
||||
License will continue to apply to the part which is the covered work, |
|
||||
but the special requirements of the GNU Affero General Public License, |
|
||||
section 13, concerning interaction through a network will apply to the |
|
||||
combination as such. |
|
||||
|
|
||||
14. Revised Versions of this License. |
|
||||
|
|
||||
The Free Software Foundation may publish revised and/or new versions of |
|
||||
the GNU General Public License from time to time. Such new versions will |
|
||||
be similar in spirit to the present version, but may differ in detail to |
|
||||
address new problems or concerns. |
|
||||
|
|
||||
Each version is given a distinguishing version number. If the |
|
||||
Program specifies that a certain numbered version of the GNU General |
|
||||
Public License "or any later version" applies to it, you have the |
|
||||
option of following the terms and conditions either of that numbered |
|
||||
version or of any later version published by the Free Software |
|
||||
Foundation. If the Program does not specify a version number of the |
|
||||
GNU General Public License, you may choose any version ever published |
|
||||
by the Free Software Foundation. |
|
||||
|
|
||||
If the Program specifies that a proxy can decide which future |
|
||||
versions of the GNU General Public License can be used, that proxy's |
|
||||
public statement of acceptance of a version permanently authorizes you |
|
||||
to choose that version for the Program. |
|
||||
|
|
||||
Later license versions may give you additional or different |
|
||||
permissions. However, no additional obligations are imposed on any |
|
||||
author or copyright holder as a result of your choosing to follow a |
|
||||
later version. |
|
||||
|
|
||||
15. Disclaimer of Warranty. |
|
||||
|
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY |
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT |
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY |
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, |
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM |
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF |
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION. |
|
||||
|
|
||||
16. Limitation of Liability. |
|
||||
|
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS |
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY |
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE |
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF |
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD |
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), |
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
|
||||
SUCH DAMAGES. |
|
||||
|
|
||||
17. Interpretation of Sections 15 and 16. |
|
||||
|
|
||||
If the disclaimer of warranty and limitation of liability provided |
|
||||
above cannot be given local legal effect according to their terms, |
|
||||
reviewing courts shall apply local law that most closely approximates |
|
||||
an absolute waiver of all civil liability in connection with the |
|
||||
Program, unless a warranty or assumption of liability accompanies a |
|
||||
copy of the Program in return for a fee. |
|
||||
|
|
||||
END OF TERMS AND CONDITIONS |
|
||||
|
|
||||
How to Apply These Terms to Your New Programs |
|
||||
|
|
||||
If you develop a new program, and you want it to be of the greatest |
|
||||
possible use to the public, the best way to achieve this is to make it |
|
||||
free software which everyone can redistribute and change under these terms. |
|
||||
|
|
||||
To do so, attach the following notices to the program. It is safest |
|
||||
to attach them to the start of each source file to most effectively |
|
||||
state the exclusion of warranty; and each file should have at least |
|
||||
the "copyright" line and a pointer to where the full notice is found. |
|
||||
|
|
||||
<one line to give the program's name and a brief idea of what it does.> |
|
||||
Copyright (C) <year> <name of author> |
|
||||
|
|
||||
This program is free software: you can redistribute it and/or modify |
|
||||
it under the terms of the GNU General Public License as published by |
|
||||
the Free Software Foundation, either version 3 of the License, or |
|
||||
(at your option) any later version. |
|
||||
|
|
||||
This program is distributed in the hope that it will be useful, |
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
GNU General Public License for more details. |
|
||||
|
|
||||
You should have received a copy of the GNU General Public License |
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
||||
|
|
||||
Also add information on how to contact you by electronic and paper mail. |
|
||||
|
|
||||
If the program does terminal interaction, make it output a short |
|
||||
notice like this when it starts in an interactive mode: |
|
||||
|
|
||||
<program> Copyright (C) <year> <name of author> |
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. |
|
||||
This is free software, and you are welcome to redistribute it |
|
||||
under certain conditions; type `show c' for details. |
|
||||
|
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate |
|
||||
parts of the General Public License. Of course, your program's commands |
|
||||
might be different; for a GUI interface, you would use an "about box". |
|
||||
|
|
||||
You should also get your employer (if you work as a programmer) or school, |
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary. |
|
||||
For more information on this, and how to apply and follow the GNU GPL, see |
|
||||
<https://www.gnu.org/licenses/>. |
|
||||
|
|
||||
The GNU General Public License does not permit incorporating your program |
|
||||
into proprietary programs. If your program is a subroutine library, you |
|
||||
may consider it more useful to permit linking proprietary applications with |
|
||||
the library. If this is what you want to do, use the GNU Lesser General |
|
||||
Public License instead of this License. But first, please read |
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>. |
|
1121
vendor/github.com/ahl5esoft/golang-underscore/README.md
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,17 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
func (m enumerable) Aggregate(memo interface{}, fn interface{}) IEnumerable { |
|
||||
fnRV := reflect.ValueOf(fn) |
|
||||
iterator := m.GetEnumerator() |
|
||||
memoRV := reflect.ValueOf(memo) |
|
||||
for ok := iterator.MoveNext(); ok; ok = iterator.MoveNext() { |
|
||||
memoRV = fnRV.Call([]reflect.Value{ |
|
||||
memoRV, |
|
||||
iterator.GetValue(), |
|
||||
iterator.GetKey(), |
|
||||
})[0] |
|
||||
} |
|
||||
return chainFromRV(memoRV) |
|
||||
} |
|
@ -1,25 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
func (m enumerable) All(predicate interface{}) bool { |
|
||||
iterator := m.GetEnumerator() |
|
||||
predicateRV := reflect.ValueOf(predicate) |
|
||||
for ok := iterator.MoveNext(); ok; ok = iterator.MoveNext() { |
|
||||
returnRVs := predicateRV.Call([]reflect.Value{ |
|
||||
iterator.GetValue(), |
|
||||
iterator.GetKey(), |
|
||||
}) |
|
||||
if !returnRVs[0].Bool() { |
|
||||
return false |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return true |
|
||||
} |
|
||||
|
|
||||
func (m enumerable) AllBy(dict map[string]interface{}) bool { |
|
||||
return m.All(func(v, _ interface{}) bool { |
|
||||
return IsMatch(v, dict) |
|
||||
}) |
|
||||
} |
|
@ -1,25 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
func (m enumerable) Any(predicate interface{}) bool { |
|
||||
iterator := m.GetEnumerator() |
|
||||
predicateRV := reflect.ValueOf(predicate) |
|
||||
for ok := iterator.MoveNext(); ok; ok = iterator.MoveNext() { |
|
||||
returnRVs := predicateRV.Call([]reflect.Value{ |
|
||||
iterator.GetValue(), |
|
||||
iterator.GetKey(), |
|
||||
}) |
|
||||
if returnRVs[0].Bool() { |
|
||||
return true |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return false |
|
||||
} |
|
||||
|
|
||||
func (m enumerable) AnyBy(dict map[string]interface{}) bool { |
|
||||
return m.Any(func(v, _ interface{}) bool { |
|
||||
return IsMatch(v, dict) |
|
||||
}) |
|
||||
} |
|
@ -1,76 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
// Chain is 初始化
|
|
||||
func Chain(src interface{}) IEnumerable { |
|
||||
return chainFromRV( |
|
||||
reflect.ValueOf(src), |
|
||||
) |
|
||||
} |
|
||||
|
|
||||
func chainFromArrayOrSlice(srcRV reflect.Value, size int) IEnumerable { |
|
||||
return enumerable{ |
|
||||
Enumerator: func() IEnumerator { |
|
||||
index := 0 |
|
||||
return &enumerator{ |
|
||||
MoveNextFunc: func() (valueRV reflect.Value, keyRV reflect.Value, ok bool) { |
|
||||
ok = index < size |
|
||||
if ok { |
|
||||
valueRV = srcRV.Index(index) |
|
||||
keyRV = reflect.ValueOf(index) |
|
||||
index++ |
|
||||
} |
|
||||
|
|
||||
return |
|
||||
}, |
|
||||
} |
|
||||
}, |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
func chainFromMap(srcRV reflect.Value, size int) IEnumerable { |
|
||||
return enumerable{ |
|
||||
Enumerator: func() IEnumerator { |
|
||||
index := 0 |
|
||||
keyRVs := srcRV.MapKeys() |
|
||||
return &enumerator{ |
|
||||
MoveNextFunc: func() (valueRV reflect.Value, keyRV reflect.Value, ok bool) { |
|
||||
ok = index < size |
|
||||
if ok { |
|
||||
valueRV = srcRV.MapIndex(keyRVs[index]) |
|
||||
keyRV = keyRVs[index] |
|
||||
index++ |
|
||||
} |
|
||||
|
|
||||
return |
|
||||
}, |
|
||||
} |
|
||||
}, |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
func chainFromRV(rv reflect.Value) IEnumerable { |
|
||||
switch rv.Kind() { |
|
||||
case reflect.Array, reflect.Slice: |
|
||||
return chainFromArrayOrSlice(rv, rv.Len()) |
|
||||
case reflect.Map: |
|
||||
return chainFromMap(rv, rv.Len()) |
|
||||
default: |
|
||||
if iterator, ok := rv.Interface().(IEnumerator); ok { |
|
||||
return enumerable{ |
|
||||
Enumerator: func() IEnumerator { |
|
||||
return iterator |
|
||||
}, |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return enumerable{ |
|
||||
Enumerator: func() IEnumerator { |
|
||||
return nullEnumerator{ |
|
||||
Src: rv, |
|
||||
} |
|
||||
}, |
|
||||
} |
|
||||
} |
|
||||
} |
|
@ -1,11 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
func (m enumerable) Count() int { |
|
||||
iterator := m.GetEnumerator() |
|
||||
count := 0 |
|
||||
for ok := iterator.MoveNext(); ok; ok = iterator.MoveNext() { |
|
||||
count++ |
|
||||
} |
|
||||
|
|
||||
return count |
|
||||
} |
|
@ -1,44 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
func (m enumerable) Distinct(selector interface{}) IEnumerable { |
|
||||
if selector == nil { |
|
||||
selector = func(value, _ interface{}) facade { |
|
||||
return facade{ |
|
||||
reflect.ValueOf(value), |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return enumerable{ |
|
||||
Enumerator: func() IEnumerator { |
|
||||
iterator := m.GetEnumerator() |
|
||||
selectorRV := reflect.ValueOf(selector) |
|
||||
set := make(map[interface{}]bool) |
|
||||
return &enumerator{ |
|
||||
MoveNextFunc: func() (valueRV reflect.Value, keyRV reflect.Value, ok bool) { |
|
||||
for ok = iterator.MoveNext(); ok; ok = iterator.MoveNext() { |
|
||||
valueRV = iterator.GetValue() |
|
||||
keyRV = iterator.GetKey() |
|
||||
v := getFuncReturnRV(selectorRV, iterator).Interface() |
|
||||
if _, has := set[v]; !has { |
|
||||
set[v] = true |
|
||||
return |
|
||||
} |
|
||||
} |
|
||||
return |
|
||||
}, |
|
||||
} |
|
||||
}, |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
func (m enumerable) DistinctBy(fieldName string) IEnumerable { |
|
||||
getter := PropertyRV(fieldName) |
|
||||
return m.Distinct(func(value, _ interface{}) facade { |
|
||||
return facade{ |
|
||||
getter(value), |
|
||||
} |
|
||||
}) |
|
||||
} |
|
@ -1,14 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
func (m enumerable) Each(action interface{}) { |
|
||||
iterator := m.GetEnumerator() |
|
||||
actionRV := reflect.ValueOf(action) |
|
||||
for ok := iterator.MoveNext(); ok; ok = iterator.MoveNext() { |
|
||||
actionRV.Call([]reflect.Value{ |
|
||||
iterator.GetValue(), |
|
||||
iterator.GetKey(), |
|
||||
}) |
|
||||
} |
|
||||
} |
|
@ -1,9 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
type enumerable struct { |
|
||||
Enumerator func() IEnumerator |
|
||||
} |
|
||||
|
|
||||
func (m enumerable) GetEnumerator() IEnumerator { |
|
||||
return m.Enumerator() |
|
||||
} |
|
@ -1,25 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import ( |
|
||||
"reflect" |
|
||||
) |
|
||||
|
|
||||
type enumerator struct { |
|
||||
MoveNextFunc func() (reflect.Value, reflect.Value, bool) |
|
||||
|
|
||||
key reflect.Value |
|
||||
value reflect.Value |
|
||||
} |
|
||||
|
|
||||
func (m enumerator) GetKey() reflect.Value { |
|
||||
return m.key |
|
||||
} |
|
||||
|
|
||||
func (m enumerator) GetValue() reflect.Value { |
|
||||
return getRealRV(m.value) |
|
||||
} |
|
||||
|
|
||||
func (m *enumerator) MoveNext() (ok bool) { |
|
||||
m.value, m.key, ok = m.MoveNextFunc() |
|
||||
return |
|
||||
} |
|
@ -1,7 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
type facade struct { |
|
||||
Real reflect.Value |
|
||||
} |
|
@ -1,9 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
func (m enumerable) Filter(predicate interface{}) IEnumerable { |
|
||||
return m.Where(predicate) |
|
||||
} |
|
||||
|
|
||||
func (m enumerable) FilterBy(dict map[string]interface{}) IEnumerable { |
|
||||
return m.WhereBy(dict) |
|
||||
} |
|
@ -1,28 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
func (m enumerable) FindIndex(predicate interface{}) int { |
|
||||
iterator := m.GetEnumerator() |
|
||||
predicateRV := reflect.ValueOf(predicate) |
|
||||
index := 0 |
|
||||
for ok := iterator.MoveNext(); ok; ok = iterator.MoveNext() { |
|
||||
returnRVs := predicateRV.Call([]reflect.Value{ |
|
||||
iterator.GetValue(), |
|
||||
iterator.GetKey(), |
|
||||
}) |
|
||||
if returnRVs[0].Bool() { |
|
||||
return index |
|
||||
} |
|
||||
|
|
||||
index++ |
|
||||
} |
|
||||
|
|
||||
return -1 |
|
||||
} |
|
||||
|
|
||||
func (m enumerable) FindIndexBy(dict map[string]interface{}) int { |
|
||||
return m.FindIndex(func(v, _ interface{}) bool { |
|
||||
return IsMatch(v, dict) |
|
||||
}) |
|
||||
} |
|
@ -1,27 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
func (m enumerable) Find(predicate interface{}) IEnumerable { |
|
||||
iterator := m.GetEnumerator() |
|
||||
predicateRV := reflect.ValueOf(predicate) |
|
||||
for ok := iterator.MoveNext(); ok; ok = iterator.MoveNext() { |
|
||||
returnRVs := predicateRV.Call([]reflect.Value{ |
|
||||
iterator.GetValue(), |
|
||||
iterator.GetKey(), |
|
||||
}) |
|
||||
if returnRVs[0].Bool() { |
|
||||
return chainFromRV( |
|
||||
iterator.GetValue(), |
|
||||
) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return nilEnumerable |
|
||||
} |
|
||||
|
|
||||
func (m enumerable) FindBy(dict map[string]interface{}) IEnumerable { |
|
||||
return m.Find(func(v, _ interface{}) bool { |
|
||||
return IsMatch(v, dict) |
|
||||
}) |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
func (m enumerable) First() IEnumerable { |
|
||||
iterator := m.GetEnumerator() |
|
||||
for ok := iterator.MoveNext(); ok; ok = iterator.MoveNext() { |
|
||||
return chainFromRV( |
|
||||
iterator.GetValue(), |
|
||||
) |
|
||||
} |
|
||||
|
|
||||
return nilEnumerable |
|
||||
} |
|
@ -1,53 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
func (m enumerable) Group(keySelector interface{}) enumerable { |
|
||||
return enumerable{ |
|
||||
Enumerator: func() IEnumerator { |
|
||||
groupRVs := make(map[interface{}]reflect.Value) |
|
||||
iterator := m.GetEnumerator() |
|
||||
keySelectorRV := reflect.ValueOf(keySelector) |
|
||||
keyRVs := make([]reflect.Value, 0) |
|
||||
for ok := iterator.MoveNext(); ok; ok = iterator.MoveNext() { |
|
||||
keyRV := getFuncReturnRV(keySelectorRV, iterator) |
|
||||
key := keyRV.Interface() |
|
||||
groupRV, ok := groupRVs[key] |
|
||||
if !ok { |
|
||||
groupRV = reflect.MakeSlice( |
|
||||
reflect.SliceOf( |
|
||||
iterator.GetValue().Type(), |
|
||||
), |
|
||||
0, |
|
||||
0, |
|
||||
) |
|
||||
keyRVs = append(keyRVs, keyRV) |
|
||||
} |
|
||||
groupRVs[key] = reflect.Append( |
|
||||
groupRV, |
|
||||
iterator.GetValue(), |
|
||||
) |
|
||||
} |
|
||||
index := 0 |
|
||||
return &enumerator{ |
|
||||
MoveNextFunc: func() (valueRV reflect.Value, keyRV reflect.Value, ok bool) { |
|
||||
if ok = index < len(keyRVs); ok { |
|
||||
keyRV = keyRVs[index] |
|
||||
valueRV = groupRVs[keyRV.Interface()] |
|
||||
index++ |
|
||||
} |
|
||||
return |
|
||||
}, |
|
||||
} |
|
||||
}, |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
func (m enumerable) GroupBy(fieldName string) enumerable { |
|
||||
getter := PropertyRV(fieldName) |
|
||||
return m.Group(func(value, _ interface{}) facade { |
|
||||
return facade{ |
|
||||
getter(value), |
|
||||
} |
|
||||
}) |
|
||||
} |
|
@ -1,46 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
// IEnumerable is 迭代器接口
|
|
||||
type IEnumerable interface { |
|
||||
Aggregate(memo interface{}, fn interface{}) IEnumerable |
|
||||
All(predicate interface{}) bool |
|
||||
AllBy(dict map[string]interface{}) bool |
|
||||
Any(predicate interface{}) bool |
|
||||
AnyBy(dict map[string]interface{}) bool |
|
||||
Count() int |
|
||||
Distinct(selector interface{}) IEnumerable |
|
||||
DistinctBy(fieldName string) IEnumerable |
|
||||
Each(action interface{}) |
|
||||
Filter(predicate interface{}) IEnumerable |
|
||||
FilterBy(dict map[string]interface{}) IEnumerable |
|
||||
Find(predicate interface{}) IEnumerable |
|
||||
FindBy(dict map[string]interface{}) IEnumerable |
|
||||
FindIndex(predicate interface{}) int |
|
||||
FindIndexBy(dict map[string]interface{}) int |
|
||||
First() IEnumerable |
|
||||
GetEnumerator() IEnumerator |
|
||||
Group(keySelector interface{}) enumerable |
|
||||
GroupBy(fieldName string) enumerable |
|
||||
Index(keySelector interface{}) IEnumerable |
|
||||
IndexBy(fieldName string) IEnumerable |
|
||||
Keys() IEnumerable |
|
||||
Map(selector interface{}) IEnumerable |
|
||||
MapBy(fieldName string) IEnumerable |
|
||||
MapMany(selector interface{}) IEnumerable |
|
||||
MapManyBy(fieldName string) IEnumerable |
|
||||
Object() IEnumerable |
|
||||
Reduce(memo interface{}, fn interface{}) IEnumerable |
|
||||
Select(selector interface{}) IEnumerable |
|
||||
SelectBy(fieldName string) IEnumerable |
|
||||
SelectMany(selector interface{}) IEnumerable |
|
||||
SelectManyBy(fieldName string) IEnumerable |
|
||||
Size() int |
|
||||
Skip(count int) IEnumerable |
|
||||
Take(count int) IEnumerable |
|
||||
Uniq(selector interface{}) IEnumerable |
|
||||
UniqBy(fieldName string) IEnumerable |
|
||||
Value(res interface{}) |
|
||||
Values() IEnumerable |
|
||||
Where(predicate interface{}) IEnumerable |
|
||||
WhereBy(dict map[string]interface{}) IEnumerable |
|
||||
} |
|
@ -1,10 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
// IEnumerator is 迭代器接口
|
|
||||
type IEnumerator interface { |
|
||||
GetKey() reflect.Value |
|
||||
GetValue() reflect.Value |
|
||||
MoveNext() bool |
|
||||
} |
|
@ -1,31 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
func (m enumerable) Index(keySelector interface{}) IEnumerable { |
|
||||
return enumerable{ |
|
||||
Enumerator: func() IEnumerator { |
|
||||
iterator := m.GetEnumerator() |
|
||||
keySelectorRV := reflect.ValueOf(keySelector) |
|
||||
return &enumerator{ |
|
||||
MoveNextFunc: func() (valueRV reflect.Value, keyRV reflect.Value, ok bool) { |
|
||||
if ok = iterator.MoveNext(); ok { |
|
||||
keyRV = getFuncReturnRV(keySelectorRV, iterator) |
|
||||
valueRV = iterator.GetValue() |
|
||||
} |
|
||||
|
|
||||
return |
|
||||
}, |
|
||||
} |
|
||||
}, |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
func (m enumerable) IndexBy(fieldName string) IEnumerable { |
|
||||
getter := PropertyRV(fieldName) |
|
||||
return m.Index(func(value, _ interface{}) facade { |
|
||||
return facade{ |
|
||||
getter(value), |
|
||||
} |
|
||||
}) |
|
||||
} |
|
@ -1,9 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
// IsArray is 判断是否数组或者切片
|
|
||||
func IsArray(v interface{}) bool { |
|
||||
rv := reflect.ValueOf(v) |
|
||||
return rv.Kind() == reflect.Array || rv.Kind() == reflect.Slice |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
// IsMatch is 对象中的属性名与属性值都与map的key和value相同
|
|
||||
func IsMatch(item interface{}, properties map[string]interface{}) bool { |
|
||||
if item == nil || len(properties) == 0 { |
|
||||
return false |
|
||||
} |
|
||||
|
|
||||
return Chain(properties).All(func(v interface{}, k string) bool { |
|
||||
return Property(k)(item) == v |
|
||||
}) |
|
||||
} |
|
@ -1,23 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
func (m enumerable) Keys() IEnumerable { |
|
||||
return enumerable{ |
|
||||
Enumerator: func() IEnumerator { |
|
||||
index := 0 |
|
||||
iterator := m.GetEnumerator() |
|
||||
return &enumerator{ |
|
||||
MoveNextFunc: func() (valueRV reflect.Value, keyRV reflect.Value, ok bool) { |
|
||||
if ok = iterator.MoveNext(); ok { |
|
||||
valueRV = iterator.GetKey() |
|
||||
keyRV = reflect.ValueOf(index) |
|
||||
index++ |
|
||||
} |
|
||||
|
|
||||
return |
|
||||
}, |
|
||||
} |
|
||||
}, |
|
||||
} |
|
||||
} |
|
@ -1 +0,0 @@ |
|||||
package underscore |
|
@ -1,9 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
func (m enumerable) MapMany(selector interface{}) IEnumerable { |
|
||||
return m.SelectMany(selector) |
|
||||
} |
|
||||
|
|
||||
func (m enumerable) MapManyBy(fieldName string) IEnumerable { |
|
||||
return m.SelectManyBy(fieldName) |
|
||||
} |
|
@ -1,9 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
func (m enumerable) Map(selector interface{}) IEnumerable { |
|
||||
return m.Select(selector) |
|
||||
} |
|
||||
|
|
||||
func (m enumerable) MapBy(fieldName string) IEnumerable { |
|
||||
return m.SelectBy(fieldName) |
|
||||
} |
|
@ -1,25 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import ( |
|
||||
"reflect" |
|
||||
) |
|
||||
|
|
||||
type nullEnumerator struct { |
|
||||
Src reflect.Value |
|
||||
} |
|
||||
|
|
||||
func (m nullEnumerator) GetKey() reflect.Value { |
|
||||
return nilRV |
|
||||
} |
|
||||
|
|
||||
func (m nullEnumerator) GetValue() reflect.Value { |
|
||||
if m.Src.IsValid() && m.Src.Type() == facadeRT { |
|
||||
return m.Src.Interface().(facade).Real |
|
||||
} |
|
||||
|
|
||||
return m.Src |
|
||||
} |
|
||||
|
|
||||
func (m nullEnumerator) MoveNext() bool { |
|
||||
return false |
|
||||
} |
|
@ -1,21 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
func (m enumerable) Object() IEnumerable { |
|
||||
iterator := m.GetEnumerator() |
|
||||
return enumerable{ |
|
||||
Enumerator: func() IEnumerator { |
|
||||
return &enumerator{ |
|
||||
MoveNextFunc: func() (valueRV reflect.Value, keyRV reflect.Value, ok bool) { |
|
||||
if ok = iterator.MoveNext(); ok { |
|
||||
keyRV = iterator.GetValue().Index(0).Elem() |
|
||||
valueRV = iterator.GetValue().Index(1).Elem() |
|
||||
} |
|
||||
|
|
||||
return |
|
||||
}, |
|
||||
} |
|
||||
}, |
|
||||
} |
|
||||
} |
|
@ -1,44 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import ( |
|
||||
"reflect" |
|
||||
"strings" |
|
||||
) |
|
||||
|
|
||||
// GetProeprtyRVFunc is get property reflect.Value func
|
|
||||
type GetProeprtyRVFunc func(interface{}) reflect.Value |
|
||||
|
|
||||
// Property is 获取属性函数
|
|
||||
func Property(name string) func(interface{}) interface{} { |
|
||||
fn := PropertyRV(name) |
|
||||
return func(item interface{}) interface{} { |
|
||||
return fn(item).Interface() |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// PropertyRV is 获取reflect.Value
|
|
||||
func PropertyRV(name string) GetProeprtyRVFunc { |
|
||||
var getter GetProeprtyRVFunc |
|
||||
getter = func(item interface{}) reflect.Value { |
|
||||
itemRV := getRealRV(item) |
|
||||
itemRT := itemRV.Type() |
|
||||
for i := 0; i < itemRT.NumField(); i++ { |
|
||||
field := itemRT.Field(i) |
|
||||
if field.Anonymous { |
|
||||
rv := getter( |
|
||||
itemRV.Field(i), |
|
||||
) |
|
||||
if rv != nilRV { |
|
||||
return rv |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if strings.ToLower(name) == strings.ToLower(field.Name) { |
|
||||
return itemRV.Field(i) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return nilRV |
|
||||
} |
|
||||
return getter |
|
||||
} |
|
@ -1,6 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
type query struct { |
|
||||
IsParallel bool |
|
||||
Source interface{} |
|
||||
} |
|
@ -1,34 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
// Range is 生成范围内的整数序列
|
|
||||
func Range(start, stop, step int) IEnumerable { |
|
||||
if step == 0 { |
|
||||
panic("step can not equal 0") |
|
||||
} |
|
||||
|
|
||||
return enumerable{ |
|
||||
Enumerator: func() IEnumerator { |
|
||||
current := start |
|
||||
index := 0 |
|
||||
return &enumerator{ |
|
||||
MoveNextFunc: func() (valueRV reflect.Value, keyRV reflect.Value, ok bool) { |
|
||||
if step > 0 { |
|
||||
ok = current < stop |
|
||||
} else { |
|
||||
ok = current > stop |
|
||||
} |
|
||||
if ok { |
|
||||
valueRV = reflect.ValueOf(current) |
|
||||
keyRV = reflect.ValueOf(index) |
|
||||
current += step |
|
||||
index++ |
|
||||
} |
|
||||
|
|
||||
return |
|
||||
}, |
|
||||
} |
|
||||
}, |
|
||||
} |
|
||||
} |
|
@ -1,5 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
func (m enumerable) Reduce(memo interface{}, fn interface{}) IEnumerable { |
|
||||
return m.Aggregate(memo, fn) |
|
||||
} |
|
@ -1 +0,0 @@ |
|||||
package underscore |
|
@ -1 +0,0 @@ |
|||||
package underscore |
|
@ -1,45 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
func (m enumerable) SelectMany(selector interface{}) IEnumerable { |
|
||||
return enumerable{ |
|
||||
Enumerator: func() IEnumerator { |
|
||||
var tempIterator IEnumerator |
|
||||
iterator := m.GetEnumerator() |
|
||||
selectorRV := reflect.ValueOf(selector) |
|
||||
return &enumerator{ |
|
||||
MoveNextFunc: func() (valueRV reflect.Value, keyRV reflect.Value, ok bool) { |
|
||||
for !ok { |
|
||||
if tempIterator == nil { |
|
||||
ok = iterator.MoveNext() |
|
||||
if !ok { |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
selectorResultRV := getFuncReturnRV(selectorRV, iterator) |
|
||||
tempIterator = chainFromRV(selectorResultRV).GetEnumerator() |
|
||||
} |
|
||||
|
|
||||
if ok = tempIterator.MoveNext(); ok { |
|
||||
keyRV = tempIterator.GetKey() |
|
||||
valueRV = tempIterator.GetValue() |
|
||||
} else { |
|
||||
tempIterator = nil |
|
||||
} |
|
||||
} |
|
||||
return |
|
||||
}, |
|
||||
} |
|
||||
}, |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
func (m enumerable) SelectManyBy(fieldName string) IEnumerable { |
|
||||
getter := PropertyRV(fieldName) |
|
||||
return m.SelectMany(func(value, _ interface{}) facade { |
|
||||
return facade{ |
|
||||
getter(value), |
|
||||
} |
|
||||
}) |
|
||||
} |
|
@ -1,31 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
func (m enumerable) Select(selector interface{}) IEnumerable { |
|
||||
return enumerable{ |
|
||||
Enumerator: func() IEnumerator { |
|
||||
iterator := m.GetEnumerator() |
|
||||
selectorRV := reflect.ValueOf(selector) |
|
||||
return &enumerator{ |
|
||||
MoveNextFunc: func() (valueRV reflect.Value, keyRV reflect.Value, ok bool) { |
|
||||
if ok = iterator.MoveNext(); ok { |
|
||||
keyRV = iterator.GetKey() |
|
||||
valueRV = getFuncReturnRV(selectorRV, iterator) |
|
||||
} |
|
||||
|
|
||||
return |
|
||||
}, |
|
||||
} |
|
||||
}, |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
func (m enumerable) SelectBy(fieldName string) IEnumerable { |
|
||||
getter := PropertyRV(fieldName) |
|
||||
return m.Select(func(value, _ interface{}) facade { |
|
||||
return facade{ |
|
||||
getter(value), |
|
||||
} |
|
||||
}) |
|
||||
} |
|
@ -1,5 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
func (m enumerable) Size() int { |
|
||||
return m.Count() |
|
||||
} |
|
@ -1,26 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
func (m enumerable) Skip(count int) IEnumerable { |
|
||||
return enumerable{ |
|
||||
Enumerator: func() IEnumerator { |
|
||||
iterator := m.GetEnumerator() |
|
||||
return &enumerator{ |
|
||||
MoveNextFunc: func() (valueRV reflect.Value, keyRV reflect.Value, ok bool) { |
|
||||
for ; count > 0; count-- { |
|
||||
if !iterator.MoveNext() { |
|
||||
return |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if ok = iterator.MoveNext(); ok { |
|
||||
valueRV = iterator.GetValue() |
|
||||
keyRV = iterator.GetKey() |
|
||||
} |
|
||||
return |
|
||||
}, |
|
||||
} |
|
||||
}, |
|
||||
} |
|
||||
} |
|
@ -1 +0,0 @@ |
|||||
package underscore |
|
@ -1,26 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
func (m enumerable) Take(count int) IEnumerable { |
|
||||
return enumerable{ |
|
||||
Enumerator: func() IEnumerator { |
|
||||
iterator := m.GetEnumerator() |
|
||||
return &enumerator{ |
|
||||
MoveNextFunc: func() (valueRV reflect.Value, keyRV reflect.Value, ok bool) { |
|
||||
if count <= 0 { |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
count-- |
|
||||
if ok = iterator.MoveNext(); ok { |
|
||||
valueRV = iterator.GetValue() |
|
||||
keyRV = iterator.GetKey() |
|
||||
} |
|
||||
|
|
||||
return |
|
||||
}, |
|
||||
} |
|
||||
}, |
|
||||
} |
|
||||
} |
|
@ -1,9 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
func (m enumerable) Uniq(predicate interface{}) IEnumerable { |
|
||||
return m.Distinct(predicate) |
|
||||
} |
|
||||
|
|
||||
func (m enumerable) UniqBy(fieldName string) IEnumerable { |
|
||||
return m.DistinctBy(fieldName) |
|
||||
} |
|
@ -1,29 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
func getRealRV(v interface{}) reflect.Value { |
|
||||
rv := reflect.ValueOf(v) |
|
||||
if rv.Type() == rtOfRV { |
|
||||
rv = v.(reflect.Value) |
|
||||
} |
|
||||
|
|
||||
if rv.Kind() == reflect.Ptr { |
|
||||
rv = rv.Elem() |
|
||||
} |
|
||||
|
|
||||
if rv.Type() == facadeRT { |
|
||||
rv = rv.Interface().(facade).Real |
|
||||
} |
|
||||
|
|
||||
return rv |
|
||||
} |
|
||||
|
|
||||
func getFuncReturnRV(selectorRV reflect.Value, enumerator IEnumerator) reflect.Value { |
|
||||
return getRealRV( |
|
||||
selectorRV.Call([]reflect.Value{ |
|
||||
enumerator.GetValue(), |
|
||||
enumerator.GetKey(), |
|
||||
})[0], |
|
||||
) |
|
||||
} |
|
@ -1,44 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
func (m enumerable) Value(res interface{}) { |
|
||||
resRV := reflect.ValueOf(res) |
|
||||
switch resRV.Elem().Kind() { |
|
||||
case reflect.Array, reflect.Slice: |
|
||||
m.valueToArrayOrSlice(resRV) |
|
||||
case reflect.Map: |
|
||||
m.valueToMap(resRV) |
|
||||
default: |
|
||||
if nullIterator, ok := m.GetEnumerator().(nullEnumerator); ok { |
|
||||
if rv := nullIterator.GetValue(); rv.IsValid() { |
|
||||
resRV.Elem().Set(rv) |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
func (m enumerable) valueToArrayOrSlice(resRV reflect.Value) { |
|
||||
iterator := m.GetEnumerator() |
|
||||
sliceRV := resRV.Elem() |
|
||||
for ok := iterator.MoveNext(); ok; ok = iterator.MoveNext() { |
|
||||
sliceRV = reflect.Append( |
|
||||
sliceRV, |
|
||||
iterator.GetValue(), |
|
||||
) |
|
||||
} |
|
||||
|
|
||||
resRV.Elem().Set(sliceRV) |
|
||||
} |
|
||||
|
|
||||
func (m enumerable) valueToMap(resRV reflect.Value) { |
|
||||
iterator := m.GetEnumerator() |
|
||||
mapRV := resRV.Elem() |
|
||||
for ok := iterator.MoveNext(); ok; ok = iterator.MoveNext() { |
|
||||
mapRV.SetMapIndex( |
|
||||
iterator.GetKey(), |
|
||||
iterator.GetValue(), |
|
||||
) |
|
||||
} |
|
||||
resRV.Elem().Set(mapRV) |
|
||||
} |
|
@ -1,23 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
func (m enumerable) Values() IEnumerable { |
|
||||
return enumerable{ |
|
||||
Enumerator: func() IEnumerator { |
|
||||
index := 0 |
|
||||
iterator := m.GetEnumerator() |
|
||||
return &enumerator{ |
|
||||
MoveNextFunc: func() (valueRV reflect.Value, keyRV reflect.Value, ok bool) { |
|
||||
if ok = iterator.MoveNext(); ok { |
|
||||
valueRV = iterator.GetValue() |
|
||||
keyRV = reflect.ValueOf(index) |
|
||||
index++ |
|
||||
} |
|
||||
|
|
||||
return |
|
||||
}, |
|
||||
} |
|
||||
}, |
|
||||
} |
|
||||
} |
|
@ -1,16 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
var ( |
|
||||
facadeRT = reflect.TypeOf(facade{}) |
|
||||
nilEnumerable = enumerable{ |
|
||||
Enumerator: func() IEnumerator { |
|
||||
return nullEnumerator{ |
|
||||
Src: nilRV, |
|
||||
} |
|
||||
}, |
|
||||
} |
|
||||
nilRV = reflect.ValueOf(nil) |
|
||||
rtOfRV = reflect.TypeOf(nilRV) |
|
||||
) |
|
@ -1,31 +0,0 @@ |
|||||
package underscore |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
func (m enumerable) Where(predicate interface{}) IEnumerable { |
|
||||
return enumerable{ |
|
||||
Enumerator: func() IEnumerator { |
|
||||
iterator := m.GetEnumerator() |
|
||||
predicateRV := reflect.ValueOf(predicate) |
|
||||
return &enumerator{ |
|
||||
MoveNextFunc: func() (valueRV reflect.Value, keyRV reflect.Value, ok bool) { |
|
||||
for ok = iterator.MoveNext(); ok; ok = iterator.MoveNext() { |
|
||||
valueRV = iterator.GetValue() |
|
||||
keyRV = iterator.GetKey() |
|
||||
if predicateRV.Call([]reflect.Value{valueRV, keyRV})[0].Bool() { |
|
||||
return |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return |
|
||||
}, |
|
||||
} |
|
||||
}, |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
func (m enumerable) WhereBy(dict map[string]interface{}) IEnumerable { |
|
||||
return m.Where(func(v, _ interface{}) bool { |
|
||||
return IsMatch(v, dict) |
|
||||
}) |
|
||||
} |
|
@ -1,15 +0,0 @@ |
|||||
ISC License |
|
||||
|
|
||||
Copyright (c) 2012-2016 Dave Collins <dave@davec.name> |
|
||||
|
|
||||
Permission to use, copy, modify, and/or distribute this software for any |
|
||||
purpose with or without fee is hereby granted, provided that the above |
|
||||
copyright notice and this permission notice appear in all copies. |
|
||||
|
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
@ -1,145 +0,0 @@ |
|||||
// Copyright (c) 2015-2016 Dave Collins <dave@davec.name>
|
|
||||
//
|
|
||||
// Permission to use, copy, modify, and distribute this software for any
|
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
|
||||
// copyright notice and this permission notice appear in all copies.
|
|
||||
//
|
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||
|
|
||||
// NOTE: Due to the following build constraints, this file will only be compiled
|
|
||||
// when the code is not running on Google App Engine, compiled by GopherJS, and
|
|
||||
// "-tags safe" is not added to the go build command line. The "disableunsafe"
|
|
||||
// tag is deprecated and thus should not be used.
|
|
||||
// Go versions prior to 1.4 are disabled because they use a different layout
|
|
||||
// for interfaces which make the implementation of unsafeReflectValue more complex.
|
|
||||
// +build !js,!appengine,!safe,!disableunsafe,go1.4
|
|
||||
|
|
||||
package spew |
|
||||
|
|
||||
import ( |
|
||||
"reflect" |
|
||||
"unsafe" |
|
||||
) |
|
||||
|
|
||||
const ( |
|
||||
// UnsafeDisabled is a build-time constant which specifies whether or
|
|
||||
// not access to the unsafe package is available.
|
|
||||
UnsafeDisabled = false |
|
||||
|
|
||||
// ptrSize is the size of a pointer on the current arch.
|
|
||||
ptrSize = unsafe.Sizeof((*byte)(nil)) |
|
||||
) |
|
||||
|
|
||||
type flag uintptr |
|
||||
|
|
||||
var ( |
|
||||
// flagRO indicates whether the value field of a reflect.Value
|
|
||||
// is read-only.
|
|
||||
flagRO flag |
|
||||
|
|
||||
// flagAddr indicates whether the address of the reflect.Value's
|
|
||||
// value may be taken.
|
|
||||
flagAddr flag |
|
||||
) |
|
||||
|
|
||||
// flagKindMask holds the bits that make up the kind
|
|
||||
// part of the flags field. In all the supported versions,
|
|
||||
// it is in the lower 5 bits.
|
|
||||
const flagKindMask = flag(0x1f) |
|
||||
|
|
||||
// Different versions of Go have used different
|
|
||||
// bit layouts for the flags type. This table
|
|
||||
// records the known combinations.
|
|
||||
var okFlags = []struct { |
|
||||
ro, addr flag |
|
||||
}{{ |
|
||||
// From Go 1.4 to 1.5
|
|
||||
ro: 1 << 5, |
|
||||
addr: 1 << 7, |
|
||||
}, { |
|
||||
// Up to Go tip.
|
|
||||
ro: 1<<5 | 1<<6, |
|
||||
addr: 1 << 8, |
|
||||
}} |
|
||||
|
|
||||
var flagValOffset = func() uintptr { |
|
||||
field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag") |
|
||||
if !ok { |
|
||||
panic("reflect.Value has no flag field") |
|
||||
} |
|
||||
return field.Offset |
|
||||
}() |
|
||||
|
|
||||
// flagField returns a pointer to the flag field of a reflect.Value.
|
|
||||
func flagField(v *reflect.Value) *flag { |
|
||||
return (*flag)(unsafe.Pointer(uintptr(unsafe.Pointer(v)) + flagValOffset)) |
|
||||
} |
|
||||
|
|
||||
// unsafeReflectValue converts the passed reflect.Value into a one that bypasses
|
|
||||
// the typical safety restrictions preventing access to unaddressable and
|
|
||||
// unexported data. It works by digging the raw pointer to the underlying
|
|
||||
// value out of the protected value and generating a new unprotected (unsafe)
|
|
||||
// reflect.Value to it.
|
|
||||
//
|
|
||||
// This allows us to check for implementations of the Stringer and error
|
|
||||
// interfaces to be used for pretty printing ordinarily unaddressable and
|
|
||||
// inaccessible values such as unexported struct fields.
|
|
||||
func unsafeReflectValue(v reflect.Value) reflect.Value { |
|
||||
if !v.IsValid() || (v.CanInterface() && v.CanAddr()) { |
|
||||
return v |
|
||||
} |
|
||||
flagFieldPtr := flagField(&v) |
|
||||
*flagFieldPtr &^= flagRO |
|
||||
*flagFieldPtr |= flagAddr |
|
||||
return v |
|
||||
} |
|
||||
|
|
||||
// Sanity checks against future reflect package changes
|
|
||||
// to the type or semantics of the Value.flag field.
|
|
||||
func init() { |
|
||||
field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag") |
|
||||
if !ok { |
|
||||
panic("reflect.Value has no flag field") |
|
||||
} |
|
||||
if field.Type.Kind() != reflect.TypeOf(flag(0)).Kind() { |
|
||||
panic("reflect.Value flag field has changed kind") |
|
||||
} |
|
||||
type t0 int |
|
||||
var t struct { |
|
||||
A t0 |
|
||||
// t0 will have flagEmbedRO set.
|
|
||||
t0 |
|
||||
// a will have flagStickyRO set
|
|
||||
a t0 |
|
||||
} |
|
||||
vA := reflect.ValueOf(t).FieldByName("A") |
|
||||
va := reflect.ValueOf(t).FieldByName("a") |
|
||||
vt0 := reflect.ValueOf(t).FieldByName("t0") |
|
||||
|
|
||||
// Infer flagRO from the difference between the flags
|
|
||||
// for the (otherwise identical) fields in t.
|
|
||||
flagPublic := *flagField(&vA) |
|
||||
flagWithRO := *flagField(&va) | *flagField(&vt0) |
|
||||
flagRO = flagPublic ^ flagWithRO |
|
||||
|
|
||||
// Infer flagAddr from the difference between a value
|
|
||||
// taken from a pointer and not.
|
|
||||
vPtrA := reflect.ValueOf(&t).Elem().FieldByName("A") |
|
||||
flagNoPtr := *flagField(&vA) |
|
||||
flagPtr := *flagField(&vPtrA) |
|
||||
flagAddr = flagNoPtr ^ flagPtr |
|
||||
|
|
||||
// Check that the inferred flags tally with one of the known versions.
|
|
||||
for _, f := range okFlags { |
|
||||
if flagRO == f.ro && flagAddr == f.addr { |
|
||||
return |
|
||||
} |
|
||||
} |
|
||||
panic("reflect.Value read-only flag has changed semantics") |
|
||||
} |
|
@ -1,38 +0,0 @@ |
|||||
// Copyright (c) 2015-2016 Dave Collins <dave@davec.name>
|
|
||||
//
|
|
||||
// Permission to use, copy, modify, and distribute this software for any
|
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
|
||||
// copyright notice and this permission notice appear in all copies.
|
|
||||
//
|
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||
|
|
||||
// NOTE: Due to the following build constraints, this file will only be compiled
|
|
||||
// when the code is running on Google App Engine, compiled by GopherJS, or
|
|
||||
// "-tags safe" is added to the go build command line. The "disableunsafe"
|
|
||||
// tag is deprecated and thus should not be used.
|
|
||||
// +build js appengine safe disableunsafe !go1.4
|
|
||||
|
|
||||
package spew |
|
||||
|
|
||||
import "reflect" |
|
||||
|
|
||||
const ( |
|
||||
// UnsafeDisabled is a build-time constant which specifies whether or
|
|
||||
// not access to the unsafe package is available.
|
|
||||
UnsafeDisabled = true |
|
||||
) |
|
||||
|
|
||||
// unsafeReflectValue typically converts the passed reflect.Value into a one
|
|
||||
// that bypasses the typical safety restrictions preventing access to
|
|
||||
// unaddressable and unexported data. However, doing this relies on access to
|
|
||||
// the unsafe package. This is a stub version which simply returns the passed
|
|
||||
// reflect.Value when the unsafe package is not available.
|
|
||||
func unsafeReflectValue(v reflect.Value) reflect.Value { |
|
||||
return v |
|
||||
} |
|
@ -1,341 +0,0 @@ |
|||||
/* |
|
||||
* Copyright (c) 2013-2016 Dave Collins <dave@davec.name> |
|
||||
* |
|
||||
* Permission to use, copy, modify, and distribute this software for any |
|
||||
* purpose with or without fee is hereby granted, provided that the above |
|
||||
* copyright notice and this permission notice appear in all copies. |
|
||||
* |
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
||||
*/ |
|
||||
|
|
||||
package spew |
|
||||
|
|
||||
import ( |
|
||||
"bytes" |
|
||||
"fmt" |
|
||||
"io" |
|
||||
"reflect" |
|
||||
"sort" |
|
||||
"strconv" |
|
||||
) |
|
||||
|
|
||||
// Some constants in the form of bytes to avoid string overhead. This mirrors
|
|
||||
// the technique used in the fmt package.
|
|
||||
var ( |
|
||||
panicBytes = []byte("(PANIC=") |
|
||||
plusBytes = []byte("+") |
|
||||
iBytes = []byte("i") |
|
||||
trueBytes = []byte("true") |
|
||||
falseBytes = []byte("false") |
|
||||
interfaceBytes = []byte("(interface {})") |
|
||||
commaNewlineBytes = []byte(",\n") |
|
||||
newlineBytes = []byte("\n") |
|
||||
openBraceBytes = []byte("{") |
|
||||
openBraceNewlineBytes = []byte("{\n") |
|
||||
closeBraceBytes = []byte("}") |
|
||||
asteriskBytes = []byte("*") |
|
||||
colonBytes = []byte(":") |
|
||||
colonSpaceBytes = []byte(": ") |
|
||||
openParenBytes = []byte("(") |
|
||||
closeParenBytes = []byte(")") |
|
||||
spaceBytes = []byte(" ") |
|
||||
pointerChainBytes = []byte("->") |
|
||||
nilAngleBytes = []byte("<nil>") |
|
||||
maxNewlineBytes = []byte("<max depth reached>\n") |
|
||||
maxShortBytes = []byte("<max>") |
|
||||
circularBytes = []byte("<already shown>") |
|
||||
circularShortBytes = []byte("<shown>") |
|
||||
invalidAngleBytes = []byte("<invalid>") |
|
||||
openBracketBytes = []byte("[") |
|
||||
closeBracketBytes = []byte("]") |
|
||||
percentBytes = []byte("%") |
|
||||
precisionBytes = []byte(".") |
|
||||
openAngleBytes = []byte("<") |
|
||||
closeAngleBytes = []byte(">") |
|
||||
openMapBytes = []byte("map[") |
|
||||
closeMapBytes = []byte("]") |
|
||||
lenEqualsBytes = []byte("len=") |
|
||||
capEqualsBytes = []byte("cap=") |
|
||||
) |
|
||||
|
|
||||
// hexDigits is used to map a decimal value to a hex digit.
|
|
||||
var hexDigits = "0123456789abcdef" |
|
||||
|
|
||||
// catchPanic handles any panics that might occur during the handleMethods
|
|
||||
// calls.
|
|
||||
func catchPanic(w io.Writer, v reflect.Value) { |
|
||||
if err := recover(); err != nil { |
|
||||
w.Write(panicBytes) |
|
||||
fmt.Fprintf(w, "%v", err) |
|
||||
w.Write(closeParenBytes) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// handleMethods attempts to call the Error and String methods on the underlying
|
|
||||
// type the passed reflect.Value represents and outputes the result to Writer w.
|
|
||||
//
|
|
||||
// It handles panics in any called methods by catching and displaying the error
|
|
||||
// as the formatted value.
|
|
||||
func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool) { |
|
||||
// We need an interface to check if the type implements the error or
|
|
||||
// Stringer interface. However, the reflect package won't give us an
|
|
||||
// interface on certain things like unexported struct fields in order
|
|
||||
// to enforce visibility rules. We use unsafe, when it's available,
|
|
||||
// to bypass these restrictions since this package does not mutate the
|
|
||||
// values.
|
|
||||
if !v.CanInterface() { |
|
||||
if UnsafeDisabled { |
|
||||
return false |
|
||||
} |
|
||||
|
|
||||
v = unsafeReflectValue(v) |
|
||||
} |
|
||||
|
|
||||
// Choose whether or not to do error and Stringer interface lookups against
|
|
||||
// the base type or a pointer to the base type depending on settings.
|
|
||||
// Technically calling one of these methods with a pointer receiver can
|
|
||||
// mutate the value, however, types which choose to satisify an error or
|
|
||||
// Stringer interface with a pointer receiver should not be mutating their
|
|
||||
// state inside these interface methods.
|
|
||||
if !cs.DisablePointerMethods && !UnsafeDisabled && !v.CanAddr() { |
|
||||
v = unsafeReflectValue(v) |
|
||||
} |
|
||||
if v.CanAddr() { |
|
||||
v = v.Addr() |
|
||||
} |
|
||||
|
|
||||
// Is it an error or Stringer?
|
|
||||
switch iface := v.Interface().(type) { |
|
||||
case error: |
|
||||
defer catchPanic(w, v) |
|
||||
if cs.ContinueOnMethod { |
|
||||
w.Write(openParenBytes) |
|
||||
w.Write([]byte(iface.Error())) |
|
||||
w.Write(closeParenBytes) |
|
||||
w.Write(spaceBytes) |
|
||||
return false |
|
||||
} |
|
||||
|
|
||||
w.Write([]byte(iface.Error())) |
|
||||
return true |
|
||||
|
|
||||
case fmt.Stringer: |
|
||||
defer catchPanic(w, v) |
|
||||
if cs.ContinueOnMethod { |
|
||||
w.Write(openParenBytes) |
|
||||
w.Write([]byte(iface.String())) |
|
||||
w.Write(closeParenBytes) |
|
||||
w.Write(spaceBytes) |
|
||||
return false |
|
||||
} |
|
||||
w.Write([]byte(iface.String())) |
|
||||
return true |
|
||||
} |
|
||||
return false |
|
||||
} |
|
||||
|
|
||||
// printBool outputs a boolean value as true or false to Writer w.
|
|
||||
func printBool(w io.Writer, val bool) { |
|
||||
if val { |
|
||||
w.Write(trueBytes) |
|
||||
} else { |
|
||||
w.Write(falseBytes) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// printInt outputs a signed integer value to Writer w.
|
|
||||
func printInt(w io.Writer, val int64, base int) { |
|
||||
w.Write([]byte(strconv.FormatInt(val, base))) |
|
||||
} |
|
||||
|
|
||||
// printUint outputs an unsigned integer value to Writer w.
|
|
||||
func printUint(w io.Writer, val uint64, base int) { |
|
||||
w.Write([]byte(strconv.FormatUint(val, base))) |
|
||||
} |
|
||||
|
|
||||
// printFloat outputs a floating point value using the specified precision,
|
|
||||
// which is expected to be 32 or 64bit, to Writer w.
|
|
||||
func printFloat(w io.Writer, val float64, precision int) { |
|
||||
w.Write([]byte(strconv.FormatFloat(val, 'g', -1, precision))) |
|
||||
} |
|
||||
|
|
||||
// printComplex outputs a complex value using the specified float precision
|
|
||||
// for the real and imaginary parts to Writer w.
|
|
||||
func printComplex(w io.Writer, c complex128, floatPrecision int) { |
|
||||
r := real(c) |
|
||||
w.Write(openParenBytes) |
|
||||
w.Write([]byte(strconv.FormatFloat(r, 'g', -1, floatPrecision))) |
|
||||
i := imag(c) |
|
||||
if i >= 0 { |
|
||||
w.Write(plusBytes) |
|
||||
} |
|
||||
w.Write([]byte(strconv.FormatFloat(i, 'g', -1, floatPrecision))) |
|
||||
w.Write(iBytes) |
|
||||
w.Write(closeParenBytes) |
|
||||
} |
|
||||
|
|
||||
// printHexPtr outputs a uintptr formatted as hexadecimal with a leading '0x'
|
|
||||
// prefix to Writer w.
|
|
||||
func printHexPtr(w io.Writer, p uintptr) { |
|
||||
// Null pointer.
|
|
||||
num := uint64(p) |
|
||||
if num == 0 { |
|
||||
w.Write(nilAngleBytes) |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
// Max uint64 is 16 bytes in hex + 2 bytes for '0x' prefix
|
|
||||
buf := make([]byte, 18) |
|
||||
|
|
||||
// It's simpler to construct the hex string right to left.
|
|
||||
base := uint64(16) |
|
||||
i := len(buf) - 1 |
|
||||
for num >= base { |
|
||||
buf[i] = hexDigits[num%base] |
|
||||
num /= base |
|
||||
i-- |
|
||||
} |
|
||||
buf[i] = hexDigits[num] |
|
||||
|
|
||||
// Add '0x' prefix.
|
|
||||
i-- |
|
||||
buf[i] = 'x' |
|
||||
i-- |
|
||||
buf[i] = '0' |
|
||||
|
|
||||
// Strip unused leading bytes.
|
|
||||
buf = buf[i:] |
|
||||
w.Write(buf) |
|
||||
} |
|
||||
|
|
||||
// valuesSorter implements sort.Interface to allow a slice of reflect.Value
|
|
||||
// elements to be sorted.
|
|
||||
type valuesSorter struct { |
|
||||
values []reflect.Value |
|
||||
strings []string // either nil or same len and values
|
|
||||
cs *ConfigState |
|
||||
} |
|
||||
|
|
||||
// newValuesSorter initializes a valuesSorter instance, which holds a set of
|
|
||||
// surrogate keys on which the data should be sorted. It uses flags in
|
|
||||
// ConfigState to decide if and how to populate those surrogate keys.
|
|
||||
func newValuesSorter(values []reflect.Value, cs *ConfigState) sort.Interface { |
|
||||
vs := &valuesSorter{values: values, cs: cs} |
|
||||
if canSortSimply(vs.values[0].Kind()) { |
|
||||
return vs |
|
||||
} |
|
||||
if !cs.DisableMethods { |
|
||||
vs.strings = make([]string, len(values)) |
|
||||
for i := range vs.values { |
|
||||
b := bytes.Buffer{} |
|
||||
if !handleMethods(cs, &b, vs.values[i]) { |
|
||||
vs.strings = nil |
|
||||
break |
|
||||
} |
|
||||
vs.strings[i] = b.String() |
|
||||
} |
|
||||
} |
|
||||
if vs.strings == nil && cs.SpewKeys { |
|
||||
vs.strings = make([]string, len(values)) |
|
||||
for i := range vs.values { |
|
||||
vs.strings[i] = Sprintf("%#v", vs.values[i].Interface()) |
|
||||
} |
|
||||
} |
|
||||
return vs |
|
||||
} |
|
||||
|
|
||||
// canSortSimply tests whether a reflect.Kind is a primitive that can be sorted
|
|
||||
// directly, or whether it should be considered for sorting by surrogate keys
|
|
||||
// (if the ConfigState allows it).
|
|
||||
func canSortSimply(kind reflect.Kind) bool { |
|
||||
// This switch parallels valueSortLess, except for the default case.
|
|
||||
switch kind { |
|
||||
case reflect.Bool: |
|
||||
return true |
|
||||
case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: |
|
||||
return true |
|
||||
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: |
|
||||
return true |
|
||||
case reflect.Float32, reflect.Float64: |
|
||||
return true |
|
||||
case reflect.String: |
|
||||
return true |
|
||||
case reflect.Uintptr: |
|
||||
return true |
|
||||
case reflect.Array: |
|
||||
return true |
|
||||
} |
|
||||
return false |
|
||||
} |
|
||||
|
|
||||
// Len returns the number of values in the slice. It is part of the
|
|
||||
// sort.Interface implementation.
|
|
||||
func (s *valuesSorter) Len() int { |
|
||||
return len(s.values) |
|
||||
} |
|
||||
|
|
||||
// Swap swaps the values at the passed indices. It is part of the
|
|
||||
// sort.Interface implementation.
|
|
||||
func (s *valuesSorter) Swap(i, j int) { |
|
||||
s.values[i], s.values[j] = s.values[j], s.values[i] |
|
||||
if s.strings != nil { |
|
||||
s.strings[i], s.strings[j] = s.strings[j], s.strings[i] |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// valueSortLess returns whether the first value should sort before the second
|
|
||||
// value. It is used by valueSorter.Less as part of the sort.Interface
|
|
||||
// implementation.
|
|
||||
func valueSortLess(a, b reflect.Value) bool { |
|
||||
switch a.Kind() { |
|
||||
case reflect.Bool: |
|
||||
return !a.Bool() && b.Bool() |
|
||||
case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: |
|
||||
return a.Int() < b.Int() |
|
||||
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: |
|
||||
return a.Uint() < b.Uint() |
|
||||
case reflect.Float32, reflect.Float64: |
|
||||
return a.Float() < b.Float() |
|
||||
case reflect.String: |
|
||||
return a.String() < b.String() |
|
||||
case reflect.Uintptr: |
|
||||
return a.Uint() < b.Uint() |
|
||||
case reflect.Array: |
|
||||
// Compare the contents of both arrays.
|
|
||||
l := a.Len() |
|
||||
for i := 0; i < l; i++ { |
|
||||
av := a.Index(i) |
|
||||
bv := b.Index(i) |
|
||||
if av.Interface() == bv.Interface() { |
|
||||
continue |
|
||||
} |
|
||||
return valueSortLess(av, bv) |
|
||||
} |
|
||||
} |
|
||||
return a.String() < b.String() |
|
||||
} |
|
||||
|
|
||||
// Less returns whether the value at index i should sort before the
|
|
||||
// value at index j. It is part of the sort.Interface implementation.
|
|
||||
func (s *valuesSorter) Less(i, j int) bool { |
|
||||
if s.strings == nil { |
|
||||
return valueSortLess(s.values[i], s.values[j]) |
|
||||
} |
|
||||
return s.strings[i] < s.strings[j] |
|
||||
} |
|
||||
|
|
||||
// sortValues is a sort function that handles both native types and any type that
|
|
||||
// can be converted to error or Stringer. Other inputs are sorted according to
|
|
||||
// their Value.String() value to ensure display stability.
|
|
||||
func sortValues(values []reflect.Value, cs *ConfigState) { |
|
||||
if len(values) == 0 { |
|
||||
return |
|
||||
} |
|
||||
sort.Sort(newValuesSorter(values, cs)) |
|
||||
} |
|
@ -1,306 +0,0 @@ |
|||||
/* |
|
||||
* Copyright (c) 2013-2016 Dave Collins <dave@davec.name> |
|
||||
* |
|
||||
* Permission to use, copy, modify, and distribute this software for any |
|
||||
* purpose with or without fee is hereby granted, provided that the above |
|
||||
* copyright notice and this permission notice appear in all copies. |
|
||||
* |
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
||||
*/ |
|
||||
|
|
||||
package spew |
|
||||
|
|
||||
import ( |
|
||||
"bytes" |
|
||||
"fmt" |
|
||||
"io" |
|
||||
"os" |
|
||||
) |
|
||||
|
|
||||
// ConfigState houses the configuration options used by spew to format and
|
|
||||
// display values. There is a global instance, Config, that is used to control
|
|
||||
// all top-level Formatter and Dump functionality. Each ConfigState instance
|
|
||||
// provides methods equivalent to the top-level functions.
|
|
||||
//
|
|
||||
// The zero value for ConfigState provides no indentation. You would typically
|
|
||||
// want to set it to a space or a tab.
|
|
||||
//
|
|
||||
// Alternatively, you can use NewDefaultConfig to get a ConfigState instance
|
|
||||
// with default settings. See the documentation of NewDefaultConfig for default
|
|
||||
// values.
|
|
||||
type ConfigState struct { |
|
||||
// Indent specifies the string to use for each indentation level. The
|
|
||||
// global config instance that all top-level functions use set this to a
|
|
||||
// single space by default. If you would like more indentation, you might
|
|
||||
// set this to a tab with "\t" or perhaps two spaces with " ".
|
|
||||
Indent string |
|
||||
|
|
||||
// MaxDepth controls the maximum number of levels to descend into nested
|
|
||||
// data structures. The default, 0, means there is no limit.
|
|
||||
//
|
|
||||
// NOTE: Circular data structures are properly detected, so it is not
|
|
||||
// necessary to set this value unless you specifically want to limit deeply
|
|
||||
// nested data structures.
|
|
||||
MaxDepth int |
|
||||
|
|
||||
// DisableMethods specifies whether or not error and Stringer interfaces are
|
|
||||
// invoked for types that implement them.
|
|
||||
DisableMethods bool |
|
||||
|
|
||||
// DisablePointerMethods specifies whether or not to check for and invoke
|
|
||||
// error and Stringer interfaces on types which only accept a pointer
|
|
||||
// receiver when the current type is not a pointer.
|
|
||||
//
|
|
||||
// NOTE: This might be an unsafe action since calling one of these methods
|
|
||||
// with a pointer receiver could technically mutate the value, however,
|
|
||||
// in practice, types which choose to satisify an error or Stringer
|
|
||||
// interface with a pointer receiver should not be mutating their state
|
|
||||
// inside these interface methods. As a result, this option relies on
|
|
||||
// access to the unsafe package, so it will not have any effect when
|
|
||||
// running in environments without access to the unsafe package such as
|
|
||||
// Google App Engine or with the "safe" build tag specified.
|
|
||||
DisablePointerMethods bool |
|
||||
|
|
||||
// DisablePointerAddresses specifies whether to disable the printing of
|
|
||||
// pointer addresses. This is useful when diffing data structures in tests.
|
|
||||
DisablePointerAddresses bool |
|
||||
|
|
||||
// DisableCapacities specifies whether to disable the printing of capacities
|
|
||||
// for arrays, slices, maps and channels. This is useful when diffing
|
|
||||
// data structures in tests.
|
|
||||
DisableCapacities bool |
|
||||
|
|
||||
// ContinueOnMethod specifies whether or not recursion should continue once
|
|
||||
// a custom error or Stringer interface is invoked. The default, false,
|
|
||||
// means it will print the results of invoking the custom error or Stringer
|
|
||||
// interface and return immediately instead of continuing to recurse into
|
|
||||
// the internals of the data type.
|
|
||||
//
|
|
||||
// NOTE: This flag does not have any effect if method invocation is disabled
|
|
||||
// via the DisableMethods or DisablePointerMethods options.
|
|
||||
ContinueOnMethod bool |
|
||||
|
|
||||
// SortKeys specifies map keys should be sorted before being printed. Use
|
|
||||
// this to have a more deterministic, diffable output. Note that only
|
|
||||
// native types (bool, int, uint, floats, uintptr and string) and types
|
|
||||
// that support the error or Stringer interfaces (if methods are
|
|
||||
// enabled) are supported, with other types sorted according to the
|
|
||||
// reflect.Value.String() output which guarantees display stability.
|
|
||||
SortKeys bool |
|
||||
|
|
||||
// SpewKeys specifies that, as a last resort attempt, map keys should
|
|
||||
// be spewed to strings and sorted by those strings. This is only
|
|
||||
// considered if SortKeys is true.
|
|
||||
SpewKeys bool |
|
||||
} |
|
||||
|
|
||||
// Config is the active configuration of the top-level functions.
|
|
||||
// The configuration can be changed by modifying the contents of spew.Config.
|
|
||||
var Config = ConfigState{Indent: " "} |
|
||||
|
|
||||
// Errorf is a wrapper for fmt.Errorf that treats each argument as if it were
|
|
||||
// passed with a Formatter interface returned by c.NewFormatter. It returns
|
|
||||
// the formatted string as a value that satisfies error. See NewFormatter
|
|
||||
// for formatting details.
|
|
||||
//
|
|
||||
// This function is shorthand for the following syntax:
|
|
||||
//
|
|
||||
// fmt.Errorf(format, c.NewFormatter(a), c.NewFormatter(b))
|
|
||||
func (c *ConfigState) Errorf(format string, a ...interface{}) (err error) { |
|
||||
return fmt.Errorf(format, c.convertArgs(a)...) |
|
||||
} |
|
||||
|
|
||||
// Fprint is a wrapper for fmt.Fprint that treats each argument as if it were
|
|
||||
// passed with a Formatter interface returned by c.NewFormatter. It returns
|
|
||||
// the number of bytes written and any write error encountered. See
|
|
||||
// NewFormatter for formatting details.
|
|
||||
//
|
|
||||
// This function is shorthand for the following syntax:
|
|
||||
//
|
|
||||
// fmt.Fprint(w, c.NewFormatter(a), c.NewFormatter(b))
|
|
||||
func (c *ConfigState) Fprint(w io.Writer, a ...interface{}) (n int, err error) { |
|
||||
return fmt.Fprint(w, c.convertArgs(a)...) |
|
||||
} |
|
||||
|
|
||||
// Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were
|
|
||||
// passed with a Formatter interface returned by c.NewFormatter. It returns
|
|
||||
// the number of bytes written and any write error encountered. See
|
|
||||
// NewFormatter for formatting details.
|
|
||||
//
|
|
||||
// This function is shorthand for the following syntax:
|
|
||||
//
|
|
||||
// fmt.Fprintf(w, format, c.NewFormatter(a), c.NewFormatter(b))
|
|
||||
func (c *ConfigState) Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) { |
|
||||
return fmt.Fprintf(w, format, c.convertArgs(a)...) |
|
||||
} |
|
||||
|
|
||||
// Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it
|
|
||||
// passed with a Formatter interface returned by c.NewFormatter. See
|
|
||||
// NewFormatter for formatting details.
|
|
||||
//
|
|
||||
// This function is shorthand for the following syntax:
|
|
||||
//
|
|
||||
// fmt.Fprintln(w, c.NewFormatter(a), c.NewFormatter(b))
|
|
||||
func (c *ConfigState) Fprintln(w io.Writer, a ...interface{}) (n int, err error) { |
|
||||
return fmt.Fprintln(w, c.convertArgs(a)...) |
|
||||
} |
|
||||
|
|
||||
// Print is a wrapper for fmt.Print that treats each argument as if it were
|
|
||||
// passed with a Formatter interface returned by c.NewFormatter. It returns
|
|
||||
// the number of bytes written and any write error encountered. See
|
|
||||
// NewFormatter for formatting details.
|
|
||||
//
|
|
||||
// This function is shorthand for the following syntax:
|
|
||||
//
|
|
||||
// fmt.Print(c.NewFormatter(a), c.NewFormatter(b))
|
|
||||
func (c *ConfigState) Print(a ...interface{}) (n int, err error) { |
|
||||
return fmt.Print(c.convertArgs(a)...) |
|
||||
} |
|
||||
|
|
||||
// Printf is a wrapper for fmt.Printf that treats each argument as if it were
|
|
||||
// passed with a Formatter interface returned by c.NewFormatter. It returns
|
|
||||
// the number of bytes written and any write error encountered. See
|
|
||||
// NewFormatter for formatting details.
|
|
||||
//
|
|
||||
// This function is shorthand for the following syntax:
|
|
||||
//
|
|
||||
// fmt.Printf(format, c.NewFormatter(a), c.NewFormatter(b))
|
|
||||
func (c *ConfigState) Printf(format string, a ...interface{}) (n int, err error) { |
|
||||
return fmt.Printf(format, c.convertArgs(a)...) |
|
||||
} |
|
||||
|
|
||||
// Println is a wrapper for fmt.Println that treats each argument as if it were
|
|
||||
// passed with a Formatter interface returned by c.NewFormatter. It returns
|
|
||||
// the number of bytes written and any write error encountered. See
|
|
||||
// NewFormatter for formatting details.
|
|
||||
//
|
|
||||
// This function is shorthand for the following syntax:
|
|
||||
//
|
|
||||
// fmt.Println(c.NewFormatter(a), c.NewFormatter(b))
|
|
||||
func (c *ConfigState) Println(a ...interface{}) (n int, err error) { |
|
||||
return fmt.Println(c.convertArgs(a)...) |
|
||||
} |
|
||||
|
|
||||
// Sprint is a wrapper for fmt.Sprint that treats each argument as if it were
|
|
||||
// passed with a Formatter interface returned by c.NewFormatter. It returns
|
|
||||
// the resulting string. See NewFormatter for formatting details.
|
|
||||
//
|
|
||||
// This function is shorthand for the following syntax:
|
|
||||
//
|
|
||||
// fmt.Sprint(c.NewFormatter(a), c.NewFormatter(b))
|
|
||||
func (c *ConfigState) Sprint(a ...interface{}) string { |
|
||||
return fmt.Sprint(c.convertArgs(a)...) |
|
||||
} |
|
||||
|
|
||||
// Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were
|
|
||||
// passed with a Formatter interface returned by c.NewFormatter. It returns
|
|
||||
// the resulting string. See NewFormatter for formatting details.
|
|
||||
//
|
|
||||
// This function is shorthand for the following syntax:
|
|
||||
//
|
|
||||
// fmt.Sprintf(format, c.NewFormatter(a), c.NewFormatter(b))
|
|
||||
func (c *ConfigState) Sprintf(format string, a ...interface{}) string { |
|
||||
return fmt.Sprintf(format, c.convertArgs(a)...) |
|
||||
} |
|
||||
|
|
||||
// Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it
|
|
||||
// were passed with a Formatter interface returned by c.NewFormatter. It
|
|
||||
// returns the resulting string. See NewFormatter for formatting details.
|
|
||||
//
|
|
||||
// This function is shorthand for the following syntax:
|
|
||||
//
|
|
||||
// fmt.Sprintln(c.NewFormatter(a), c.NewFormatter(b))
|
|
||||
func (c *ConfigState) Sprintln(a ...interface{}) string { |
|
||||
return fmt.Sprintln(c.convertArgs(a)...) |
|
||||
} |
|
||||
|
|
||||
/* |
|
||||
NewFormatter returns a custom formatter that satisfies the fmt.Formatter |
|
||||
interface. As a result, it integrates cleanly with standard fmt package |
|
||||
printing functions. The formatter is useful for inline printing of smaller data |
|
||||
types similar to the standard %v format specifier. |
|
||||
|
|
||||
The custom formatter only responds to the %v (most compact), %+v (adds pointer |
|
||||
addresses), %#v (adds types), and %#+v (adds types and pointer addresses) verb |
|
||||
combinations. Any other verbs such as %x and %q will be sent to the the |
|
||||
standard fmt package for formatting. In addition, the custom formatter ignores |
|
||||
the width and precision arguments (however they will still work on the format |
|
||||
specifiers not handled by the custom formatter). |
|
||||
|
|
||||
Typically this function shouldn't be called directly. It is much easier to make |
|
||||
use of the custom formatter by calling one of the convenience functions such as |
|
||||
c.Printf, c.Println, or c.Printf. |
|
||||
*/ |
|
||||
func (c *ConfigState) NewFormatter(v interface{}) fmt.Formatter { |
|
||||
return newFormatter(c, v) |
|
||||
} |
|
||||
|
|
||||
// Fdump formats and displays the passed arguments to io.Writer w. It formats
|
|
||||
// exactly the same as Dump.
|
|
||||
func (c *ConfigState) Fdump(w io.Writer, a ...interface{}) { |
|
||||
fdump(c, w, a...) |
|
||||
} |
|
||||
|
|
||||
/* |
|
||||
Dump displays the passed parameters to standard out with newlines, customizable |
|
||||
indentation, and additional debug information such as complete types and all |
|
||||
pointer addresses used to indirect to the final value. It provides the |
|
||||
following features over the built-in printing facilities provided by the fmt |
|
||||
package: |
|
||||
|
|
||||
* Pointers are dereferenced and followed |
|
||||
* Circular data structures are detected and handled properly |
|
||||
* Custom Stringer/error interfaces are optionally invoked, including |
|
||||
on unexported types |
|
||||
* Custom types which only implement the Stringer/error interfaces via |
|
||||
a pointer receiver are optionally invoked when passing non-pointer |
|
||||
variables |
|
||||
* Byte arrays and slices are dumped like the hexdump -C command which |
|
||||
includes offsets, byte values in hex, and ASCII output |
|
||||
|
|
||||
The configuration options are controlled by modifying the public members |
|
||||
of c. See ConfigState for options documentation. |
|
||||
|
|
||||
See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to |
|
||||
get the formatted result as a string. |
|
||||
*/ |
|
||||
func (c *ConfigState) Dump(a ...interface{}) { |
|
||||
fdump(c, os.Stdout, a...) |
|
||||
} |
|
||||
|
|
||||
// Sdump returns a string with the passed arguments formatted exactly the same
|
|
||||
// as Dump.
|
|
||||
func (c *ConfigState) Sdump(a ...interface{}) string { |
|
||||
var buf bytes.Buffer |
|
||||
fdump(c, &buf, a...) |
|
||||
return buf.String() |
|
||||
} |
|
||||
|
|
||||
// convertArgs accepts a slice of arguments and returns a slice of the same
|
|
||||
// length with each argument converted to a spew Formatter interface using
|
|
||||
// the ConfigState associated with s.
|
|
||||
func (c *ConfigState) convertArgs(args []interface{}) (formatters []interface{}) { |
|
||||
formatters = make([]interface{}, len(args)) |
|
||||
for index, arg := range args { |
|
||||
formatters[index] = newFormatter(c, arg) |
|
||||
} |
|
||||
return formatters |
|
||||
} |
|
||||
|
|
||||
// NewDefaultConfig returns a ConfigState with the following default settings.
|
|
||||
//
|
|
||||
// Indent: " "
|
|
||||
// MaxDepth: 0
|
|
||||
// DisableMethods: false
|
|
||||
// DisablePointerMethods: false
|
|
||||
// ContinueOnMethod: false
|
|
||||
// SortKeys: false
|
|
||||
func NewDefaultConfig() *ConfigState { |
|
||||
return &ConfigState{Indent: " "} |
|
||||
} |
|
@ -1,211 +0,0 @@ |
|||||
/* |
|
||||
* Copyright (c) 2013-2016 Dave Collins <dave@davec.name> |
|
||||
* |
|
||||
* Permission to use, copy, modify, and distribute this software for any |
|
||||
* purpose with or without fee is hereby granted, provided that the above |
|
||||
* copyright notice and this permission notice appear in all copies. |
|
||||
* |
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
||||
*/ |
|
||||
|
|
||||
/* |
|
||||
Package spew implements a deep pretty printer for Go data structures to aid in |
|
||||
debugging. |
|
||||
|
|
||||
A quick overview of the additional features spew provides over the built-in |
|
||||
printing facilities for Go data types are as follows: |
|
||||
|
|
||||
* Pointers are dereferenced and followed |
|
||||
* Circular data structures are detected and handled properly |
|
||||
* Custom Stringer/error interfaces are optionally invoked, including |
|
||||
on unexported types |
|
||||
* Custom types which only implement the Stringer/error interfaces via |
|
||||
a pointer receiver are optionally invoked when passing non-pointer |
|
||||
variables |
|
||||
* Byte arrays and slices are dumped like the hexdump -C command which |
|
||||
includes offsets, byte values in hex, and ASCII output (only when using |
|
||||
Dump style) |
|
||||
|
|
||||
There are two different approaches spew allows for dumping Go data structures: |
|
||||
|
|
||||
* Dump style which prints with newlines, customizable indentation, |
|
||||
and additional debug information such as types and all pointer addresses |
|
||||
used to indirect to the final value |
|
||||
* A custom Formatter interface that integrates cleanly with the standard fmt |
|
||||
package and replaces %v, %+v, %#v, and %#+v to provide inline printing |
|
||||
similar to the default %v while providing the additional functionality |
|
||||
outlined above and passing unsupported format verbs such as %x and %q |
|
||||
along to fmt |
|
||||
|
|
||||
Quick Start |
|
||||
|
|
||||
This section demonstrates how to quickly get started with spew. See the |
|
||||
sections below for further details on formatting and configuration options. |
|
||||
|
|
||||
To dump a variable with full newlines, indentation, type, and pointer |
|
||||
information use Dump, Fdump, or Sdump: |
|
||||
spew.Dump(myVar1, myVar2, ...) |
|
||||
spew.Fdump(someWriter, myVar1, myVar2, ...) |
|
||||
str := spew.Sdump(myVar1, myVar2, ...) |
|
||||
|
|
||||
Alternatively, if you would prefer to use format strings with a compacted inline |
|
||||
printing style, use the convenience wrappers Printf, Fprintf, etc with |
|
||||
%v (most compact), %+v (adds pointer addresses), %#v (adds types), or |
|
||||
%#+v (adds types and pointer addresses): |
|
||||
spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2) |
|
||||
spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) |
|
||||
spew.Fprintf(someWriter, "myVar1: %v -- myVar2: %+v", myVar1, myVar2) |
|
||||
spew.Fprintf(someWriter, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) |
|
||||
|
|
||||
Configuration Options |
|
||||
|
|
||||
Configuration of spew is handled by fields in the ConfigState type. For |
|
||||
convenience, all of the top-level functions use a global state available |
|
||||
via the spew.Config global. |
|
||||
|
|
||||
It is also possible to create a ConfigState instance that provides methods |
|
||||
equivalent to the top-level functions. This allows concurrent configuration |
|
||||
options. See the ConfigState documentation for more details. |
|
||||
|
|
||||
The following configuration options are available: |
|
||||
* Indent |
|
||||
String to use for each indentation level for Dump functions. |
|
||||
It is a single space by default. A popular alternative is "\t". |
|
||||
|
|
||||
* MaxDepth |
|
||||
Maximum number of levels to descend into nested data structures. |
|
||||
There is no limit by default. |
|
||||
|
|
||||
* DisableMethods |
|
||||
Disables invocation of error and Stringer interface methods. |
|
||||
Method invocation is enabled by default. |
|
||||
|
|
||||
* DisablePointerMethods |
|
||||
Disables invocation of error and Stringer interface methods on types |
|
||||
which only accept pointer receivers from non-pointer variables. |
|
||||
Pointer method invocation is enabled by default. |
|
||||
|
|
||||
* DisablePointerAddresses |
|
||||
DisablePointerAddresses specifies whether to disable the printing of |
|
||||
pointer addresses. This is useful when diffing data structures in tests. |
|
||||
|
|
||||
* DisableCapacities |
|
||||
DisableCapacities specifies whether to disable the printing of |
|
||||
capacities for arrays, slices, maps and channels. This is useful when |
|
||||
diffing data structures in tests. |
|
||||
|
|
||||
* ContinueOnMethod |
|
||||
Enables recursion into types after invoking error and Stringer interface |
|
||||
methods. Recursion after method invocation is disabled by default. |
|
||||
|
|
||||
* SortKeys |
|
||||
Specifies map keys should be sorted before being printed. Use |
|
||||
this to have a more deterministic, diffable output. Note that |
|
||||
only native types (bool, int, uint, floats, uintptr and string) |
|
||||
and types which implement error or Stringer interfaces are |
|
||||
supported with other types sorted according to the |
|
||||
reflect.Value.String() output which guarantees display |
|
||||
stability. Natural map order is used by default. |
|
||||
|
|
||||
* SpewKeys |
|
||||
Specifies that, as a last resort attempt, map keys should be |
|
||||
spewed to strings and sorted by those strings. This is only |
|
||||
considered if SortKeys is true. |
|
||||
|
|
||||
Dump Usage |
|
||||
|
|
||||
Simply call spew.Dump with a list of variables you want to dump: |
|
||||
|
|
||||
spew.Dump(myVar1, myVar2, ...) |
|
||||
|
|
||||
You may also call spew.Fdump if you would prefer to output to an arbitrary |
|
||||
io.Writer. For example, to dump to standard error: |
|
||||
|
|
||||
spew.Fdump(os.Stderr, myVar1, myVar2, ...) |
|
||||
|
|
||||
A third option is to call spew.Sdump to get the formatted output as a string: |
|
||||
|
|
||||
str := spew.Sdump(myVar1, myVar2, ...) |
|
||||
|
|
||||
Sample Dump Output |
|
||||
|
|
||||
See the Dump example for details on the setup of the types and variables being |
|
||||
shown here. |
|
||||
|
|
||||
(main.Foo) { |
|
||||
unexportedField: (*main.Bar)(0xf84002e210)({ |
|
||||
flag: (main.Flag) flagTwo, |
|
||||
data: (uintptr) <nil> |
|
||||
}), |
|
||||
ExportedField: (map[interface {}]interface {}) (len=1) { |
|
||||
(string) (len=3) "one": (bool) true |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
Byte (and uint8) arrays and slices are displayed uniquely like the hexdump -C |
|
||||
command as shown. |
|
||||
([]uint8) (len=32 cap=32) { |
|
||||
00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... | |
|
||||
00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0| |
|
||||
00000020 31 32 |12| |
|
||||
} |
|
||||
|
|
||||
Custom Formatter |
|
||||
|
|
||||
Spew provides a custom formatter that implements the fmt.Formatter interface |
|
||||
so that it integrates cleanly with standard fmt package printing functions. The |
|
||||
formatter is useful for inline printing of smaller data types similar to the |
|
||||
standard %v format specifier. |
|
||||
|
|
||||
The custom formatter only responds to the %v (most compact), %+v (adds pointer |
|
||||
addresses), %#v (adds types), or %#+v (adds types and pointer addresses) verb |
|
||||
combinations. Any other verbs such as %x and %q will be sent to the the |
|
||||
standard fmt package for formatting. In addition, the custom formatter ignores |
|
||||
the width and precision arguments (however they will still work on the format |
|
||||
specifiers not handled by the custom formatter). |
|
||||
|
|
||||
Custom Formatter Usage |
|
||||
|
|
||||
The simplest way to make use of the spew custom formatter is to call one of the |
|
||||
convenience functions such as spew.Printf, spew.Println, or spew.Printf. The |
|
||||
functions have syntax you are most likely already familiar with: |
|
||||
|
|
||||
spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2) |
|
||||
spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) |
|
||||
spew.Println(myVar, myVar2) |
|
||||
spew.Fprintf(os.Stderr, "myVar1: %v -- myVar2: %+v", myVar1, myVar2) |
|
||||
spew.Fprintf(os.Stderr, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) |
|
||||
|
|
||||
See the Index for the full list convenience functions. |
|
||||
|
|
||||
Sample Formatter Output |
|
||||
|
|
||||
Double pointer to a uint8: |
|
||||
%v: <**>5 |
|
||||
%+v: <**>(0xf8400420d0->0xf8400420c8)5 |
|
||||
%#v: (**uint8)5 |
|
||||
%#+v: (**uint8)(0xf8400420d0->0xf8400420c8)5 |
|
||||
|
|
||||
Pointer to circular struct with a uint8 field and a pointer to itself: |
|
||||
%v: <*>{1 <*><shown>} |
|
||||
%+v: <*>(0xf84003e260){ui8:1 c:<*>(0xf84003e260)<shown>} |
|
||||
%#v: (*main.circular){ui8:(uint8)1 c:(*main.circular)<shown>} |
|
||||
%#+v: (*main.circular)(0xf84003e260){ui8:(uint8)1 c:(*main.circular)(0xf84003e260)<shown>} |
|
||||
|
|
||||
See the Printf example for details on the setup of variables being shown |
|
||||
here. |
|
||||
|
|
||||
Errors |
|
||||
|
|
||||
Since it is possible for custom Stringer/error interfaces to panic, spew |
|
||||
detects them and handles them internally by printing the panic information |
|
||||
inline with the output. Since spew is intended to provide deep pretty printing |
|
||||
capabilities on structures, it intentionally does not return any errors. |
|
||||
*/ |
|
||||
package spew |
|
@ -1,509 +0,0 @@ |
|||||
/* |
|
||||
* Copyright (c) 2013-2016 Dave Collins <dave@davec.name> |
|
||||
* |
|
||||
* Permission to use, copy, modify, and distribute this software for any |
|
||||
* purpose with or without fee is hereby granted, provided that the above |
|
||||
* copyright notice and this permission notice appear in all copies. |
|
||||
* |
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
||||
*/ |
|
||||
|
|
||||
package spew |
|
||||
|
|
||||
import ( |
|
||||
"bytes" |
|
||||
"encoding/hex" |
|
||||
"fmt" |
|
||||
"io" |
|
||||
"os" |
|
||||
"reflect" |
|
||||
"regexp" |
|
||||
"strconv" |
|
||||
"strings" |
|
||||
) |
|
||||
|
|
||||
var ( |
|
||||
// uint8Type is a reflect.Type representing a uint8. It is used to
|
|
||||
// convert cgo types to uint8 slices for hexdumping.
|
|
||||
uint8Type = reflect.TypeOf(uint8(0)) |
|
||||
|
|
||||
// cCharRE is a regular expression that matches a cgo char.
|
|
||||
// It is used to detect character arrays to hexdump them.
|
|
||||
cCharRE = regexp.MustCompile(`^.*\._Ctype_char$`) |
|
||||
|
|
||||
// cUnsignedCharRE is a regular expression that matches a cgo unsigned
|
|
||||
// char. It is used to detect unsigned character arrays to hexdump
|
|
||||
// them.
|
|
||||
cUnsignedCharRE = regexp.MustCompile(`^.*\._Ctype_unsignedchar$`) |
|
||||
|
|
||||
// cUint8tCharRE is a regular expression that matches a cgo uint8_t.
|
|
||||
// It is used to detect uint8_t arrays to hexdump them.
|
|
||||
cUint8tCharRE = regexp.MustCompile(`^.*\._Ctype_uint8_t$`) |
|
||||
) |
|
||||
|
|
||||
// dumpState contains information about the state of a dump operation.
|
|
||||
type dumpState struct { |
|
||||
w io.Writer |
|
||||
depth int |
|
||||
pointers map[uintptr]int |
|
||||
ignoreNextType bool |
|
||||
ignoreNextIndent bool |
|
||||
cs *ConfigState |
|
||||
} |
|
||||
|
|
||||
// indent performs indentation according to the depth level and cs.Indent
|
|
||||
// option.
|
|
||||
func (d *dumpState) indent() { |
|
||||
if d.ignoreNextIndent { |
|
||||
d.ignoreNextIndent = false |
|
||||
return |
|
||||
} |
|
||||
d.w.Write(bytes.Repeat([]byte(d.cs.Indent), d.depth)) |
|
||||
} |
|
||||
|
|
||||
// unpackValue returns values inside of non-nil interfaces when possible.
|
|
||||
// This is useful for data types like structs, arrays, slices, and maps which
|
|
||||
// can contain varying types packed inside an interface.
|
|
||||
func (d *dumpState) unpackValue(v reflect.Value) reflect.Value { |
|
||||
if v.Kind() == reflect.Interface && !v.IsNil() { |
|
||||
v = v.Elem() |
|
||||
} |
|
||||
return v |
|
||||
} |
|
||||
|
|
||||
// dumpPtr handles formatting of pointers by indirecting them as necessary.
|
|
||||
func (d *dumpState) dumpPtr(v reflect.Value) { |
|
||||
// Remove pointers at or below the current depth from map used to detect
|
|
||||
// circular refs.
|
|
||||
for k, depth := range d.pointers { |
|
||||
if depth >= d.depth { |
|
||||
delete(d.pointers, k) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// Keep list of all dereferenced pointers to show later.
|
|
||||
pointerChain := make([]uintptr, 0) |
|
||||
|
|
||||
// Figure out how many levels of indirection there are by dereferencing
|
|
||||
// pointers and unpacking interfaces down the chain while detecting circular
|
|
||||
// references.
|
|
||||
nilFound := false |
|
||||
cycleFound := false |
|
||||
indirects := 0 |
|
||||
ve := v |
|
||||
for ve.Kind() == reflect.Ptr { |
|
||||
if ve.IsNil() { |
|
||||
nilFound = true |
|
||||
break |
|
||||
} |
|
||||
indirects++ |
|
||||
addr := ve.Pointer() |
|
||||
pointerChain = append(pointerChain, addr) |
|
||||
if pd, ok := d.pointers[addr]; ok && pd < d.depth { |
|
||||
cycleFound = true |
|
||||
indirects-- |
|
||||
break |
|
||||
} |
|
||||
d.pointers[addr] = d.depth |
|
||||
|
|
||||
ve = ve.Elem() |
|
||||
if ve.Kind() == reflect.Interface { |
|
||||
if ve.IsNil() { |
|
||||
nilFound = true |
|
||||
break |
|
||||
} |
|
||||
ve = ve.Elem() |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// Display type information.
|
|
||||
d.w.Write(openParenBytes) |
|
||||
d.w.Write(bytes.Repeat(asteriskBytes, indirects)) |
|
||||
d.w.Write([]byte(ve.Type().String())) |
|
||||
d.w.Write(closeParenBytes) |
|
||||
|
|
||||
// Display pointer information.
|
|
||||
if !d.cs.DisablePointerAddresses && len(pointerChain) > 0 { |
|
||||
d.w.Write(openParenBytes) |
|
||||
for i, addr := range pointerChain { |
|
||||
if i > 0 { |
|
||||
d.w.Write(pointerChainBytes) |
|
||||
} |
|
||||
printHexPtr(d.w, addr) |
|
||||
} |
|
||||
d.w.Write(closeParenBytes) |
|
||||
} |
|
||||
|
|
||||
// Display dereferenced value.
|
|
||||
d.w.Write(openParenBytes) |
|
||||
switch { |
|
||||
case nilFound: |
|
||||
d.w.Write(nilAngleBytes) |
|
||||
|
|
||||
case cycleFound: |
|
||||
d.w.Write(circularBytes) |
|
||||
|
|
||||
default: |
|
||||
d.ignoreNextType = true |
|
||||
d.dump(ve) |
|
||||
} |
|
||||
d.w.Write(closeParenBytes) |
|
||||
} |
|
||||
|
|
||||
// dumpSlice handles formatting of arrays and slices. Byte (uint8 under
|
|
||||
// reflection) arrays and slices are dumped in hexdump -C fashion.
|
|
||||
func (d *dumpState) dumpSlice(v reflect.Value) { |
|
||||
// Determine whether this type should be hex dumped or not. Also,
|
|
||||
// for types which should be hexdumped, try to use the underlying data
|
|
||||
// first, then fall back to trying to convert them to a uint8 slice.
|
|
||||
var buf []uint8 |
|
||||
doConvert := false |
|
||||
doHexDump := false |
|
||||
numEntries := v.Len() |
|
||||
if numEntries > 0 { |
|
||||
vt := v.Index(0).Type() |
|
||||
vts := vt.String() |
|
||||
switch { |
|
||||
// C types that need to be converted.
|
|
||||
case cCharRE.MatchString(vts): |
|
||||
fallthrough |
|
||||
case cUnsignedCharRE.MatchString(vts): |
|
||||
fallthrough |
|
||||
case cUint8tCharRE.MatchString(vts): |
|
||||
doConvert = true |
|
||||
|
|
||||
// Try to use existing uint8 slices and fall back to converting
|
|
||||
// and copying if that fails.
|
|
||||
case vt.Kind() == reflect.Uint8: |
|
||||
// We need an addressable interface to convert the type
|
|
||||
// to a byte slice. However, the reflect package won't
|
|
||||
// give us an interface on certain things like
|
|
||||
// unexported struct fields in order to enforce
|
|
||||
// visibility rules. We use unsafe, when available, to
|
|
||||
// bypass these restrictions since this package does not
|
|
||||
// mutate the values.
|
|
||||
vs := v |
|
||||
if !vs.CanInterface() || !vs.CanAddr() { |
|
||||
vs = unsafeReflectValue(vs) |
|
||||
} |
|
||||
if !UnsafeDisabled { |
|
||||
vs = vs.Slice(0, numEntries) |
|
||||
|
|
||||
// Use the existing uint8 slice if it can be
|
|
||||
// type asserted.
|
|
||||
iface := vs.Interface() |
|
||||
if slice, ok := iface.([]uint8); ok { |
|
||||
buf = slice |
|
||||
doHexDump = true |
|
||||
break |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// The underlying data needs to be converted if it can't
|
|
||||
// be type asserted to a uint8 slice.
|
|
||||
doConvert = true |
|
||||
} |
|
||||
|
|
||||
// Copy and convert the underlying type if needed.
|
|
||||
if doConvert && vt.ConvertibleTo(uint8Type) { |
|
||||
// Convert and copy each element into a uint8 byte
|
|
||||
// slice.
|
|
||||
buf = make([]uint8, numEntries) |
|
||||
for i := 0; i < numEntries; i++ { |
|
||||
vv := v.Index(i) |
|
||||
buf[i] = uint8(vv.Convert(uint8Type).Uint()) |
|
||||
} |
|
||||
doHexDump = true |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// Hexdump the entire slice as needed.
|
|
||||
if doHexDump { |
|
||||
indent := strings.Repeat(d.cs.Indent, d.depth) |
|
||||
str := indent + hex.Dump(buf) |
|
||||
str = strings.Replace(str, "\n", "\n"+indent, -1) |
|
||||
str = strings.TrimRight(str, d.cs.Indent) |
|
||||
d.w.Write([]byte(str)) |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
// Recursively call dump for each item.
|
|
||||
for i := 0; i < numEntries; i++ { |
|
||||
d.dump(d.unpackValue(v.Index(i))) |
|
||||
if i < (numEntries - 1) { |
|
||||
d.w.Write(commaNewlineBytes) |
|
||||
} else { |
|
||||
d.w.Write(newlineBytes) |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// dump is the main workhorse for dumping a value. It uses the passed reflect
|
|
||||
// value to figure out what kind of object we are dealing with and formats it
|
|
||||
// appropriately. It is a recursive function, however circular data structures
|
|
||||
// are detected and handled properly.
|
|
||||
func (d *dumpState) dump(v reflect.Value) { |
|
||||
// Handle invalid reflect values immediately.
|
|
||||
kind := v.Kind() |
|
||||
if kind == reflect.Invalid { |
|
||||
d.w.Write(invalidAngleBytes) |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
// Handle pointers specially.
|
|
||||
if kind == reflect.Ptr { |
|
||||
d.indent() |
|
||||
d.dumpPtr(v) |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
// Print type information unless already handled elsewhere.
|
|
||||
if !d.ignoreNextType { |
|
||||
d.indent() |
|
||||
d.w.Write(openParenBytes) |
|
||||
d.w.Write([]byte(v.Type().String())) |
|
||||
d.w.Write(closeParenBytes) |
|
||||
d.w.Write(spaceBytes) |
|
||||
} |
|
||||
d.ignoreNextType = false |
|
||||
|
|
||||
// Display length and capacity if the built-in len and cap functions
|
|
||||
// work with the value's kind and the len/cap itself is non-zero.
|
|
||||
valueLen, valueCap := 0, 0 |
|
||||
switch v.Kind() { |
|
||||
case reflect.Array, reflect.Slice, reflect.Chan: |
|
||||
valueLen, valueCap = v.Len(), v.Cap() |
|
||||
case reflect.Map, reflect.String: |
|
||||
valueLen = v.Len() |
|
||||
} |
|
||||
if valueLen != 0 || !d.cs.DisableCapacities && valueCap != 0 { |
|
||||
d.w.Write(openParenBytes) |
|
||||
if valueLen != 0 { |
|
||||
d.w.Write(lenEqualsBytes) |
|
||||
printInt(d.w, int64(valueLen), 10) |
|
||||
} |
|
||||
if !d.cs.DisableCapacities && valueCap != 0 { |
|
||||
if valueLen != 0 { |
|
||||
d.w.Write(spaceBytes) |
|
||||
} |
|
||||
d.w.Write(capEqualsBytes) |
|
||||
printInt(d.w, int64(valueCap), 10) |
|
||||
} |
|
||||
d.w.Write(closeParenBytes) |
|
||||
d.w.Write(spaceBytes) |
|
||||
} |
|
||||
|
|
||||
// Call Stringer/error interfaces if they exist and the handle methods flag
|
|
||||
// is enabled
|
|
||||
if !d.cs.DisableMethods { |
|
||||
if (kind != reflect.Invalid) && (kind != reflect.Interface) { |
|
||||
if handled := handleMethods(d.cs, d.w, v); handled { |
|
||||
return |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
switch kind { |
|
||||
case reflect.Invalid: |
|
||||
// Do nothing. We should never get here since invalid has already
|
|
||||
// been handled above.
|
|
||||
|
|
||||
case reflect.Bool: |
|
||||
printBool(d.w, v.Bool()) |
|
||||
|
|
||||
case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: |
|
||||
printInt(d.w, v.Int(), 10) |
|
||||
|
|
||||
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: |
|
||||
printUint(d.w, v.Uint(), 10) |
|
||||
|
|
||||
case reflect.Float32: |
|
||||
printFloat(d.w, v.Float(), 32) |
|
||||
|
|
||||
case reflect.Float64: |
|
||||
printFloat(d.w, v.Float(), 64) |
|
||||
|
|
||||
case reflect.Complex64: |
|
||||
printComplex(d.w, v.Complex(), 32) |
|
||||
|
|
||||
case reflect.Complex128: |
|
||||
printComplex(d.w, v.Complex(), 64) |
|
||||
|
|
||||
case reflect.Slice: |
|
||||
if v.IsNil() { |
|
||||
d.w.Write(nilAngleBytes) |
|
||||
break |
|
||||
} |
|
||||
fallthrough |
|
||||
|
|
||||
case reflect.Array: |
|
||||
d.w.Write(openBraceNewlineBytes) |
|
||||
d.depth++ |
|
||||
if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) { |
|
||||
d.indent() |
|
||||
d.w.Write(maxNewlineBytes) |
|
||||
} else { |
|
||||
d.dumpSlice(v) |
|
||||
} |
|
||||
d.depth-- |
|
||||
d.indent() |
|
||||
d.w.Write(closeBraceBytes) |
|
||||
|
|
||||
case reflect.String: |
|
||||
d.w.Write([]byte(strconv.Quote(v.String()))) |
|
||||
|
|
||||
case reflect.Interface: |
|
||||
// The only time we should get here is for nil interfaces due to
|
|
||||
// unpackValue calls.
|
|
||||
if v.IsNil() { |
|
||||
d.w.Write(nilAngleBytes) |
|
||||
} |
|
||||
|
|
||||
case reflect.Ptr: |
|
||||
// Do nothing. We should never get here since pointers have already
|
|
||||
// been handled above.
|
|
||||
|
|
||||
case reflect.Map: |
|
||||
// nil maps should be indicated as different than empty maps
|
|
||||
if v.IsNil() { |
|
||||
d.w.Write(nilAngleBytes) |
|
||||
break |
|
||||
} |
|
||||
|
|
||||
d.w.Write(openBraceNewlineBytes) |
|
||||
d.depth++ |
|
||||
if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) { |
|
||||
d.indent() |
|
||||
d.w.Write(maxNewlineBytes) |
|
||||
} else { |
|
||||
numEntries := v.Len() |
|
||||
keys := v.MapKeys() |
|
||||
if d.cs.SortKeys { |
|
||||
sortValues(keys, d.cs) |
|
||||
} |
|
||||
for i, key := range keys { |
|
||||
d.dump(d.unpackValue(key)) |
|
||||
d.w.Write(colonSpaceBytes) |
|
||||
d.ignoreNextIndent = true |
|
||||
d.dump(d.unpackValue(v.MapIndex(key))) |
|
||||
if i < (numEntries - 1) { |
|
||||
d.w.Write(commaNewlineBytes) |
|
||||
} else { |
|
||||
d.w.Write(newlineBytes) |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
d.depth-- |
|
||||
d.indent() |
|
||||
d.w.Write(closeBraceBytes) |
|
||||
|
|
||||
case reflect.Struct: |
|
||||
d.w.Write(openBraceNewlineBytes) |
|
||||
d.depth++ |
|
||||
if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) { |
|
||||
d.indent() |
|
||||
d.w.Write(maxNewlineBytes) |
|
||||
} else { |
|
||||
vt := v.Type() |
|
||||
numFields := v.NumField() |
|
||||
for i := 0; i < numFields; i++ { |
|
||||
d.indent() |
|
||||
vtf := vt.Field(i) |
|
||||
d.w.Write([]byte(vtf.Name)) |
|
||||
d.w.Write(colonSpaceBytes) |
|
||||
d.ignoreNextIndent = true |
|
||||
d.dump(d.unpackValue(v.Field(i))) |
|
||||
if i < (numFields - 1) { |
|
||||
d.w.Write(commaNewlineBytes) |
|
||||
} else { |
|
||||
d.w.Write(newlineBytes) |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
d.depth-- |
|
||||
d.indent() |
|
||||
d.w.Write(closeBraceBytes) |
|
||||
|
|
||||
case reflect.Uintptr: |
|
||||
printHexPtr(d.w, uintptr(v.Uint())) |
|
||||
|
|
||||
case reflect.UnsafePointer, reflect.Chan, reflect.Func: |
|
||||
printHexPtr(d.w, v.Pointer()) |
|
||||
|
|
||||
// There were not any other types at the time this code was written, but
|
|
||||
// fall back to letting the default fmt package handle it in case any new
|
|
||||
// types are added.
|
|
||||
default: |
|
||||
if v.CanInterface() { |
|
||||
fmt.Fprintf(d.w, "%v", v.Interface()) |
|
||||
} else { |
|
||||
fmt.Fprintf(d.w, "%v", v.String()) |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// fdump is a helper function to consolidate the logic from the various public
|
|
||||
// methods which take varying writers and config states.
|
|
||||
func fdump(cs *ConfigState, w io.Writer, a ...interface{}) { |
|
||||
for _, arg := range a { |
|
||||
if arg == nil { |
|
||||
w.Write(interfaceBytes) |
|
||||
w.Write(spaceBytes) |
|
||||
w.Write(nilAngleBytes) |
|
||||
w.Write(newlineBytes) |
|
||||
continue |
|
||||
} |
|
||||
|
|
||||
d := dumpState{w: w, cs: cs} |
|
||||
d.pointers = make(map[uintptr]int) |
|
||||
d.dump(reflect.ValueOf(arg)) |
|
||||
d.w.Write(newlineBytes) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// Fdump formats and displays the passed arguments to io.Writer w. It formats
|
|
||||
// exactly the same as Dump.
|
|
||||
func Fdump(w io.Writer, a ...interface{}) { |
|
||||
fdump(&Config, w, a...) |
|
||||
} |
|
||||
|
|
||||
// Sdump returns a string with the passed arguments formatted exactly the same
|
|
||||
// as Dump.
|
|
||||
func Sdump(a ...interface{}) string { |
|
||||
var buf bytes.Buffer |
|
||||
fdump(&Config, &buf, a...) |
|
||||
return buf.String() |
|
||||
} |
|
||||
|
|
||||
/* |
|
||||
Dump displays the passed parameters to standard out with newlines, customizable |
|
||||
indentation, and additional debug information such as complete types and all |
|
||||
pointer addresses used to indirect to the final value. It provides the |
|
||||
following features over the built-in printing facilities provided by the fmt |
|
||||
package: |
|
||||
|
|
||||
* Pointers are dereferenced and followed |
|
||||
* Circular data structures are detected and handled properly |
|
||||
* Custom Stringer/error interfaces are optionally invoked, including |
|
||||
on unexported types |
|
||||
* Custom types which only implement the Stringer/error interfaces via |
|
||||
a pointer receiver are optionally invoked when passing non-pointer |
|
||||
variables |
|
||||
* Byte arrays and slices are dumped like the hexdump -C command which |
|
||||
includes offsets, byte values in hex, and ASCII output |
|
||||
|
|
||||
The configuration options are controlled by an exported package global, |
|
||||
spew.Config. See ConfigState for options documentation. |
|
||||
|
|
||||
See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to |
|
||||
get the formatted result as a string. |
|
||||
*/ |
|
||||
func Dump(a ...interface{}) { |
|
||||
fdump(&Config, os.Stdout, a...) |
|
||||
} |
|
@ -1,419 +0,0 @@ |
|||||
/* |
|
||||
* Copyright (c) 2013-2016 Dave Collins <dave@davec.name> |
|
||||
* |
|
||||
* Permission to use, copy, modify, and distribute this software for any |
|
||||
* purpose with or without fee is hereby granted, provided that the above |
|
||||
* copyright notice and this permission notice appear in all copies. |
|
||||
* |
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
||||
*/ |
|
||||
|
|
||||
package spew |
|
||||
|
|
||||
import ( |
|
||||
"bytes" |
|
||||
"fmt" |
|
||||
"reflect" |
|
||||
"strconv" |
|
||||
"strings" |
|
||||
) |
|
||||
|
|
||||
// supportedFlags is a list of all the character flags supported by fmt package.
|
|
||||
const supportedFlags = "0-+# " |
|
||||
|
|
||||
// formatState implements the fmt.Formatter interface and contains information
|
|
||||
// about the state of a formatting operation. The NewFormatter function can
|
|
||||
// be used to get a new Formatter which can be used directly as arguments
|
|
||||
// in standard fmt package printing calls.
|
|
||||
type formatState struct { |
|
||||
value interface{} |
|
||||
fs fmt.State |
|
||||
depth int |
|
||||
pointers map[uintptr]int |
|
||||
ignoreNextType bool |
|
||||
cs *ConfigState |
|
||||
} |
|
||||
|
|
||||
// buildDefaultFormat recreates the original format string without precision
|
|
||||
// and width information to pass in to fmt.Sprintf in the case of an
|
|
||||
// unrecognized type. Unless new types are added to the language, this
|
|
||||
// function won't ever be called.
|
|
||||
func (f *formatState) buildDefaultFormat() (format string) { |
|
||||
buf := bytes.NewBuffer(percentBytes) |
|
||||
|
|
||||
for _, flag := range supportedFlags { |
|
||||
if f.fs.Flag(int(flag)) { |
|
||||
buf.WriteRune(flag) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
buf.WriteRune('v') |
|
||||
|
|
||||
format = buf.String() |
|
||||
return format |
|
||||
} |
|
||||
|
|
||||
// constructOrigFormat recreates the original format string including precision
|
|
||||
// and width information to pass along to the standard fmt package. This allows
|
|
||||
// automatic deferral of all format strings this package doesn't support.
|
|
||||
func (f *formatState) constructOrigFormat(verb rune) (format string) { |
|
||||
buf := bytes.NewBuffer(percentBytes) |
|
||||
|
|
||||
for _, flag := range supportedFlags { |
|
||||
if f.fs.Flag(int(flag)) { |
|
||||
buf.WriteRune(flag) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if width, ok := f.fs.Width(); ok { |
|
||||
buf.WriteString(strconv.Itoa(width)) |
|
||||
} |
|
||||
|
|
||||
if precision, ok := f.fs.Precision(); ok { |
|
||||
buf.Write(precisionBytes) |
|
||||
buf.WriteString(strconv.Itoa(precision)) |
|
||||
} |
|
||||
|
|
||||
buf.WriteRune(verb) |
|
||||
|
|
||||
format = buf.String() |
|
||||
return format |
|
||||
} |
|
||||
|
|
||||
// unpackValue returns values inside of non-nil interfaces when possible and
|
|
||||
// ensures that types for values which have been unpacked from an interface
|
|
||||
// are displayed when the show types flag is also set.
|
|
||||
// This is useful for data types like structs, arrays, slices, and maps which
|
|
||||
// can contain varying types packed inside an interface.
|
|
||||
func (f *formatState) unpackValue(v reflect.Value) reflect.Value { |
|
||||
if v.Kind() == reflect.Interface { |
|
||||
f.ignoreNextType = false |
|
||||
if !v.IsNil() { |
|
||||
v = v.Elem() |
|
||||
} |
|
||||
} |
|
||||
return v |
|
||||
} |
|
||||
|
|
||||
// formatPtr handles formatting of pointers by indirecting them as necessary.
|
|
||||
func (f *formatState) formatPtr(v reflect.Value) { |
|
||||
// Display nil if top level pointer is nil.
|
|
||||
showTypes := f.fs.Flag('#') |
|
||||
if v.IsNil() && (!showTypes || f.ignoreNextType) { |
|
||||
f.fs.Write(nilAngleBytes) |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
// Remove pointers at or below the current depth from map used to detect
|
|
||||
// circular refs.
|
|
||||
for k, depth := range f.pointers { |
|
||||
if depth >= f.depth { |
|
||||
delete(f.pointers, k) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// Keep list of all dereferenced pointers to possibly show later.
|
|
||||
pointerChain := make([]uintptr, 0) |
|
||||
|
|
||||
// Figure out how many levels of indirection there are by derferencing
|
|
||||
// pointers and unpacking interfaces down the chain while detecting circular
|
|
||||
// references.
|
|
||||
nilFound := false |
|
||||
cycleFound := false |
|
||||
indirects := 0 |
|
||||
ve := v |
|
||||
for ve.Kind() == reflect.Ptr { |
|
||||
if ve.IsNil() { |
|
||||
nilFound = true |
|
||||
break |
|
||||
} |
|
||||
indirects++ |
|
||||
addr := ve.Pointer() |
|
||||
pointerChain = append(pointerChain, addr) |
|
||||
if pd, ok := f.pointers[addr]; ok && pd < f.depth { |
|
||||
cycleFound = true |
|
||||
indirects-- |
|
||||
break |
|
||||
} |
|
||||
f.pointers[addr] = f.depth |
|
||||
|
|
||||
ve = ve.Elem() |
|
||||
if ve.Kind() == reflect.Interface { |
|
||||
if ve.IsNil() { |
|
||||
nilFound = true |
|
||||
break |
|
||||
} |
|
||||
ve = ve.Elem() |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// Display type or indirection level depending on flags.
|
|
||||
if showTypes && !f.ignoreNextType { |
|
||||
f.fs.Write(openParenBytes) |
|
||||
f.fs.Write(bytes.Repeat(asteriskBytes, indirects)) |
|
||||
f.fs.Write([]byte(ve.Type().String())) |
|
||||
f.fs.Write(closeParenBytes) |
|
||||
} else { |
|
||||
if nilFound || cycleFound { |
|
||||
indirects += strings.Count(ve.Type().String(), "*") |
|
||||
} |
|
||||
f.fs.Write(openAngleBytes) |
|
||||
f.fs.Write([]byte(strings.Repeat("*", indirects))) |
|
||||
f.fs.Write(closeAngleBytes) |
|
||||
} |
|
||||
|
|
||||
// Display pointer information depending on flags.
|
|
||||
if f.fs.Flag('+') && (len(pointerChain) > 0) { |
|
||||
f.fs.Write(openParenBytes) |
|
||||
for i, addr := range pointerChain { |
|
||||
if i > 0 { |
|
||||
f.fs.Write(pointerChainBytes) |
|
||||
} |
|
||||
printHexPtr(f.fs, addr) |
|
||||
} |
|
||||
f.fs.Write(closeParenBytes) |
|
||||
} |
|
||||
|
|
||||
// Display dereferenced value.
|
|
||||
switch { |
|
||||
case nilFound: |
|
||||
f.fs.Write(nilAngleBytes) |
|
||||
|
|
||||
case cycleFound: |
|
||||
f.fs.Write(circularShortBytes) |
|
||||
|
|
||||
default: |
|
||||
f.ignoreNextType = true |
|
||||
f.format(ve) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// format is the main workhorse for providing the Formatter interface. It
|
|
||||
// uses the passed reflect value to figure out what kind of object we are
|
|
||||
// dealing with and formats it appropriately. It is a recursive function,
|
|
||||
// however circular data structures are detected and handled properly.
|
|
||||
func (f *formatState) format(v reflect.Value) { |
|
||||
// Handle invalid reflect values immediately.
|
|
||||
kind := v.Kind() |
|
||||
if kind == reflect.Invalid { |
|
||||
f.fs.Write(invalidAngleBytes) |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
// Handle pointers specially.
|
|
||||
if kind == reflect.Ptr { |
|
||||
f.formatPtr(v) |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
// Print type information unless already handled elsewhere.
|
|
||||
if !f.ignoreNextType && f.fs.Flag('#') { |
|
||||
f.fs.Write(openParenBytes) |
|
||||
f.fs.Write([]byte(v.Type().String())) |
|
||||
f.fs.Write(closeParenBytes) |
|
||||
} |
|
||||
f.ignoreNextType = false |
|
||||
|
|
||||
// Call Stringer/error interfaces if they exist and the handle methods
|
|
||||
// flag is enabled.
|
|
||||
if !f.cs.DisableMethods { |
|
||||
if (kind != reflect.Invalid) && (kind != reflect.Interface) { |
|
||||
if handled := handleMethods(f.cs, f.fs, v); handled { |
|
||||
return |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
switch kind { |
|
||||
case reflect.Invalid: |
|
||||
// Do nothing. We should never get here since invalid has already
|
|
||||
// been handled above.
|
|
||||
|
|
||||
case reflect.Bool: |
|
||||
printBool(f.fs, v.Bool()) |
|
||||
|
|
||||
case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: |
|
||||
printInt(f.fs, v.Int(), 10) |
|
||||
|
|
||||
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: |
|
||||
printUint(f.fs, v.Uint(), 10) |
|
||||
|
|
||||
case reflect.Float32: |
|
||||
printFloat(f.fs, v.Float(), 32) |
|
||||
|
|
||||
case reflect.Float64: |
|
||||
printFloat(f.fs, v.Float(), 64) |
|
||||
|
|
||||
case reflect.Complex64: |
|
||||
printComplex(f.fs, v.Complex(), 32) |
|
||||
|
|
||||
case reflect.Complex128: |
|
||||
printComplex(f.fs, v.Complex(), 64) |
|
||||
|
|
||||
case reflect.Slice: |
|
||||
if v.IsNil() { |
|
||||
f.fs.Write(nilAngleBytes) |
|
||||
break |
|
||||
} |
|
||||
fallthrough |
|
||||
|
|
||||
case reflect.Array: |
|
||||
f.fs.Write(openBracketBytes) |
|
||||
f.depth++ |
|
||||
if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) { |
|
||||
f.fs.Write(maxShortBytes) |
|
||||
} else { |
|
||||
numEntries := v.Len() |
|
||||
for i := 0; i < numEntries; i++ { |
|
||||
if i > 0 { |
|
||||
f.fs.Write(spaceBytes) |
|
||||
} |
|
||||
f.ignoreNextType = true |
|
||||
f.format(f.unpackValue(v.Index(i))) |
|
||||
} |
|
||||
} |
|
||||
f.depth-- |
|
||||
f.fs.Write(closeBracketBytes) |
|
||||
|
|
||||
case reflect.String: |
|
||||
f.fs.Write([]byte(v.String())) |
|
||||
|
|
||||
case reflect.Interface: |
|
||||
// The only time we should get here is for nil interfaces due to
|
|
||||
// unpackValue calls.
|
|
||||
if v.IsNil() { |
|
||||
f.fs.Write(nilAngleBytes) |
|
||||
} |
|
||||
|
|
||||
case reflect.Ptr: |
|
||||
// Do nothing. We should never get here since pointers have already
|
|
||||
// been handled above.
|
|
||||
|
|
||||
case reflect.Map: |
|
||||
// nil maps should be indicated as different than empty maps
|
|
||||
if v.IsNil() { |
|
||||
f.fs.Write(nilAngleBytes) |
|
||||
break |
|
||||
} |
|
||||
|
|
||||
f.fs.Write(openMapBytes) |
|
||||
f.depth++ |
|
||||
if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) { |
|
||||
f.fs.Write(maxShortBytes) |
|
||||
} else { |
|
||||
keys := v.MapKeys() |
|
||||
if f.cs.SortKeys { |
|
||||
sortValues(keys, f.cs) |
|
||||
} |
|
||||
for i, key := range keys { |
|
||||
if i > 0 { |
|
||||
f.fs.Write(spaceBytes) |
|
||||
} |
|
||||
f.ignoreNextType = true |
|
||||
f.format(f.unpackValue(key)) |
|
||||
f.fs.Write(colonBytes) |
|
||||
f.ignoreNextType = true |
|
||||
f.format(f.unpackValue(v.MapIndex(key))) |
|
||||
} |
|
||||
} |
|
||||
f.depth-- |
|
||||
f.fs.Write(closeMapBytes) |
|
||||
|
|
||||
case reflect.Struct: |
|
||||
numFields := v.NumField() |
|
||||
f.fs.Write(openBraceBytes) |
|
||||
f.depth++ |
|
||||
if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) { |
|
||||
f.fs.Write(maxShortBytes) |
|
||||
} else { |
|
||||
vt := v.Type() |
|
||||
for i := 0; i < numFields; i++ { |
|
||||
if i > 0 { |
|
||||
f.fs.Write(spaceBytes) |
|
||||
} |
|
||||
vtf := vt.Field(i) |
|
||||
if f.fs.Flag('+') || f.fs.Flag('#') { |
|
||||
f.fs.Write([]byte(vtf.Name)) |
|
||||
f.fs.Write(colonBytes) |
|
||||
} |
|
||||
f.format(f.unpackValue(v.Field(i))) |
|
||||
} |
|
||||
} |
|
||||
f.depth-- |
|
||||
f.fs.Write(closeBraceBytes) |
|
||||
|
|
||||
case reflect.Uintptr: |
|
||||
printHexPtr(f.fs, uintptr(v.Uint())) |
|
||||
|
|
||||
case reflect.UnsafePointer, reflect.Chan, reflect.Func: |
|
||||
printHexPtr(f.fs, v.Pointer()) |
|
||||
|
|
||||
// There were not any other types at the time this code was written, but
|
|
||||
// fall back to letting the default fmt package handle it if any get added.
|
|
||||
default: |
|
||||
format := f.buildDefaultFormat() |
|
||||
if v.CanInterface() { |
|
||||
fmt.Fprintf(f.fs, format, v.Interface()) |
|
||||
} else { |
|
||||
fmt.Fprintf(f.fs, format, v.String()) |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// Format satisfies the fmt.Formatter interface. See NewFormatter for usage
|
|
||||
// details.
|
|
||||
func (f *formatState) Format(fs fmt.State, verb rune) { |
|
||||
f.fs = fs |
|
||||
|
|
||||
// Use standard formatting for verbs that are not v.
|
|
||||
if verb != 'v' { |
|
||||
format := f.constructOrigFormat(verb) |
|
||||
fmt.Fprintf(fs, format, f.value) |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
if f.value == nil { |
|
||||
if fs.Flag('#') { |
|
||||
fs.Write(interfaceBytes) |
|
||||
} |
|
||||
fs.Write(nilAngleBytes) |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
f.format(reflect.ValueOf(f.value)) |
|
||||
} |
|
||||
|
|
||||
// newFormatter is a helper function to consolidate the logic from the various
|
|
||||
// public methods which take varying config states.
|
|
||||
func newFormatter(cs *ConfigState, v interface{}) fmt.Formatter { |
|
||||
fs := &formatState{value: v, cs: cs} |
|
||||
fs.pointers = make(map[uintptr]int) |
|
||||
return fs |
|
||||
} |
|
||||
|
|
||||
/* |
|
||||
NewFormatter returns a custom formatter that satisfies the fmt.Formatter |
|
||||
interface. As a result, it integrates cleanly with standard fmt package |
|
||||
printing functions. The formatter is useful for inline printing of smaller data |
|
||||
types similar to the standard %v format specifier. |
|
||||
|
|
||||
The custom formatter only responds to the %v (most compact), %+v (adds pointer |
|
||||
addresses), %#v (adds types), or %#+v (adds types and pointer addresses) verb |
|
||||
combinations. Any other verbs such as %x and %q will be sent to the the |
|
||||
standard fmt package for formatting. In addition, the custom formatter ignores |
|
||||
the width and precision arguments (however they will still work on the format |
|
||||
specifiers not handled by the custom formatter). |
|
||||
|
|
||||
Typically this function shouldn't be called directly. It is much easier to make |
|
||||
use of the custom formatter by calling one of the convenience functions such as |
|
||||
Printf, Println, or Fprintf. |
|
||||
*/ |
|
||||
func NewFormatter(v interface{}) fmt.Formatter { |
|
||||
return newFormatter(&Config, v) |
|
||||
} |
|
@ -1,148 +0,0 @@ |
|||||
/* |
|
||||
* Copyright (c) 2013-2016 Dave Collins <dave@davec.name> |
|
||||
* |
|
||||
* Permission to use, copy, modify, and distribute this software for any |
|
||||
* purpose with or without fee is hereby granted, provided that the above |
|
||||
* copyright notice and this permission notice appear in all copies. |
|
||||
* |
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
||||
*/ |
|
||||
|
|
||||
package spew |
|
||||
|
|
||||
import ( |
|
||||
"fmt" |
|
||||
"io" |
|
||||
) |
|
||||
|
|
||||
// Errorf is a wrapper for fmt.Errorf that treats each argument as if it were
|
|
||||
// passed with a default Formatter interface returned by NewFormatter. It
|
|
||||
// returns the formatted string as a value that satisfies error. See
|
|
||||
// NewFormatter for formatting details.
|
|
||||
//
|
|
||||
// This function is shorthand for the following syntax:
|
|
||||
//
|
|
||||
// fmt.Errorf(format, spew.NewFormatter(a), spew.NewFormatter(b))
|
|
||||
func Errorf(format string, a ...interface{}) (err error) { |
|
||||
return fmt.Errorf(format, convertArgs(a)...) |
|
||||
} |
|
||||
|
|
||||
// Fprint is a wrapper for fmt.Fprint that treats each argument as if it were
|
|
||||
// passed with a default Formatter interface returned by NewFormatter. It
|
|
||||
// returns the number of bytes written and any write error encountered. See
|
|
||||
// NewFormatter for formatting details.
|
|
||||
//
|
|
||||
// This function is shorthand for the following syntax:
|
|
||||
//
|
|
||||
// fmt.Fprint(w, spew.NewFormatter(a), spew.NewFormatter(b))
|
|
||||
func Fprint(w io.Writer, a ...interface{}) (n int, err error) { |
|
||||
return fmt.Fprint(w, convertArgs(a)...) |
|
||||
} |
|
||||
|
|
||||
// Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were
|
|
||||
// passed with a default Formatter interface returned by NewFormatter. It
|
|
||||
// returns the number of bytes written and any write error encountered. See
|
|
||||
// NewFormatter for formatting details.
|
|
||||
//
|
|
||||
// This function is shorthand for the following syntax:
|
|
||||
//
|
|
||||
// fmt.Fprintf(w, format, spew.NewFormatter(a), spew.NewFormatter(b))
|
|
||||
func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) { |
|
||||
return fmt.Fprintf(w, format, convertArgs(a)...) |
|
||||
} |
|
||||
|
|
||||
// Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it
|
|
||||
// passed with a default Formatter interface returned by NewFormatter. See
|
|
||||
// NewFormatter for formatting details.
|
|
||||
//
|
|
||||
// This function is shorthand for the following syntax:
|
|
||||
//
|
|
||||
// fmt.Fprintln(w, spew.NewFormatter(a), spew.NewFormatter(b))
|
|
||||
func Fprintln(w io.Writer, a ...interface{}) (n int, err error) { |
|
||||
return fmt.Fprintln(w, convertArgs(a)...) |
|
||||
} |
|
||||
|
|
||||
// Print is a wrapper for fmt.Print that treats each argument as if it were
|
|
||||
// passed with a default Formatter interface returned by NewFormatter. It
|
|
||||
// returns the number of bytes written and any write error encountered. See
|
|
||||
// NewFormatter for formatting details.
|
|
||||
//
|
|
||||
// This function is shorthand for the following syntax:
|
|
||||
//
|
|
||||
// fmt.Print(spew.NewFormatter(a), spew.NewFormatter(b))
|
|
||||
func Print(a ...interface{}) (n int, err error) { |
|
||||
return fmt.Print(convertArgs(a)...) |
|
||||
} |
|
||||
|
|
||||
// Printf is a wrapper for fmt.Printf that treats each argument as if it were
|
|
||||
// passed with a default Formatter interface returned by NewFormatter. It
|
|
||||
// returns the number of bytes written and any write error encountered. See
|
|
||||
// NewFormatter for formatting details.
|
|
||||
//
|
|
||||
// This function is shorthand for the following syntax:
|
|
||||
//
|
|
||||
// fmt.Printf(format, spew.NewFormatter(a), spew.NewFormatter(b))
|
|
||||
func Printf(format string, a ...interface{}) (n int, err error) { |
|
||||
return fmt.Printf(format, convertArgs(a)...) |
|
||||
} |
|
||||
|
|
||||
// Println is a wrapper for fmt.Println that treats each argument as if it were
|
|
||||
// passed with a default Formatter interface returned by NewFormatter. It
|
|
||||
// returns the number of bytes written and any write error encountered. See
|
|
||||
// NewFormatter for formatting details.
|
|
||||
//
|
|
||||
// This function is shorthand for the following syntax:
|
|
||||
//
|
|
||||
// fmt.Println(spew.NewFormatter(a), spew.NewFormatter(b))
|
|
||||
func Println(a ...interface{}) (n int, err error) { |
|
||||
return fmt.Println(convertArgs(a)...) |
|
||||
} |
|
||||
|
|
||||
// Sprint is a wrapper for fmt.Sprint that treats each argument as if it were
|
|
||||
// passed with a default Formatter interface returned by NewFormatter. It
|
|
||||
// returns the resulting string. See NewFormatter for formatting details.
|
|
||||
//
|
|
||||
// This function is shorthand for the following syntax:
|
|
||||
//
|
|
||||
// fmt.Sprint(spew.NewFormatter(a), spew.NewFormatter(b))
|
|
||||
func Sprint(a ...interface{}) string { |
|
||||
return fmt.Sprint(convertArgs(a)...) |
|
||||
} |
|
||||
|
|
||||
// Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were
|
|
||||
// passed with a default Formatter interface returned by NewFormatter. It
|
|
||||
// returns the resulting string. See NewFormatter for formatting details.
|
|
||||
//
|
|
||||
// This function is shorthand for the following syntax:
|
|
||||
//
|
|
||||
// fmt.Sprintf(format, spew.NewFormatter(a), spew.NewFormatter(b))
|
|
||||
func Sprintf(format string, a ...interface{}) string { |
|
||||
return fmt.Sprintf(format, convertArgs(a)...) |
|
||||
} |
|
||||
|
|
||||
// Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it
|
|
||||
// were passed with a default Formatter interface returned by NewFormatter. It
|
|
||||
// returns the resulting string. See NewFormatter for formatting details.
|
|
||||
//
|
|
||||
// This function is shorthand for the following syntax:
|
|
||||
//
|
|
||||
// fmt.Sprintln(spew.NewFormatter(a), spew.NewFormatter(b))
|
|
||||
func Sprintln(a ...interface{}) string { |
|
||||
return fmt.Sprintln(convertArgs(a)...) |
|
||||
} |
|
||||
|
|
||||
// convertArgs accepts a slice of arguments and returns a slice of the same
|
|
||||
// length with each argument converted to a default spew Formatter interface.
|
|
||||
func convertArgs(args []interface{}) (formatters []interface{}) { |
|
||||
formatters = make([]interface{}, len(args)) |
|
||||
for index, arg := range args { |
|
||||
formatters[index] = NewFormatter(arg) |
|
||||
} |
|
||||
return formatters |
|
||||
} |
|
@ -1,8 +0,0 @@ |
|||||
/.idea |
|
||||
/.connstr |
|
||||
.vscode |
|
||||
.terraform |
|
||||
*.tfstate* |
|
||||
*.log |
|
||||
*.swp |
|
||||
*~ |
|
@ -1,10 +0,0 @@ |
|||||
linters: |
|
||||
enable: |
|
||||
# basic go linters |
|
||||
- gofmt |
|
||||
- golint |
|
||||
- govet |
|
||||
|
|
||||
# sql related linters |
|
||||
- rowserrcheck |
|
||||
- sqlclosecheck |
|
@ -1,27 +0,0 @@ |
|||||
Copyright (c) 2012 The Go Authors. All rights reserved. |
|
||||
|
|
||||
Redistribution and use in source and binary forms, with or without |
|
||||
modification, are permitted provided that the following conditions are |
|
||||
met: |
|
||||
|
|
||||
* Redistributions of source code must retain the above copyright |
|
||||
notice, this list of conditions and the following disclaimer. |
|
||||
* Redistributions in binary form must reproduce the above |
|
||||
copyright notice, this list of conditions and the following disclaimer |
|
||||
in the documentation and/or other materials provided with the |
|
||||
distribution. |
|
||||
* Neither the name of Google Inc. nor the names of its |
|
||||
contributors may be used to endorse or promote products derived from |
|
||||
this software without specific prior written permission. |
|
||||
|
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
@ -1,309 +0,0 @@ |
|||||
# A pure Go MSSQL driver for Go's database/sql package |
|
||||
|
|
||||
[](http://godoc.org/github.com/denisenkom/go-mssqldb) |
|
||||
[](https://ci.appveyor.com/project/denisenkom/go-mssqldb) |
|
||||
[](https://codecov.io/gh/denisenkom/go-mssqldb) |
|
||||
|
|
||||
## Install |
|
||||
|
|
||||
Requires Go 1.8 or above. |
|
||||
|
|
||||
Install with `go get github.com/denisenkom/go-mssqldb` . |
|
||||
|
|
||||
## Connection Parameters and DSN |
|
||||
|
|
||||
The recommended connection string uses a URL format: |
|
||||
`sqlserver://username:password@host/instance?param1=value¶m2=value` |
|
||||
Other supported formats are listed below. |
|
||||
|
|
||||
### Common parameters: |
|
||||
|
|
||||
* `user id` - enter the SQL Server Authentication user id or the Windows Authentication user id in the DOMAIN\User format. On Windows, if user id is empty or missing Single-Sign-On is used. The user domain sensitive to the case which is defined in the connection string. |
|
||||
* `password` |
|
||||
* `database` |
|
||||
* `connection timeout` - in seconds (default is 0 for no timeout), set to 0 for no timeout. Recommended to set to 0 and use context to manage query and connection timeouts. |
|
||||
* `dial timeout` - in seconds (default is 15), set to 0 for no timeout |
|
||||
* `encrypt` |
|
||||
* `disable` - Data send between client and server is not encrypted. |
|
||||
* `false` - Data sent between client and server is not encrypted beyond the login packet. (Default) |
|
||||
* `true` - Data sent between client and server is encrypted. |
|
||||
* `app name` - The application name (default is go-mssqldb) |
|
||||
|
|
||||
### Connection parameters for ODBC and ADO style connection strings: |
|
||||
|
|
||||
* `server` - host or host\instance (default localhost) |
|
||||
* `port` - used only when there is no instance in server (default 1433) |
|
||||
|
|
||||
### Less common parameters: |
|
||||
|
|
||||
* `keepAlive` - in seconds; 0 to disable (default is 30) |
|
||||
* `failoverpartner` - host or host\instance (default is no partner). |
|
||||
* `failoverport` - used only when there is no instance in failoverpartner (default 1433) |
|
||||
* `packet size` - in bytes; 512 to 32767 (default is 4096) |
|
||||
* Encrypted connections have a maximum packet size of 16383 bytes |
|
||||
* Further information on usage: https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/configure-the-network-packet-size-server-configuration-option |
|
||||
* `log` - logging flags (default 0/no logging, 63 for full logging) |
|
||||
* 1 log errors |
|
||||
* 2 log messages |
|
||||
* 4 log rows affected |
|
||||
* 8 trace sql statements |
|
||||
* 16 log statement parameters |
|
||||
* 32 log transaction begin/end |
|
||||
* `TrustServerCertificate` |
|
||||
* false - Server certificate is checked. Default is false if encypt is specified. |
|
||||
* true - Server certificate is not checked. Default is true if encrypt is not specified. If trust server certificate is true, driver accepts any certificate presented by the server and any host name in that certificate. In this mode, TLS is susceptible to man-in-the-middle attacks. This should be used only for testing. |
|
||||
* `certificate` - The file that contains the public key certificate of the CA that signed the SQL Server certificate. The specified certificate overrides the go platform specific CA certificates. |
|
||||
* `hostNameInCertificate` - Specifies the Common Name (CN) in the server certificate. Default value is the server host. |
|
||||
* `ServerSPN` - The kerberos SPN (Service Principal Name) for the server. Default is MSSQLSvc/host:port. |
|
||||
* `Workstation ID` - The workstation name (default is the host name) |
|
||||
* `ApplicationIntent` - Can be given the value `ReadOnly` to initiate a read-only connection to an Availability Group listener. The `database` must be specified when connecting with `Application Intent` set to `ReadOnly`. |
|
||||
|
|
||||
### The connection string can be specified in one of three formats: |
|
||||
|
|
||||
|
|
||||
1. URL: with `sqlserver` scheme. username and password appears before the host. Any instance appears as |
|
||||
the first segment in the path. All other options are query parameters. Examples: |
|
||||
|
|
||||
* `sqlserver://username:password@host/instance?param1=value¶m2=value` |
|
||||
* `sqlserver://username:password@host:port?param1=value¶m2=value` |
|
||||
* `sqlserver://sa@localhost/SQLExpress?database=master&connection+timeout=30` // `SQLExpress instance. |
|
||||
* `sqlserver://sa:mypass@localhost?database=master&connection+timeout=30` // username=sa, password=mypass. |
|
||||
* `sqlserver://sa:mypass@localhost:1234?database=master&connection+timeout=30` // port 1234 on localhost. |
|
||||
* `sqlserver://sa:my%7Bpass@somehost?connection+timeout=30` // password is "my{pass" |
|
||||
|
|
||||
A string of this format can be constructed using the `URL` type in the `net/url` package. |
|
||||
|
|
||||
```go |
|
||||
query := url.Values{} |
|
||||
query.Add("app name", "MyAppName") |
|
||||
|
|
||||
u := &url.URL{ |
|
||||
Scheme: "sqlserver", |
|
||||
User: url.UserPassword(username, password), |
|
||||
Host: fmt.Sprintf("%s:%d", hostname, port), |
|
||||
// Path: instance, // if connecting to an instance instead of a port |
|
||||
RawQuery: query.Encode(), |
|
||||
} |
|
||||
db, err := sql.Open("sqlserver", u.String()) |
|
||||
``` |
|
||||
|
|
||||
2. ADO: `key=value` pairs separated by `;`. Values may not contain `;`, leading and trailing whitespace is ignored. |
|
||||
Examples: |
|
||||
|
|
||||
* `server=localhost\\SQLExpress;user id=sa;database=master;app name=MyAppName` |
|
||||
* `server=localhost;user id=sa;database=master;app name=MyAppName` |
|
||||
|
|
||||
3. ODBC: Prefix with `odbc`, `key=value` pairs separated by `;`. Allow `;` by wrapping |
|
||||
values in `{}`. Examples: |
|
||||
|
|
||||
* `odbc:server=localhost\\SQLExpress;user id=sa;database=master;app name=MyAppName` |
|
||||
* `odbc:server=localhost;user id=sa;database=master;app name=MyAppName` |
|
||||
* `odbc:server=localhost;user id=sa;password={foo;bar}` // Value marked with `{}`, password is "foo;bar" |
|
||||
* `odbc:server=localhost;user id=sa;password={foo{bar}` // Value marked with `{}`, password is "foo{bar" |
|
||||
* `odbc:server=localhost;user id=sa;password={foobar }` // Value marked with `{}`, password is "foobar " |
|
||||
* `odbc:server=localhost;user id=sa;password=foo{bar` // Literal `{`, password is "foo{bar" |
|
||||
* `odbc:server=localhost;user id=sa;password=foo}bar` // Literal `}`, password is "foo}bar" |
|
||||
* `odbc:server=localhost;user id=sa;password={foo{bar}` // Literal `{`, password is "foo{bar" |
|
||||
* `odbc:server=localhost;user id=sa;password={foo}}bar}` // Escaped `} with `}}`, password is "foo}bar" |
|
||||
|
|
||||
### Azure Active Directory authentication - preview |
|
||||
|
|
||||
The configuration of functionality might change in the future. |
|
||||
|
|
||||
Azure Active Directory (AAD) access tokens are relatively short lived and need to be |
|
||||
valid when a new connection is made. Authentication is supported using a callback func that |
|
||||
provides a fresh and valid token using a connector: |
|
||||
``` golang |
|
||||
conn, err := mssql.NewAccessTokenConnector( |
|
||||
"Server=test.database.windows.net;Database=testdb", |
|
||||
tokenProvider) |
|
||||
if err != nil { |
|
||||
// handle errors in DSN |
|
||||
} |
|
||||
db := sql.OpenDB(conn) |
|
||||
``` |
|
||||
Where `tokenProvider` is a function that returns a fresh access token or an error. None of these statements |
|
||||
actually trigger the retrieval of a token, this happens when the first statment is issued and a connection |
|
||||
is created. |
|
||||
|
|
||||
## Executing Stored Procedures |
|
||||
|
|
||||
To run a stored procedure, set the query text to the procedure name: |
|
||||
```go |
|
||||
var account = "abc" |
|
||||
_, err := db.ExecContext(ctx, "sp_RunMe", |
|
||||
sql.Named("ID", 123), |
|
||||
sql.Named("Account", sql.Out{Dest: &account}), |
|
||||
) |
|
||||
``` |
|
||||
|
|
||||
## Reading Output Parameters from a Stored Procedure with Resultset |
|
||||
|
|
||||
To read output parameters from a stored procedure with resultset, make sure you read all the rows before reading the output parameters: |
|
||||
```go |
|
||||
sqltextcreate := ` |
|
||||
CREATE PROCEDURE spwithoutputandrows |
|
||||
@bitparam BIT OUTPUT |
|
||||
AS BEGIN |
|
||||
SET @bitparam = 1 |
|
||||
SELECT 'Row 1' |
|
||||
END |
|
||||
` |
|
||||
var bitout int64 |
|
||||
rows, err := db.QueryContext(ctx, "spwithoutputandrows", sql.Named("bitparam", sql.Out{Dest: &bitout})) |
|
||||
var strrow string |
|
||||
for rows.Next() { |
|
||||
err = rows.Scan(&strrow) |
|
||||
} |
|
||||
fmt.Printf("bitparam is %d", bitout) |
|
||||
``` |
|
||||
|
|
||||
## Caveat for local temporary tables |
|
||||
|
|
||||
Due to protocol limitations, temporary tables will only be allocated on the connection |
|
||||
as a result of executing a query with zero parameters. The following query |
|
||||
will, due to the use of a parameter, execute in its own session, |
|
||||
and `#mytemp` will be de-allocated right away: |
|
||||
|
|
||||
```go |
|
||||
conn, err := pool.Conn(ctx) |
|
||||
defer conn.Close() |
|
||||
_, err := conn.ExecContext(ctx, "select @p1 as x into #mytemp", 1) |
|
||||
// at this point #mytemp is already dropped again as the session of the ExecContext is over |
|
||||
``` |
|
||||
|
|
||||
To work around this, always explicitly create the local temporary |
|
||||
table in a query without any parameters. As a special case, the driver |
|
||||
will then be able to execute the query directly on the |
|
||||
connection-scoped session. The following example works: |
|
||||
|
|
||||
```go |
|
||||
conn, err := pool.Conn(ctx) |
|
||||
|
|
||||
// Set us up so that temp table is always cleaned up, since conn.Close() |
|
||||
// merely returns conn to pool, rather than actually closing the connection. |
|
||||
defer func() { |
|
||||
_, _ = conn.ExecContext(ctx, "drop table #mytemp") // always clean up |
|
||||
conn.Close() // merely returns conn to pool |
|
||||
}() |
|
||||
|
|
||||
|
|
||||
// Since we not pass any parameters below, the query will execute on the scope of |
|
||||
// the connection and succeed in creating the table. |
|
||||
_, err := conn.ExecContext(ctx, "create table #mytemp ( x int )") |
|
||||
|
|
||||
// #mytemp is now available even if you pass parameters |
|
||||
_, err := conn.ExecContext(ctx, "insert into #mytemp (x) values (@p1)", 1) |
|
||||
|
|
||||
``` |
|
||||
|
|
||||
## Return Status |
|
||||
|
|
||||
To get the procedure return status, pass into the parameters a |
|
||||
`*mssql.ReturnStatus`. For example: |
|
||||
``` |
|
||||
var rs mssql.ReturnStatus |
|
||||
_, err := db.ExecContext(ctx, "theproc", &rs) |
|
||||
log.Printf("status=%d", rs) |
|
||||
``` |
|
||||
|
|
||||
or |
|
||||
|
|
||||
``` |
|
||||
var rs mssql.ReturnStatus |
|
||||
_, err := db.QueryContext(ctx, "theproc", &rs) |
|
||||
for rows.Next() { |
|
||||
err = rows.Scan(&val) |
|
||||
} |
|
||||
log.Printf("status=%d", rs) |
|
||||
``` |
|
||||
|
|
||||
Limitation: ReturnStatus cannot be retrieved using `QueryRow`. |
|
||||
|
|
||||
## Parameters |
|
||||
|
|
||||
The `sqlserver` driver uses normal MS SQL Server syntax and expects parameters in |
|
||||
the sql query to be in the form of either `@Name` or `@p1` to `@pN` (ordinal position). |
|
||||
|
|
||||
```go |
|
||||
db.QueryContext(ctx, `select * from t where ID = @ID and Name = @p2;`, sql.Named("ID", 6), "Bob") |
|
||||
``` |
|
||||
|
|
||||
### Parameter Types |
|
||||
|
|
||||
To pass specific types to the query parameters, say `varchar` or `date` types, |
|
||||
you must convert the types to the type before passing in. The following types |
|
||||
are supported: |
|
||||
|
|
||||
* string -> nvarchar |
|
||||
* mssql.VarChar -> varchar |
|
||||
* time.Time -> datetimeoffset or datetime (TDS version dependent) |
|
||||
* mssql.DateTime1 -> datetime |
|
||||
* mssql.DateTimeOffset -> datetimeoffset |
|
||||
* "github.com/golang-sql/civil".Date -> date |
|
||||
* "github.com/golang-sql/civil".DateTime -> datetime2 |
|
||||
* "github.com/golang-sql/civil".Time -> time |
|
||||
* mssql.TVP -> Table Value Parameter (TDS version dependent) |
|
||||
|
|
||||
## Important Notes |
|
||||
|
|
||||
* [LastInsertId](https://golang.org/pkg/database/sql/#Result.LastInsertId) should |
|
||||
not be used with this driver (or SQL Server) due to how the TDS protocol |
|
||||
works. Please use the [OUTPUT Clause](https://docs.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql) |
|
||||
or add a `select ID = convert(bigint, SCOPE_IDENTITY());` to the end of your |
|
||||
query (ref [SCOPE_IDENTITY](https://docs.microsoft.com/en-us/sql/t-sql/functions/scope-identity-transact-sql)). |
|
||||
This will ensure you are getting the correct ID and will prevent a network round trip. |
|
||||
* [NewConnector](https://godoc.org/github.com/denisenkom/go-mssqldb#NewConnector) |
|
||||
may be used with [OpenDB](https://golang.org/pkg/database/sql/#OpenDB). |
|
||||
* [Connector.SessionInitSQL](https://godoc.org/github.com/denisenkom/go-mssqldb#Connector.SessionInitSQL) |
|
||||
may be set to set any driver specific session settings after the session |
|
||||
has been reset. If empty the session will still be reset but use the database |
|
||||
defaults in Go1.10+. |
|
||||
|
|
||||
## Features |
|
||||
|
|
||||
* Can be used with SQL Server 2005 or newer |
|
||||
* Can be used with Microsoft Azure SQL Database |
|
||||
* Can be used on all go supported platforms (e.g. Linux, Mac OS X and Windows) |
|
||||
* Supports new date/time types: date, time, datetime2, datetimeoffset |
|
||||
* Supports string parameters longer than 8000 characters |
|
||||
* Supports encryption using SSL/TLS |
|
||||
* Supports SQL Server and Windows Authentication |
|
||||
* Supports Single-Sign-On on Windows |
|
||||
* Supports connections to AlwaysOn Availability Group listeners, including re-direction to read-only replicas. |
|
||||
* Supports query notifications |
|
||||
|
|
||||
## Tests |
|
||||
|
|
||||
`go test` is used for testing. A running instance of MSSQL server is required. |
|
||||
Environment variables are used to pass login information. |
|
||||
|
|
||||
Example: |
|
||||
|
|
||||
env SQLSERVER_DSN=sqlserver://user:pass@hostname/instance?database=test1 go test |
|
||||
|
|
||||
## Deprecated |
|
||||
|
|
||||
These features still exist in the driver, but they are are deprecated. |
|
||||
|
|
||||
### Query Parameter Token Replace (driver "mssql") |
|
||||
|
|
||||
If you use the driver name "mssql" (rather then "sqlserver") the SQL text |
|
||||
will be loosly parsed and an attempt to extract identifiers using one of |
|
||||
|
|
||||
* ? |
|
||||
* ?nnn |
|
||||
* :nnn |
|
||||
* $nnn |
|
||||
|
|
||||
will be used. This is not recommended with SQL Server. |
|
||||
There is at least one existing `won't fix` issue with the query parsing. |
|
||||
|
|
||||
Use the native "@Name" parameters instead with the "sqlserver" driver name. |
|
||||
|
|
||||
## Known Issues |
|
||||
|
|
||||
* SQL Server 2008 and 2008 R2 engine cannot handle login records when SSL encryption is not disabled. |
|
||||
To fix SQL Server 2008 R2 issue, install SQL Server 2008 R2 Service Pack 2. |
|
||||
To fix SQL Server 2008 issue, install Microsoft SQL Server 2008 Service Pack 3 and Cumulative update package 3 for SQL Server 2008 SP3. |
|
||||
More information: http://support.microsoft.com/kb/2653857 |
|
@ -1,30 +0,0 @@ |
|||||
// +build go1.10
|
|
||||
|
|
||||
package mssql |
|
||||
|
|
||||
import ( |
|
||||
"context" |
|
||||
"database/sql/driver" |
|
||||
"errors" |
|
||||
) |
|
||||
|
|
||||
// NewAccessTokenConnector creates a new connector from a DSN and a token provider.
|
|
||||
// The token provider func will be called when a new connection is requested and should return a valid access token.
|
|
||||
// The returned connector may be used with sql.OpenDB.
|
|
||||
func NewAccessTokenConnector(dsn string, tokenProvider func() (string, error)) (driver.Connector, error) { |
|
||||
if tokenProvider == nil { |
|
||||
return nil, errors.New("mssql: tokenProvider cannot be nil") |
|
||||
} |
|
||||
|
|
||||
conn, err := NewConnector(dsn) |
|
||||
if err != nil { |
|
||||
return nil, err |
|
||||
} |
|
||||
|
|
||||
conn.params.fedAuthLibrary = fedAuthLibrarySecurityToken |
|
||||
conn.securityTokenProvider = func(ctx context.Context) (string, error) { |
|
||||
return tokenProvider() |
|
||||
} |
|
||||
|
|
||||
return conn, nil |
|
||||
} |
|
@ -1,68 +0,0 @@ |
|||||
version: 1.0.{build} |
|
||||
|
|
||||
image: |
|
||||
- Visual Studio 2015 |
|
||||
|
|
||||
clone_folder: c:\gopath\src\github.com\denisenkom\go-mssqldb |
|
||||
|
|
||||
environment: |
|
||||
GOPATH: c:\gopath |
|
||||
HOST: localhost |
|
||||
SQLUSER: sa |
|
||||
SQLPASSWORD: Password12! |
|
||||
DATABASE: test |
|
||||
GOVERSION: 113 |
|
||||
matrix: |
|
||||
- GOVERSION: 18 |
|
||||
SQLINSTANCE: SQL2017 |
|
||||
- GOVERSION: 19 |
|
||||
SQLINSTANCE: SQL2017 |
|
||||
- GOVERSION: 110 |
|
||||
SQLINSTANCE: SQL2017 |
|
||||
- GOVERSION: 111 |
|
||||
SQLINSTANCE: SQL2017 |
|
||||
- GOVERSION: 112 |
|
||||
SQLINSTANCE: SQL2017 |
|
||||
- SQLINSTANCE: SQL2017 |
|
||||
- SQLINSTANCE: SQL2016 |
|
||||
- SQLINSTANCE: SQL2014 |
|
||||
- SQLINSTANCE: SQL2012SP1 |
|
||||
- SQLINSTANCE: SQL2008R2SP2 |
|
||||
|
|
||||
# Go 1.14+ and SQL2019 are available on the Visual Studio 2019 image only |
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 |
|
||||
GOVERSION: 114 |
|
||||
SQLINSTANCE: SQL2019 |
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 |
|
||||
GOVERSION: 115 |
|
||||
SQLINSTANCE: SQL2019 |
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 |
|
||||
GOVERSION: 115 |
|
||||
SQLINSTANCE: SQL2017 |
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 |
|
||||
GOVERSION: 116 |
|
||||
SQLINSTANCE: SQL2017 |
|
||||
|
|
||||
install: |
|
||||
- set GOROOT=c:\go%GOVERSION% |
|
||||
- set PATH=%GOPATH%\bin;%GOROOT%\bin;%PATH% |
|
||||
- go version |
|
||||
- go env |
|
||||
- go get -u github.com/golang-sql/civil |
|
||||
|
|
||||
build_script: |
|
||||
- go build |
|
||||
|
|
||||
before_test: |
|
||||
# setup SQL Server |
|
||||
- ps: | |
|
||||
$instanceName = $env:SQLINSTANCE |
|
||||
Start-Service "MSSQL`$$instanceName" |
|
||||
Start-Service "SQLBrowser" |
|
||||
- sqlcmd -S "(local)\%SQLINSTANCE%" -Q "Use [master]; CREATE DATABASE test;" |
|
||||
- sqlcmd -S "(local)\%SQLINSTANCE%" -h -1 -Q "set nocount on; Select @@version" |
|
||||
- pip install codecov |
|
||||
|
|
||||
test_script: |
|
||||
- go test -race -cpu 4 -coverprofile=coverage.txt -covermode=atomic |
|
||||
- codecov -f coverage.txt |
|
@ -1,271 +0,0 @@ |
|||||
package mssql |
|
||||
|
|
||||
import ( |
|
||||
"encoding/binary" |
|
||||
"errors" |
|
||||
"io" |
|
||||
) |
|
||||
|
|
||||
type packetType uint8 |
|
||||
|
|
||||
type header struct { |
|
||||
PacketType packetType |
|
||||
Status uint8 |
|
||||
Size uint16 |
|
||||
Spid uint16 |
|
||||
PacketNo uint8 |
|
||||
Pad uint8 |
|
||||
} |
|
||||
|
|
||||
// tdsBuffer reads and writes TDS packets of data to the transport.
|
|
||||
// The write and read buffers are separate to make sending attn signals
|
|
||||
// possible without locks. Currently attn signals are only sent during
|
|
||||
// reads, not writes.
|
|
||||
type tdsBuffer struct { |
|
||||
transport io.ReadWriteCloser |
|
||||
|
|
||||
packetSize int |
|
||||
|
|
||||
// Write fields.
|
|
||||
wbuf []byte |
|
||||
wpos int |
|
||||
wPacketSeq byte |
|
||||
wPacketType packetType |
|
||||
|
|
||||
// Read fields.
|
|
||||
rbuf []byte |
|
||||
rpos int |
|
||||
rsize int |
|
||||
final bool |
|
||||
rPacketType packetType |
|
||||
|
|
||||
// afterFirst is assigned to right after tdsBuffer is created and
|
|
||||
// before the first use. It is executed after the first packet is
|
|
||||
// written and then removed.
|
|
||||
afterFirst func() |
|
||||
} |
|
||||
|
|
||||
func newTdsBuffer(bufsize uint16, transport io.ReadWriteCloser) *tdsBuffer { |
|
||||
return &tdsBuffer{ |
|
||||
packetSize: int(bufsize), |
|
||||
wbuf: make([]byte, bufsize), |
|
||||
rbuf: make([]byte, bufsize), |
|
||||
rpos: 8, |
|
||||
transport: transport, |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
func (rw *tdsBuffer) ResizeBuffer(packetSize int) { |
|
||||
rw.packetSize = packetSize |
|
||||
} |
|
||||
|
|
||||
func (w *tdsBuffer) PackageSize() int { |
|
||||
return w.packetSize |
|
||||
} |
|
||||
|
|
||||
func (w *tdsBuffer) flush() (err error) { |
|
||||
// Write packet size.
|
|
||||
w.wbuf[0] = byte(w.wPacketType) |
|
||||
binary.BigEndian.PutUint16(w.wbuf[2:], uint16(w.wpos)) |
|
||||
w.wbuf[6] = w.wPacketSeq |
|
||||
|
|
||||
// Write packet into underlying transport.
|
|
||||
if _, err = w.transport.Write(w.wbuf[:w.wpos]); err != nil { |
|
||||
return err |
|
||||
} |
|
||||
// It is possible to create a whole new buffer after a flush.
|
|
||||
// Useful for debugging. Normally reuse the buffer.
|
|
||||
// w.wbuf = make([]byte, 1<<16)
|
|
||||
|
|
||||
// Execute afterFirst hook if it is set.
|
|
||||
if w.afterFirst != nil { |
|
||||
w.afterFirst() |
|
||||
w.afterFirst = nil |
|
||||
} |
|
||||
|
|
||||
w.wpos = 8 |
|
||||
w.wPacketSeq++ |
|
||||
return nil |
|
||||
} |
|
||||
|
|
||||
func (w *tdsBuffer) Write(p []byte) (total int, err error) { |
|
||||
for { |
|
||||
copied := copy(w.wbuf[w.wpos:w.packetSize], p) |
|
||||
w.wpos += copied |
|
||||
total += copied |
|
||||
if copied == len(p) { |
|
||||
return |
|
||||
} |
|
||||
if err = w.flush(); err != nil { |
|
||||
return |
|
||||
} |
|
||||
p = p[copied:] |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
func (w *tdsBuffer) WriteByte(b byte) error { |
|
||||
if int(w.wpos) == len(w.wbuf) || w.wpos == w.packetSize { |
|
||||
if err := w.flush(); err != nil { |
|
||||
return err |
|
||||
} |
|
||||
} |
|
||||
w.wbuf[w.wpos] = b |
|
||||
w.wpos += 1 |
|
||||
return nil |
|
||||
} |
|
||||
|
|
||||
func (w *tdsBuffer) BeginPacket(packetType packetType, resetSession bool) { |
|
||||
status := byte(0) |
|
||||
if resetSession { |
|
||||
switch packetType { |
|
||||
// Reset session can only be set on the following packet types.
|
|
||||
case packSQLBatch, packRPCRequest, packTransMgrReq: |
|
||||
status = 0x8 |
|
||||
} |
|
||||
} |
|
||||
w.wbuf[1] = status // Packet is incomplete. This byte is set again in FinishPacket.
|
|
||||
w.wpos = 8 |
|
||||
w.wPacketSeq = 1 |
|
||||
w.wPacketType = packetType |
|
||||
} |
|
||||
|
|
||||
func (w *tdsBuffer) FinishPacket() error { |
|
||||
w.wbuf[1] |= 1 // Mark this as the last packet in the message.
|
|
||||
return w.flush() |
|
||||
} |
|
||||
|
|
||||
var headerSize = binary.Size(header{}) |
|
||||
|
|
||||
func (r *tdsBuffer) readNextPacket() error { |
|
||||
buf := r.rbuf[:headerSize] |
|
||||
_, err := io.ReadFull(r.transport, buf) |
|
||||
if err != nil { |
|
||||
return err |
|
||||
} |
|
||||
h := header{ |
|
||||
PacketType: packetType(buf[0]), |
|
||||
Status: buf[1], |
|
||||
Size: binary.BigEndian.Uint16(buf[2:4]), |
|
||||
Spid: binary.BigEndian.Uint16(buf[4:6]), |
|
||||
PacketNo: buf[6], |
|
||||
Pad: buf[7], |
|
||||
} |
|
||||
if int(h.Size) > r.packetSize { |
|
||||
return errors.New("invalid packet size, it is longer than buffer size") |
|
||||
} |
|
||||
if headerSize > int(h.Size) { |
|
||||
return errors.New("invalid packet size, it is shorter than header size") |
|
||||
} |
|
||||
_, err = io.ReadFull(r.transport, r.rbuf[headerSize:h.Size]) |
|
||||
//s := base64.StdEncoding.EncodeToString(r.rbuf[headerSize:h.Size])
|
|
||||
//fmt.Print(s)
|
|
||||
if err != nil { |
|
||||
return err |
|
||||
} |
|
||||
r.rpos = headerSize |
|
||||
r.rsize = int(h.Size) |
|
||||
r.final = h.Status != 0 |
|
||||
r.rPacketType = h.PacketType |
|
||||
return nil |
|
||||
} |
|
||||
|
|
||||
func (r *tdsBuffer) BeginRead() (packetType, error) { |
|
||||
err := r.readNextPacket() |
|
||||
if err != nil { |
|
||||
return 0, err |
|
||||
} |
|
||||
return r.rPacketType, nil |
|
||||
} |
|
||||
|
|
||||
func (r *tdsBuffer) ReadByte() (res byte, err error) { |
|
||||
if r.rpos == r.rsize { |
|
||||
if r.final { |
|
||||
return 0, io.EOF |
|
||||
} |
|
||||
err = r.readNextPacket() |
|
||||
if err != nil { |
|
||||
return 0, err |
|
||||
} |
|
||||
} |
|
||||
res = r.rbuf[r.rpos] |
|
||||
r.rpos++ |
|
||||
return res, nil |
|
||||
} |
|
||||
|
|
||||
func (r *tdsBuffer) byte() byte { |
|
||||
b, err := r.ReadByte() |
|
||||
if err != nil { |
|
||||
badStreamPanic(err) |
|
||||
} |
|
||||
return b |
|
||||
} |
|
||||
|
|
||||
func (r *tdsBuffer) ReadFull(buf []byte) { |
|
||||
_, err := io.ReadFull(r, buf[:]) |
|
||||
if err != nil { |
|
||||
badStreamPanic(err) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
func (r *tdsBuffer) uint64() uint64 { |
|
||||
var buf [8]byte |
|
||||
r.ReadFull(buf[:]) |
|
||||
return binary.LittleEndian.Uint64(buf[:]) |
|
||||
} |
|
||||
|
|
||||
func (r *tdsBuffer) int32() int32 { |
|
||||
return int32(r.uint32()) |
|
||||
} |
|
||||
|
|
||||
func (r *tdsBuffer) uint32() uint32 { |
|
||||
var buf [4]byte |
|
||||
r.ReadFull(buf[:]) |
|
||||
return binary.LittleEndian.Uint32(buf[:]) |
|
||||
} |
|
||||
|
|
||||
func (r *tdsBuffer) uint16() uint16 { |
|
||||
var buf [2]byte |
|
||||
r.ReadFull(buf[:]) |
|
||||
return binary.LittleEndian.Uint16(buf[:]) |
|
||||
} |
|
||||
|
|
||||
func (r *tdsBuffer) BVarChar() string { |
|
||||
return readBVarCharOrPanic(r) |
|
||||
} |
|
||||
|
|
||||
func readBVarCharOrPanic(r io.Reader) string { |
|
||||
s, err := readBVarChar(r) |
|
||||
if err != nil { |
|
||||
badStreamPanic(err) |
|
||||
} |
|
||||
return s |
|
||||
} |
|
||||
|
|
||||
func readUsVarCharOrPanic(r io.Reader) string { |
|
||||
s, err := readUsVarChar(r) |
|
||||
if err != nil { |
|
||||
badStreamPanic(err) |
|
||||
} |
|
||||
return s |
|
||||
} |
|
||||
|
|
||||
func (r *tdsBuffer) UsVarChar() string { |
|
||||
return readUsVarCharOrPanic(r) |
|
||||
} |
|
||||
|
|
||||
func (r *tdsBuffer) Read(buf []byte) (copied int, err error) { |
|
||||
copied = 0 |
|
||||
err = nil |
|
||||
if r.rpos == r.rsize { |
|
||||
if r.final { |
|
||||
return 0, io.EOF |
|
||||
} |
|
||||
err = r.readNextPacket() |
|
||||
if err != nil { |
|
||||
return |
|
||||
} |
|
||||
} |
|
||||
copied = copy(buf, r.rbuf[r.rpos:r.rsize]) |
|
||||
r.rpos += copied |
|
||||
return |
|
||||
} |
|
@ -1,588 +0,0 @@ |
|||||
package mssql |
|
||||
|
|
||||
import ( |
|
||||
"bytes" |
|
||||
"context" |
|
||||
"encoding/binary" |
|
||||
"fmt" |
|
||||
"math" |
|
||||
"reflect" |
|
||||
"strings" |
|
||||
"time" |
|
||||
|
|
||||
"github.com/denisenkom/go-mssqldb/internal/decimal" |
|
||||
) |
|
||||
|
|
||||
type Bulk struct { |
|
||||
// ctx is used only for AddRow and Done methods.
|
|
||||
// This could be removed if AddRow and Done accepted
|
|
||||
// a ctx field as well, which is available with the
|
|
||||
// database/sql call.
|
|
||||
ctx context.Context |
|
||||
|
|
||||
cn *Conn |
|
||||
metadata []columnStruct |
|
||||
bulkColumns []columnStruct |
|
||||
columnsName []string |
|
||||
tablename string |
|
||||
numRows int |
|
||||
|
|
||||
headerSent bool |
|
||||
Options BulkOptions |
|
||||
Debug bool |
|
||||
} |
|
||||
type BulkOptions struct { |
|
||||
CheckConstraints bool |
|
||||
FireTriggers bool |
|
||||
KeepNulls bool |
|
||||
KilobytesPerBatch int |
|
||||
RowsPerBatch int |
|
||||
Order []string |
|
||||
Tablock bool |
|
||||
} |
|
||||
|
|
||||
type DataValue interface{} |
|
||||
|
|
||||
const ( |
|
||||
sqlDateFormat = "2006-01-02" |
|
||||
sqlDateTimeFormat = "2006-01-02 15:04:05.999999999Z07:00" |
|
||||
sqlTimeFormat = "15:04:05.9999999" |
|
||||
) |
|
||||
|
|
||||
func (cn *Conn) CreateBulk(table string, columns []string) (_ *Bulk) { |
|
||||
b := Bulk{ctx: context.Background(), cn: cn, tablename: table, headerSent: false, columnsName: columns} |
|
||||
b.Debug = false |
|
||||
return &b |
|
||||
} |
|
||||
|
|
||||
func (cn *Conn) CreateBulkContext(ctx context.Context, table string, columns []string) (_ *Bulk) { |
|
||||
b := Bulk{ctx: ctx, cn: cn, tablename: table, headerSent: false, columnsName: columns} |
|
||||
b.Debug = false |
|
||||
return &b |
|
||||
} |
|
||||
|
|
||||
func (b *Bulk) sendBulkCommand(ctx context.Context) (err error) { |
|
||||
//get table columns info
|
|
||||
err = b.getMetadata(ctx) |
|
||||
if err != nil { |
|
||||
return err |
|
||||
} |
|
||||
|
|
||||
//match the columns
|
|
||||
for _, colname := range b.columnsName { |
|
||||
var bulkCol *columnStruct |
|
||||
|
|
||||
for _, m := range b.metadata { |
|
||||
if m.ColName == colname { |
|
||||
bulkCol = &m |
|
||||
break |
|
||||
} |
|
||||
} |
|
||||
if bulkCol != nil { |
|
||||
|
|
||||
if bulkCol.ti.TypeId == typeUdt { |
|
||||
//send udt as binary
|
|
||||
bulkCol.ti.TypeId = typeBigVarBin |
|
||||
} |
|
||||
b.bulkColumns = append(b.bulkColumns, *bulkCol) |
|
||||
b.dlogf("Adding column %s %s %#x", colname, bulkCol.ColName, bulkCol.ti.TypeId) |
|
||||
} else { |
|
||||
return fmt.Errorf("column %s does not exist in destination table %s", colname, b.tablename) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
//create the bulk command
|
|
||||
|
|
||||
//columns definitions
|
|
||||
var col_defs bytes.Buffer |
|
||||
for i, col := range b.bulkColumns { |
|
||||
if i != 0 { |
|
||||
col_defs.WriteString(", ") |
|
||||
} |
|
||||
col_defs.WriteString("[" + col.ColName + "] " + makeDecl(col.ti)) |
|
||||
} |
|
||||
|
|
||||
//options
|
|
||||
var with_opts []string |
|
||||
|
|
||||
if b.Options.CheckConstraints { |
|
||||
with_opts = append(with_opts, "CHECK_CONSTRAINTS") |
|
||||
} |
|
||||
if b.Options.FireTriggers { |
|
||||
with_opts = append(with_opts, "FIRE_TRIGGERS") |
|
||||
} |
|
||||
if b.Options.KeepNulls { |
|
||||
with_opts = append(with_opts, "KEEP_NULLS") |
|
||||
} |
|
||||
if b.Options.KilobytesPerBatch > 0 { |
|
||||
with_opts = append(with_opts, fmt.Sprintf("KILOBYTES_PER_BATCH = %d", b.Options.KilobytesPerBatch)) |
|
||||
} |
|
||||
if b.Options.RowsPerBatch > 0 { |
|
||||
with_opts = append(with_opts, fmt.Sprintf("ROWS_PER_BATCH = %d", b.Options.RowsPerBatch)) |
|
||||
} |
|
||||
if len(b.Options.Order) > 0 { |
|
||||
with_opts = append(with_opts, fmt.Sprintf("ORDER(%s)", strings.Join(b.Options.Order, ","))) |
|
||||
} |
|
||||
if b.Options.Tablock { |
|
||||
with_opts = append(with_opts, "TABLOCK") |
|
||||
} |
|
||||
var with_part string |
|
||||
if len(with_opts) > 0 { |
|
||||
with_part = fmt.Sprintf("WITH (%s)", strings.Join(with_opts, ",")) |
|
||||
} |
|
||||
|
|
||||
query := fmt.Sprintf("INSERT BULK %s (%s) %s", b.tablename, col_defs.String(), with_part) |
|
||||
|
|
||||
stmt, err := b.cn.PrepareContext(ctx, query) |
|
||||
if err != nil { |
|
||||
return fmt.Errorf("Prepare failed: %s", err.Error()) |
|
||||
} |
|
||||
b.dlogf(query) |
|
||||
|
|
||||
_, err = stmt.(*Stmt).ExecContext(ctx, nil) |
|
||||
if err != nil { |
|
||||
return err |
|
||||
} |
|
||||
|
|
||||
b.headerSent = true |
|
||||
|
|
||||
var buf = b.cn.sess.buf |
|
||||
buf.BeginPacket(packBulkLoadBCP, false) |
|
||||
|
|
||||
// Send the columns metadata.
|
|
||||
columnMetadata := b.createColMetadata() |
|
||||
_, err = buf.Write(columnMetadata) |
|
||||
|
|
||||
return |
|
||||
} |
|
||||
|
|
||||
// AddRow immediately writes the row to the destination table.
|
|
||||
// The arguments are the row values in the order they were specified.
|
|
||||
func (b *Bulk) AddRow(row []interface{}) (err error) { |
|
||||
if !b.headerSent { |
|
||||
err = b.sendBulkCommand(b.ctx) |
|
||||
if err != nil { |
|
||||
return |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if len(row) != len(b.bulkColumns) { |
|
||||
return fmt.Errorf("row does not have the same number of columns than the destination table %d %d", |
|
||||
len(row), len(b.bulkColumns)) |
|
||||
} |
|
||||
|
|
||||
bytes, err := b.makeRowData(row) |
|
||||
if err != nil { |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
_, err = b.cn.sess.buf.Write(bytes) |
|
||||
if err != nil { |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
b.numRows = b.numRows + 1 |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
func (b *Bulk) makeRowData(row []interface{}) ([]byte, error) { |
|
||||
buf := new(bytes.Buffer) |
|
||||
buf.WriteByte(byte(tokenRow)) |
|
||||
|
|
||||
var logcol bytes.Buffer |
|
||||
for i, col := range b.bulkColumns { |
|
||||
|
|
||||
if b.Debug { |
|
||||
logcol.WriteString(fmt.Sprintf(" col[%d]='%v' ", i, row[i])) |
|
||||
} |
|
||||
param, err := b.makeParam(row[i], col) |
|
||||
if err != nil { |
|
||||
return nil, fmt.Errorf("bulkcopy: %s", err.Error()) |
|
||||
} |
|
||||
|
|
||||
if col.ti.Writer == nil { |
|
||||
return nil, fmt.Errorf("no writer for column: %s, TypeId: %#x", |
|
||||
col.ColName, col.ti.TypeId) |
|
||||
} |
|
||||
err = col.ti.Writer(buf, param.ti, param.buffer) |
|
||||
if err != nil { |
|
||||
return nil, fmt.Errorf("bulkcopy: %s", err.Error()) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
b.dlogf("row[%d] %s\n", b.numRows, logcol.String()) |
|
||||
|
|
||||
return buf.Bytes(), nil |
|
||||
} |
|
||||
|
|
||||
func (b *Bulk) Done() (rowcount int64, err error) { |
|
||||
if !b.headerSent { |
|
||||
//no rows had been sent
|
|
||||
return 0, nil |
|
||||
} |
|
||||
var buf = b.cn.sess.buf |
|
||||
buf.WriteByte(byte(tokenDone)) |
|
||||
|
|
||||
binary.Write(buf, binary.LittleEndian, uint16(doneFinal)) |
|
||||
binary.Write(buf, binary.LittleEndian, uint16(0)) // curcmd
|
|
||||
|
|
||||
if b.cn.sess.loginAck.TDSVersion >= verTDS72 { |
|
||||
binary.Write(buf, binary.LittleEndian, uint64(0)) //rowcount 0
|
|
||||
} else { |
|
||||
binary.Write(buf, binary.LittleEndian, uint32(0)) //rowcount 0
|
|
||||
} |
|
||||
|
|
||||
buf.FinishPacket() |
|
||||
|
|
||||
reader := startReading(b.cn.sess, b.ctx, nil) |
|
||||
err = reader.iterateResponse() |
|
||||
if err != nil { |
|
||||
return 0, b.cn.checkBadConn(err) |
|
||||
} |
|
||||
|
|
||||
return reader.rowCount, nil |
|
||||
} |
|
||||
|
|
||||
func (b *Bulk) createColMetadata() []byte { |
|
||||
buf := new(bytes.Buffer) |
|
||||
buf.WriteByte(byte(tokenColMetadata)) // token
|
|
||||
binary.Write(buf, binary.LittleEndian, uint16(len(b.bulkColumns))) // column count
|
|
||||
|
|
||||
for i, col := range b.bulkColumns { |
|
||||
|
|
||||
if b.cn.sess.loginAck.TDSVersion >= verTDS72 { |
|
||||
binary.Write(buf, binary.LittleEndian, uint32(col.UserType)) // usertype, always 0?
|
|
||||
} else { |
|
||||
binary.Write(buf, binary.LittleEndian, uint16(col.UserType)) |
|
||||
} |
|
||||
binary.Write(buf, binary.LittleEndian, uint16(col.Flags)) |
|
||||
|
|
||||
writeTypeInfo(buf, &b.bulkColumns[i].ti) |
|
||||
|
|
||||
if col.ti.TypeId == typeNText || |
|
||||
col.ti.TypeId == typeText || |
|
||||
col.ti.TypeId == typeImage { |
|
||||
|
|
||||
tablename_ucs2 := str2ucs2(b.tablename) |
|
||||
binary.Write(buf, binary.LittleEndian, uint16(len(tablename_ucs2)/2)) |
|
||||
buf.Write(tablename_ucs2) |
|
||||
} |
|
||||
colname_ucs2 := str2ucs2(col.ColName) |
|
||||
buf.WriteByte(uint8(len(colname_ucs2) / 2)) |
|
||||
buf.Write(colname_ucs2) |
|
||||
} |
|
||||
|
|
||||
return buf.Bytes() |
|
||||
} |
|
||||
|
|
||||
func (b *Bulk) getMetadata(ctx context.Context) (err error) { |
|
||||
stmt, err := b.cn.prepareContext(ctx, "SET FMTONLY ON") |
|
||||
if err != nil { |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
_, err = stmt.ExecContext(ctx, nil) |
|
||||
if err != nil { |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
// Get columns info.
|
|
||||
stmt, err = b.cn.prepareContext(ctx, fmt.Sprintf("select * from %s SET FMTONLY OFF", b.tablename)) |
|
||||
if err != nil { |
|
||||
return |
|
||||
} |
|
||||
rows, err := stmt.QueryContext(ctx, nil) |
|
||||
if err != nil { |
|
||||
return fmt.Errorf("get columns info failed: %v", err) |
|
||||
} |
|
||||
b.metadata = rows.(*Rows).cols |
|
||||
|
|
||||
if b.Debug { |
|
||||
for _, col := range b.metadata { |
|
||||
b.dlogf("col: %s typeId: %#x size: %d scale: %d prec: %d flags: %d lcid: %#x\n", |
|
||||
col.ColName, col.ti.TypeId, col.ti.Size, col.ti.Scale, col.ti.Prec, |
|
||||
col.Flags, col.ti.Collation.LcidAndFlags) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return rows.Close() |
|
||||
} |
|
||||
|
|
||||
func (b *Bulk) makeParam(val DataValue, col columnStruct) (res param, err error) { |
|
||||
res.ti.Size = col.ti.Size |
|
||||
res.ti.TypeId = col.ti.TypeId |
|
||||
|
|
||||
if val == nil { |
|
||||
res.ti.Size = 0 |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
switch col.ti.TypeId { |
|
||||
|
|
||||
case typeInt1, typeInt2, typeInt4, typeInt8, typeIntN: |
|
||||
var intvalue int64 |
|
||||
|
|
||||
switch val := val.(type) { |
|
||||
case int: |
|
||||
intvalue = int64(val) |
|
||||
case int32: |
|
||||
intvalue = int64(val) |
|
||||
case int64: |
|
||||
intvalue = val |
|
||||
default: |
|
||||
err = fmt.Errorf("mssql: invalid type for int column: %T", val) |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
res.buffer = make([]byte, res.ti.Size) |
|
||||
if col.ti.Size == 1 { |
|
||||
res.buffer[0] = byte(intvalue) |
|
||||
} else if col.ti.Size == 2 { |
|
||||
binary.LittleEndian.PutUint16(res.buffer, uint16(intvalue)) |
|
||||
} else if col.ti.Size == 4 { |
|
||||
binary.LittleEndian.PutUint32(res.buffer, uint32(intvalue)) |
|
||||
} else if col.ti.Size == 8 { |
|
||||
binary.LittleEndian.PutUint64(res.buffer, uint64(intvalue)) |
|
||||
} |
|
||||
case typeFlt4, typeFlt8, typeFltN: |
|
||||
var floatvalue float64 |
|
||||
|
|
||||
switch val := val.(type) { |
|
||||
case float32: |
|
||||
floatvalue = float64(val) |
|
||||
case float64: |
|
||||
floatvalue = val |
|
||||
case int: |
|
||||
floatvalue = float64(val) |
|
||||
case int64: |
|
||||
floatvalue = float64(val) |
|
||||
default: |
|
||||
err = fmt.Errorf("mssql: invalid type for float column: %T %s", val, val) |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
if col.ti.Size == 4 { |
|
||||
res.buffer = make([]byte, 4) |
|
||||
binary.LittleEndian.PutUint32(res.buffer, math.Float32bits(float32(floatvalue))) |
|
||||
} else if col.ti.Size == 8 { |
|
||||
res.buffer = make([]byte, 8) |
|
||||
binary.LittleEndian.PutUint64(res.buffer, math.Float64bits(floatvalue)) |
|
||||
} |
|
||||
case typeNVarChar, typeNText, typeNChar: |
|
||||
|
|
||||
switch val := val.(type) { |
|
||||
case string: |
|
||||
res.buffer = str2ucs2(val) |
|
||||
case []byte: |
|
||||
res.buffer = val |
|
||||
default: |
|
||||
err = fmt.Errorf("mssql: invalid type for nvarchar column: %T %s", val, val) |
|
||||
return |
|
||||
} |
|
||||
res.ti.Size = len(res.buffer) |
|
||||
|
|
||||
case typeVarChar, typeBigVarChar, typeText, typeChar, typeBigChar: |
|
||||
switch val := val.(type) { |
|
||||
case string: |
|
||||
res.buffer = []byte(val) |
|
||||
case []byte: |
|
||||
res.buffer = val |
|
||||
default: |
|
||||
err = fmt.Errorf("mssql: invalid type for varchar column: %T %s", val, val) |
|
||||
return |
|
||||
} |
|
||||
res.ti.Size = len(res.buffer) |
|
||||
|
|
||||
case typeBit, typeBitN: |
|
||||
if reflect.TypeOf(val).Kind() != reflect.Bool { |
|
||||
err = fmt.Errorf("mssql: invalid type for bit column: %T %s", val, val) |
|
||||
return |
|
||||
} |
|
||||
res.ti.TypeId = typeBitN |
|
||||
res.ti.Size = 1 |
|
||||
res.buffer = make([]byte, 1) |
|
||||
if val.(bool) { |
|
||||
res.buffer[0] = 1 |
|
||||
} |
|
||||
case typeDateTime2N: |
|
||||
switch val := val.(type) { |
|
||||
case time.Time: |
|
||||
res.buffer = encodeDateTime2(val, int(col.ti.Scale)) |
|
||||
res.ti.Size = len(res.buffer) |
|
||||
case string: |
|
||||
var t time.Time |
|
||||
if t, err = time.Parse(sqlDateTimeFormat, val); err != nil { |
|
||||
return res, fmt.Errorf("bulk: unable to convert string to date: %v", err) |
|
||||
} |
|
||||
res.buffer = encodeDateTime2(t, int(col.ti.Scale)) |
|
||||
res.ti.Size = len(res.buffer) |
|
||||
default: |
|
||||
err = fmt.Errorf("mssql: invalid type for datetime2 column: %T %s", val, val) |
|
||||
return |
|
||||
} |
|
||||
case typeDateTimeOffsetN: |
|
||||
switch val := val.(type) { |
|
||||
case time.Time: |
|
||||
res.buffer = encodeDateTimeOffset(val, int(col.ti.Scale)) |
|
||||
res.ti.Size = len(res.buffer) |
|
||||
case string: |
|
||||
var t time.Time |
|
||||
if t, err = time.Parse(sqlDateTimeFormat, val); err != nil { |
|
||||
return res, fmt.Errorf("bulk: unable to convert string to date: %v", err) |
|
||||
} |
|
||||
res.buffer = encodeDateTimeOffset(t, int(col.ti.Scale)) |
|
||||
res.ti.Size = len(res.buffer) |
|
||||
default: |
|
||||
err = fmt.Errorf("mssql: invalid type for datetimeoffset column: %T %s", val, val) |
|
||||
return |
|
||||
} |
|
||||
case typeDateN: |
|
||||
switch val := val.(type) { |
|
||||
case time.Time: |
|
||||
res.buffer = encodeDate(val) |
|
||||
res.ti.Size = len(res.buffer) |
|
||||
case string: |
|
||||
var t time.Time |
|
||||
if t, err = time.ParseInLocation(sqlDateFormat, val, time.UTC); err != nil { |
|
||||
return res, fmt.Errorf("bulk: unable to convert string to date: %v", err) |
|
||||
} |
|
||||
res.buffer = encodeDate(t) |
|
||||
res.ti.Size = len(res.buffer) |
|
||||
default: |
|
||||
err = fmt.Errorf("mssql: invalid type for date column: %T %s", val, val) |
|
||||
return |
|
||||
} |
|
||||
case typeDateTime, typeDateTimeN, typeDateTim4: |
|
||||
var t time.Time |
|
||||
switch val := val.(type) { |
|
||||
case time.Time: |
|
||||
t = val |
|
||||
case string: |
|
||||
if t, err = time.Parse(sqlDateTimeFormat, val); err != nil { |
|
||||
return res, fmt.Errorf("bulk: unable to convert string to date: %v", err) |
|
||||
} |
|
||||
default: |
|
||||
err = fmt.Errorf("mssql: invalid type for datetime column: %T %s", val, val) |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
if col.ti.Size == 4 { |
|
||||
res.buffer = encodeDateTim4(t) |
|
||||
res.ti.Size = len(res.buffer) |
|
||||
} else if col.ti.Size == 8 { |
|
||||
res.buffer = encodeDateTime(t) |
|
||||
res.ti.Size = len(res.buffer) |
|
||||
} else { |
|
||||
err = fmt.Errorf("mssql: invalid size of column %d", col.ti.Size) |
|
||||
} |
|
||||
case typeTimeN: |
|
||||
var t time.Time |
|
||||
switch val := val.(type) { |
|
||||
case time.Time: |
|
||||
res.buffer = encodeTime(val.Hour(), val.Minute(), val.Second(), val.Nanosecond(), int(col.ti.Scale)) |
|
||||
res.ti.Size = len(res.buffer) |
|
||||
case string: |
|
||||
if t, err = time.Parse(sqlTimeFormat, val); err != nil { |
|
||||
return res, fmt.Errorf("bulk: unable to convert string to time: %v", err) |
|
||||
} |
|
||||
res.buffer = encodeTime(t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), int(col.ti.Scale)) |
|
||||
res.ti.Size = len(res.buffer) |
|
||||
default: |
|
||||
err = fmt.Errorf("mssql: invalid type for time column: %T %s", val, val) |
|
||||
return |
|
||||
} |
|
||||
// case typeMoney, typeMoney4, typeMoneyN:
|
|
||||
case typeDecimal, typeDecimalN, typeNumeric, typeNumericN: |
|
||||
prec := col.ti.Prec |
|
||||
scale := col.ti.Scale |
|
||||
var dec decimal.Decimal |
|
||||
switch v := val.(type) { |
|
||||
case int: |
|
||||
dec = decimal.Int64ToDecimalScale(int64(v), 0) |
|
||||
case int8: |
|
||||
dec = decimal.Int64ToDecimalScale(int64(v), 0) |
|
||||
case int16: |
|
||||
dec = decimal.Int64ToDecimalScale(int64(v), 0) |
|
||||
case int32: |
|
||||
dec = decimal.Int64ToDecimalScale(int64(v), 0) |
|
||||
case int64: |
|
||||
dec = decimal.Int64ToDecimalScale(int64(v), 0) |
|
||||
case float32: |
|
||||
dec, err = decimal.Float64ToDecimalScale(float64(v), scale) |
|
||||
case float64: |
|
||||
dec, err = decimal.Float64ToDecimalScale(float64(v), scale) |
|
||||
case string: |
|
||||
dec, err = decimal.StringToDecimalScale(v, scale) |
|
||||
default: |
|
||||
return res, fmt.Errorf("unknown value for decimal: %T %#v", v, v) |
|
||||
} |
|
||||
|
|
||||
if err != nil { |
|
||||
return res, err |
|
||||
} |
|
||||
dec.SetPrec(prec) |
|
||||
|
|
||||
var length byte |
|
||||
switch { |
|
||||
case prec <= 9: |
|
||||
length = 4 |
|
||||
case prec <= 19: |
|
||||
length = 8 |
|
||||
case prec <= 28: |
|
||||
length = 12 |
|
||||
default: |
|
||||
length = 16 |
|
||||
} |
|
||||
|
|
||||
buf := make([]byte, length+1) |
|
||||
// first byte length written by typeInfo.writer
|
|
||||
res.ti.Size = int(length) + 1 |
|
||||
// second byte sign
|
|
||||
if !dec.IsPositive() { |
|
||||
buf[0] = 0 |
|
||||
} else { |
|
||||
buf[0] = 1 |
|
||||
} |
|
||||
|
|
||||
ub := dec.UnscaledBytes() |
|
||||
l := len(ub) |
|
||||
if l > int(length) { |
|
||||
err = fmt.Errorf("decimal out of range: %s", dec) |
|
||||
return res, err |
|
||||
} |
|
||||
// reverse the bytes
|
|
||||
for i, j := 1, l-1; j >= 0; i, j = i+1, j-1 { |
|
||||
buf[i] = ub[j] |
|
||||
} |
|
||||
res.buffer = buf |
|
||||
case typeBigVarBin, typeBigBinary: |
|
||||
switch val := val.(type) { |
|
||||
case []byte: |
|
||||
res.ti.Size = len(val) |
|
||||
res.buffer = val |
|
||||
default: |
|
||||
err = fmt.Errorf("mssql: invalid type for Binary column: %T %s", val, val) |
|
||||
return |
|
||||
} |
|
||||
case typeGuid: |
|
||||
switch val := val.(type) { |
|
||||
case []byte: |
|
||||
res.ti.Size = len(val) |
|
||||
res.buffer = val |
|
||||
default: |
|
||||
err = fmt.Errorf("mssql: invalid type for Guid column: %T %s", val, val) |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
default: |
|
||||
err = fmt.Errorf("mssql: type %x not implemented", col.ti.TypeId) |
|
||||
} |
|
||||
return |
|
||||
|
|
||||
} |
|
||||
|
|
||||
func (b *Bulk) dlogf(format string, v ...interface{}) { |
|
||||
if b.Debug { |
|
||||
b.cn.sess.log.Printf(format, v...) |
|
||||
} |
|
||||
} |
|
@ -1,93 +0,0 @@ |
|||||
package mssql |
|
||||
|
|
||||
import ( |
|
||||
"context" |
|
||||
"database/sql/driver" |
|
||||
"encoding/json" |
|
||||
"errors" |
|
||||
) |
|
||||
|
|
||||
type copyin struct { |
|
||||
cn *Conn |
|
||||
bulkcopy *Bulk |
|
||||
closed bool |
|
||||
} |
|
||||
|
|
||||
type serializableBulkConfig struct { |
|
||||
TableName string |
|
||||
ColumnsName []string |
|
||||
Options BulkOptions |
|
||||
} |
|
||||
|
|
||||
func (d *Driver) OpenConnection(dsn string) (*Conn, error) { |
|
||||
return d.open(context.Background(), dsn) |
|
||||
} |
|
||||
|
|
||||
func (c *Conn) prepareCopyIn(ctx context.Context, query string) (_ driver.Stmt, err error) { |
|
||||
config_json := query[11:] |
|
||||
|
|
||||
bulkconfig := serializableBulkConfig{} |
|
||||
err = json.Unmarshal([]byte(config_json), &bulkconfig) |
|
||||
if err != nil { |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
bulkcopy := c.CreateBulkContext(ctx, bulkconfig.TableName, bulkconfig.ColumnsName) |
|
||||
bulkcopy.Options = bulkconfig.Options |
|
||||
|
|
||||
ci := ©in{ |
|
||||
cn: c, |
|
||||
bulkcopy: bulkcopy, |
|
||||
} |
|
||||
|
|
||||
return ci, nil |
|
||||
} |
|
||||
|
|
||||
func CopyIn(table string, options BulkOptions, columns ...string) string { |
|
||||
bulkconfig := &serializableBulkConfig{TableName: table, Options: options, ColumnsName: columns} |
|
||||
|
|
||||
config_json, err := json.Marshal(bulkconfig) |
|
||||
if err != nil { |
|
||||
panic(err) |
|
||||
} |
|
||||
|
|
||||
stmt := "INSERTBULK " + string(config_json) |
|
||||
|
|
||||
return stmt |
|
||||
} |
|
||||
|
|
||||
func (ci *copyin) NumInput() int { |
|
||||
return -1 |
|
||||
} |
|
||||
|
|
||||
func (ci *copyin) Query(v []driver.Value) (r driver.Rows, err error) { |
|
||||
panic("should never be called") |
|
||||
} |
|
||||
|
|
||||
func (ci *copyin) Exec(v []driver.Value) (r driver.Result, err error) { |
|
||||
if ci.closed { |
|
||||
return nil, errors.New("copyin query is closed") |
|
||||
} |
|
||||
|
|
||||
if len(v) == 0 { |
|
||||
rowCount, err := ci.bulkcopy.Done() |
|
||||
ci.closed = true |
|
||||
return driver.RowsAffected(rowCount), err |
|
||||
} |
|
||||
|
|
||||
t := make([]interface{}, len(v)) |
|
||||
for i, val := range v { |
|
||||
t[i] = val |
|
||||
} |
|
||||
|
|
||||
err = ci.bulkcopy.AddRow(t) |
|
||||
if err != nil { |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
return driver.RowsAffected(0), nil |
|
||||
} |
|
||||
|
|
||||
func (ci *copyin) Close() (err error) { |
|
||||
return nil |
|
||||
} |
|
@ -1,500 +0,0 @@ |
|||||
package mssql |
|
||||
|
|
||||
import ( |
|
||||
"fmt" |
|
||||
"net" |
|
||||
"net/url" |
|
||||
"os" |
|
||||
"strconv" |
|
||||
"strings" |
|
||||
"time" |
|
||||
"unicode" |
|
||||
) |
|
||||
|
|
||||
const defaultServerPort = 1433 |
|
||||
|
|
||||
type connectParams struct { |
|
||||
logFlags uint64 |
|
||||
port uint64 |
|
||||
host string |
|
||||
instance string |
|
||||
database string |
|
||||
user string |
|
||||
password string |
|
||||
dial_timeout time.Duration |
|
||||
conn_timeout time.Duration |
|
||||
keepAlive time.Duration |
|
||||
encrypt bool |
|
||||
disableEncryption bool |
|
||||
trustServerCertificate bool |
|
||||
certificate string |
|
||||
hostInCertificate string |
|
||||
hostInCertificateProvided bool |
|
||||
serverSPN string |
|
||||
workstation string |
|
||||
appname string |
|
||||
typeFlags uint8 |
|
||||
failOverPartner string |
|
||||
failOverPort uint64 |
|
||||
packetSize uint16 |
|
||||
fedAuthLibrary int |
|
||||
fedAuthADALWorkflow byte |
|
||||
} |
|
||||
|
|
||||
// default packet size for TDS buffer
|
|
||||
const defaultPacketSize = 4096 |
|
||||
|
|
||||
func parseConnectParams(dsn string) (connectParams, error) { |
|
||||
p := connectParams{ |
|
||||
fedAuthLibrary: fedAuthLibraryReserved, |
|
||||
} |
|
||||
|
|
||||
var params map[string]string |
|
||||
if strings.HasPrefix(dsn, "odbc:") { |
|
||||
parameters, err := splitConnectionStringOdbc(dsn[len("odbc:"):]) |
|
||||
if err != nil { |
|
||||
return p, err |
|
||||
} |
|
||||
params = parameters |
|
||||
} else if strings.HasPrefix(dsn, "sqlserver://") { |
|
||||
parameters, err := splitConnectionStringURL(dsn) |
|
||||
if err != nil { |
|
||||
return p, err |
|
||||
} |
|
||||
params = parameters |
|
||||
} else { |
|
||||
params = splitConnectionString(dsn) |
|
||||
} |
|
||||
|
|
||||
strlog, ok := params["log"] |
|
||||
if ok { |
|
||||
var err error |
|
||||
p.logFlags, err = strconv.ParseUint(strlog, 10, 64) |
|
||||
if err != nil { |
|
||||
return p, fmt.Errorf("invalid log parameter '%s': %s", strlog, err.Error()) |
|
||||
} |
|
||||
} |
|
||||
server := params["server"] |
|
||||
parts := strings.SplitN(server, `\`, 2) |
|
||||
p.host = parts[0] |
|
||||
if p.host == "." || strings.ToUpper(p.host) == "(LOCAL)" || p.host == "" { |
|
||||
p.host = "localhost" |
|
||||
} |
|
||||
if len(parts) > 1 { |
|
||||
p.instance = parts[1] |
|
||||
} |
|
||||
p.database = params["database"] |
|
||||
p.user = params["user id"] |
|
||||
p.password = params["password"] |
|
||||
|
|
||||
p.port = 0 |
|
||||
strport, ok := params["port"] |
|
||||
if ok { |
|
||||
var err error |
|
||||
p.port, err = strconv.ParseUint(strport, 10, 16) |
|
||||
if err != nil { |
|
||||
f := "invalid tcp port '%v': %v" |
|
||||
return p, fmt.Errorf(f, strport, err.Error()) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/configure-the-network-packet-size-server-configuration-option
|
|
||||
p.packetSize = defaultPacketSize |
|
||||
strpsize, ok := params["packet size"] |
|
||||
if ok { |
|
||||
var err error |
|
||||
psize, err := strconv.ParseUint(strpsize, 0, 16) |
|
||||
if err != nil { |
|
||||
f := "invalid packet size '%v': %v" |
|
||||
return p, fmt.Errorf(f, strpsize, err.Error()) |
|
||||
} |
|
||||
|
|
||||
// Ensure packet size falls within the TDS protocol range of 512 to 32767 bytes
|
|
||||
// NOTE: Encrypted connections have a maximum size of 16383 bytes. If you request
|
|
||||
// a higher packet size, the server will respond with an ENVCHANGE request to
|
|
||||
// alter the packet size to 16383 bytes.
|
|
||||
p.packetSize = uint16(psize) |
|
||||
if p.packetSize < 512 { |
|
||||
p.packetSize = 512 |
|
||||
} else if p.packetSize > 32767 { |
|
||||
p.packetSize = 32767 |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// https://msdn.microsoft.com/en-us/library/dd341108.aspx
|
|
||||
//
|
|
||||
// Do not set a connection timeout. Use Context to manage such things.
|
|
||||
// Default to zero, but still allow it to be set.
|
|
||||
if strconntimeout, ok := params["connection timeout"]; ok { |
|
||||
timeout, err := strconv.ParseUint(strconntimeout, 10, 64) |
|
||||
if err != nil { |
|
||||
f := "invalid connection timeout '%v': %v" |
|
||||
return p, fmt.Errorf(f, strconntimeout, err.Error()) |
|
||||
} |
|
||||
p.conn_timeout = time.Duration(timeout) * time.Second |
|
||||
} |
|
||||
p.dial_timeout = 15 * time.Second |
|
||||
if strdialtimeout, ok := params["dial timeout"]; ok { |
|
||||
timeout, err := strconv.ParseUint(strdialtimeout, 10, 64) |
|
||||
if err != nil { |
|
||||
f := "invalid dial timeout '%v': %v" |
|
||||
return p, fmt.Errorf(f, strdialtimeout, err.Error()) |
|
||||
} |
|
||||
p.dial_timeout = time.Duration(timeout) * time.Second |
|
||||
} |
|
||||
|
|
||||
// default keep alive should be 30 seconds according to spec:
|
|
||||
// https://msdn.microsoft.com/en-us/library/dd341108.aspx
|
|
||||
p.keepAlive = 30 * time.Second |
|
||||
if keepAlive, ok := params["keepalive"]; ok { |
|
||||
timeout, err := strconv.ParseUint(keepAlive, 10, 64) |
|
||||
if err != nil { |
|
||||
f := "invalid keepAlive value '%s': %s" |
|
||||
return p, fmt.Errorf(f, keepAlive, err.Error()) |
|
||||
} |
|
||||
p.keepAlive = time.Duration(timeout) * time.Second |
|
||||
} |
|
||||
encrypt, ok := params["encrypt"] |
|
||||
if ok { |
|
||||
if strings.EqualFold(encrypt, "DISABLE") { |
|
||||
p.disableEncryption = true |
|
||||
} else { |
|
||||
var err error |
|
||||
p.encrypt, err = strconv.ParseBool(encrypt) |
|
||||
if err != nil { |
|
||||
f := "invalid encrypt '%s': %s" |
|
||||
return p, fmt.Errorf(f, encrypt, err.Error()) |
|
||||
} |
|
||||
} |
|
||||
} else { |
|
||||
p.trustServerCertificate = true |
|
||||
} |
|
||||
trust, ok := params["trustservercertificate"] |
|
||||
if ok { |
|
||||
var err error |
|
||||
p.trustServerCertificate, err = strconv.ParseBool(trust) |
|
||||
if err != nil { |
|
||||
f := "invalid trust server certificate '%s': %s" |
|
||||
return p, fmt.Errorf(f, trust, err.Error()) |
|
||||
} |
|
||||
} |
|
||||
p.certificate = params["certificate"] |
|
||||
p.hostInCertificate, ok = params["hostnameincertificate"] |
|
||||
if ok { |
|
||||
p.hostInCertificateProvided = true |
|
||||
} else { |
|
||||
p.hostInCertificate = p.host |
|
||||
p.hostInCertificateProvided = false |
|
||||
} |
|
||||
|
|
||||
serverSPN, ok := params["serverspn"] |
|
||||
if ok { |
|
||||
p.serverSPN = serverSPN |
|
||||
} else { |
|
||||
p.serverSPN = generateSpn(p.host, resolveServerPort(p.port)) |
|
||||
} |
|
||||
|
|
||||
workstation, ok := params["workstation id"] |
|
||||
if ok { |
|
||||
p.workstation = workstation |
|
||||
} else { |
|
||||
workstation, err := os.Hostname() |
|
||||
if err == nil { |
|
||||
p.workstation = workstation |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
appname, ok := params["app name"] |
|
||||
if !ok { |
|
||||
appname = "go-mssqldb" |
|
||||
} |
|
||||
p.appname = appname |
|
||||
|
|
||||
appintent, ok := params["applicationintent"] |
|
||||
if ok { |
|
||||
if appintent == "ReadOnly" { |
|
||||
if p.database == "" { |
|
||||
return p, fmt.Errorf("database must be specified when ApplicationIntent is ReadOnly") |
|
||||
} |
|
||||
p.typeFlags |= fReadOnlyIntent |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
failOverPartner, ok := params["failoverpartner"] |
|
||||
if ok { |
|
||||
p.failOverPartner = failOverPartner |
|
||||
} |
|
||||
|
|
||||
failOverPort, ok := params["failoverport"] |
|
||||
if ok { |
|
||||
var err error |
|
||||
p.failOverPort, err = strconv.ParseUint(failOverPort, 0, 16) |
|
||||
if err != nil { |
|
||||
f := "invalid tcp port '%v': %v" |
|
||||
return p, fmt.Errorf(f, failOverPort, err.Error()) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return p, nil |
|
||||
} |
|
||||
|
|
||||
// convert connectionParams to url style connection string
|
|
||||
// used mostly for testing
|
|
||||
func (p connectParams) toUrl() *url.URL { |
|
||||
q := url.Values{} |
|
||||
if p.database != "" { |
|
||||
q.Add("database", p.database) |
|
||||
} |
|
||||
if p.logFlags != 0 { |
|
||||
q.Add("log", strconv.FormatUint(p.logFlags, 10)) |
|
||||
} |
|
||||
res := url.URL{ |
|
||||
Scheme: "sqlserver", |
|
||||
Host: p.host, |
|
||||
User: url.UserPassword(p.user, p.password), |
|
||||
} |
|
||||
if p.instance != "" { |
|
||||
res.Path = p.instance |
|
||||
} |
|
||||
if len(q) > 0 { |
|
||||
res.RawQuery = q.Encode() |
|
||||
} |
|
||||
return &res |
|
||||
} |
|
||||
|
|
||||
func splitConnectionString(dsn string) (res map[string]string) { |
|
||||
res = map[string]string{} |
|
||||
parts := strings.Split(dsn, ";") |
|
||||
for _, part := range parts { |
|
||||
if len(part) == 0 { |
|
||||
continue |
|
||||
} |
|
||||
lst := strings.SplitN(part, "=", 2) |
|
||||
name := strings.TrimSpace(strings.ToLower(lst[0])) |
|
||||
if len(name) == 0 { |
|
||||
continue |
|
||||
} |
|
||||
var value string = "" |
|
||||
if len(lst) > 1 { |
|
||||
value = strings.TrimSpace(lst[1]) |
|
||||
} |
|
||||
res[name] = value |
|
||||
} |
|
||||
return res |
|
||||
} |
|
||||
|
|
||||
// Splits a URL of the form sqlserver://username:password@host/instance?param1=value¶m2=value
|
|
||||
func splitConnectionStringURL(dsn string) (map[string]string, error) { |
|
||||
res := map[string]string{} |
|
||||
|
|
||||
u, err := url.Parse(dsn) |
|
||||
if err != nil { |
|
||||
return res, err |
|
||||
} |
|
||||
|
|
||||
if u.Scheme != "sqlserver" { |
|
||||
return res, fmt.Errorf("scheme %s is not recognized", u.Scheme) |
|
||||
} |
|
||||
|
|
||||
if u.User != nil { |
|
||||
res["user id"] = u.User.Username() |
|
||||
p, exists := u.User.Password() |
|
||||
if exists { |
|
||||
res["password"] = p |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
host, port, err := net.SplitHostPort(u.Host) |
|
||||
if err != nil { |
|
||||
host = u.Host |
|
||||
} |
|
||||
|
|
||||
if len(u.Path) > 0 { |
|
||||
res["server"] = host + "\\" + u.Path[1:] |
|
||||
} else { |
|
||||
res["server"] = host |
|
||||
} |
|
||||
|
|
||||
if len(port) > 0 { |
|
||||
res["port"] = port |
|
||||
} |
|
||||
|
|
||||
query := u.Query() |
|
||||
for k, v := range query { |
|
||||
if len(v) > 1 { |
|
||||
return res, fmt.Errorf("key %s provided more than once", k) |
|
||||
} |
|
||||
res[strings.ToLower(k)] = v[0] |
|
||||
} |
|
||||
|
|
||||
return res, nil |
|
||||
} |
|
||||
|
|
||||
// Splits a URL in the ODBC format
|
|
||||
func splitConnectionStringOdbc(dsn string) (map[string]string, error) { |
|
||||
res := map[string]string{} |
|
||||
|
|
||||
type parserState int |
|
||||
const ( |
|
||||
// Before the start of a key
|
|
||||
parserStateBeforeKey parserState = iota |
|
||||
|
|
||||
// Inside a key
|
|
||||
parserStateKey |
|
||||
|
|
||||
// Beginning of a value. May be bare or braced
|
|
||||
parserStateBeginValue |
|
||||
|
|
||||
// Inside a bare value
|
|
||||
parserStateBareValue |
|
||||
|
|
||||
// Inside a braced value
|
|
||||
parserStateBracedValue |
|
||||
|
|
||||
// A closing brace inside a braced value.
|
|
||||
// May be the end of the value or an escaped closing brace, depending on the next character
|
|
||||
parserStateBracedValueClosingBrace |
|
||||
|
|
||||
// After a value. Next character should be a semicolon or whitespace.
|
|
||||
parserStateEndValue |
|
||||
) |
|
||||
|
|
||||
var state = parserStateBeforeKey |
|
||||
|
|
||||
var key string |
|
||||
var value string |
|
||||
|
|
||||
for i, c := range dsn { |
|
||||
switch state { |
|
||||
case parserStateBeforeKey: |
|
||||
switch { |
|
||||
case c == '=': |
|
||||
return res, fmt.Errorf("unexpected character = at index %d. Expected start of key or semi-colon or whitespace", i) |
|
||||
case !unicode.IsSpace(c) && c != ';': |
|
||||
state = parserStateKey |
|
||||
key += string(c) |
|
||||
} |
|
||||
|
|
||||
case parserStateKey: |
|
||||
switch c { |
|
||||
case '=': |
|
||||
key = normalizeOdbcKey(key) |
|
||||
state = parserStateBeginValue |
|
||||
|
|
||||
case ';': |
|
||||
// Key without value
|
|
||||
key = normalizeOdbcKey(key) |
|
||||
res[key] = value |
|
||||
key = "" |
|
||||
value = "" |
|
||||
state = parserStateBeforeKey |
|
||||
|
|
||||
default: |
|
||||
key += string(c) |
|
||||
} |
|
||||
|
|
||||
case parserStateBeginValue: |
|
||||
switch { |
|
||||
case c == '{': |
|
||||
state = parserStateBracedValue |
|
||||
case c == ';': |
|
||||
// Empty value
|
|
||||
res[key] = value |
|
||||
key = "" |
|
||||
state = parserStateBeforeKey |
|
||||
case unicode.IsSpace(c): |
|
||||
// Ignore whitespace
|
|
||||
default: |
|
||||
state = parserStateBareValue |
|
||||
value += string(c) |
|
||||
} |
|
||||
|
|
||||
case parserStateBareValue: |
|
||||
if c == ';' { |
|
||||
res[key] = strings.TrimRightFunc(value, unicode.IsSpace) |
|
||||
key = "" |
|
||||
value = "" |
|
||||
state = parserStateBeforeKey |
|
||||
} else { |
|
||||
value += string(c) |
|
||||
} |
|
||||
|
|
||||
case parserStateBracedValue: |
|
||||
if c == '}' { |
|
||||
state = parserStateBracedValueClosingBrace |
|
||||
} else { |
|
||||
value += string(c) |
|
||||
} |
|
||||
|
|
||||
case parserStateBracedValueClosingBrace: |
|
||||
if c == '}' { |
|
||||
// Escaped closing brace
|
|
||||
value += string(c) |
|
||||
state = parserStateBracedValue |
|
||||
continue |
|
||||
} |
|
||||
|
|
||||
// End of braced value
|
|
||||
res[key] = value |
|
||||
key = "" |
|
||||
value = "" |
|
||||
|
|
||||
// This character is the first character past the end,
|
|
||||
// so it needs to be parsed like the parserStateEndValue state.
|
|
||||
state = parserStateEndValue |
|
||||
switch { |
|
||||
case c == ';': |
|
||||
state = parserStateBeforeKey |
|
||||
case unicode.IsSpace(c): |
|
||||
// Ignore whitespace
|
|
||||
default: |
|
||||
return res, fmt.Errorf("unexpected character %c at index %d. Expected semi-colon or whitespace", c, i) |
|
||||
} |
|
||||
|
|
||||
case parserStateEndValue: |
|
||||
switch { |
|
||||
case c == ';': |
|
||||
state = parserStateBeforeKey |
|
||||
case unicode.IsSpace(c): |
|
||||
// Ignore whitespace
|
|
||||
default: |
|
||||
return res, fmt.Errorf("unexpected character %c at index %d. Expected semi-colon or whitespace", c, i) |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
switch state { |
|
||||
case parserStateBeforeKey: // Okay
|
|
||||
case parserStateKey: // Unfinished key. Treat as key without value.
|
|
||||
key = normalizeOdbcKey(key) |
|
||||
res[key] = value |
|
||||
case parserStateBeginValue: // Empty value
|
|
||||
res[key] = value |
|
||||
case parserStateBareValue: |
|
||||
res[key] = strings.TrimRightFunc(value, unicode.IsSpace) |
|
||||
case parserStateBracedValue: |
|
||||
return res, fmt.Errorf("unexpected end of braced value at index %d", len(dsn)) |
|
||||
case parserStateBracedValueClosingBrace: // End of braced value
|
|
||||
res[key] = value |
|
||||
case parserStateEndValue: // Okay
|
|
||||
} |
|
||||
|
|
||||
return res, nil |
|
||||
} |
|
||||
|
|
||||
// Normalizes the given string as an ODBC-format key
|
|
||||
func normalizeOdbcKey(s string) string { |
|
||||
return strings.ToLower(strings.TrimRightFunc(s, unicode.IsSpace)) |
|
||||
} |
|
||||
|
|
||||
func resolveServerPort(port uint64) uint64 { |
|
||||
if port == 0 { |
|
||||
return defaultServerPort |
|
||||
} |
|
||||
|
|
||||
return port |
|
||||
} |
|
||||
|
|
||||
func generateSpn(host string, port uint64) string { |
|
||||
return fmt.Sprintf("MSSQLSvc/%s:%d", host, port) |
|
||||
} |
|
@ -1,306 +0,0 @@ |
|||||
package mssql |
|
||||
|
|
||||
import "errors" |
|
||||
|
|
||||
// Copyright 2011 The Go Authors. All rights reserved.
|
|
||||
// Use of this source code is governed by a BSD-style
|
|
||||
// license that can be found in the LICENSE file.
|
|
||||
|
|
||||
// Type conversions for Scan.
|
|
||||
|
|
||||
// This file was imported from database.sql.convert for go 1.10.3 with minor modifications to get
|
|
||||
// convertAssign function
|
|
||||
// This function is used internally by sql to convert values during call to Scan, we need same
|
|
||||
// logic to return values for OUTPUT parameters.
|
|
||||
// TODO: sql library should instead expose function defaultCheckNamedValue to be callable by drivers
|
|
||||
|
|
||||
import ( |
|
||||
"database/sql" |
|
||||
"database/sql/driver" |
|
||||
"fmt" |
|
||||
"reflect" |
|
||||
"strconv" |
|
||||
"time" |
|
||||
) |
|
||||
|
|
||||
var errNilPtr = errors.New("destination pointer is nil") // embedded in descriptive error
|
|
||||
|
|
||||
// convertAssign copies to dest the value in src, converting it if possible.
|
|
||||
// An error is returned if the copy would result in loss of information.
|
|
||||
// dest should be a pointer type.
|
|
||||
func convertAssign(dest, src interface{}) error { |
|
||||
// Common cases, without reflect.
|
|
||||
switch s := src.(type) { |
|
||||
case string: |
|
||||
switch d := dest.(type) { |
|
||||
case *string: |
|
||||
if d == nil { |
|
||||
return errNilPtr |
|
||||
} |
|
||||
*d = s |
|
||||
return nil |
|
||||
case *[]byte: |
|
||||
if d == nil { |
|
||||
return errNilPtr |
|
||||
} |
|
||||
*d = []byte(s) |
|
||||
return nil |
|
||||
case *sql.RawBytes: |
|
||||
if d == nil { |
|
||||
return errNilPtr |
|
||||
} |
|
||||
*d = append((*d)[:0], s...) |
|
||||
return nil |
|
||||
} |
|
||||
case []byte: |
|
||||
switch d := dest.(type) { |
|
||||
case *string: |
|
||||
if d == nil { |
|
||||
return errNilPtr |
|
||||
} |
|
||||
*d = string(s) |
|
||||
return nil |
|
||||
case *interface{}: |
|
||||
if d == nil { |
|
||||
return errNilPtr |
|
||||
} |
|
||||
*d = cloneBytes(s) |
|
||||
return nil |
|
||||
case *[]byte: |
|
||||
if d == nil { |
|
||||
return errNilPtr |
|
||||
} |
|
||||
*d = cloneBytes(s) |
|
||||
return nil |
|
||||
case *sql.RawBytes: |
|
||||
if d == nil { |
|
||||
return errNilPtr |
|
||||
} |
|
||||
*d = s |
|
||||
return nil |
|
||||
} |
|
||||
case time.Time: |
|
||||
switch d := dest.(type) { |
|
||||
case *time.Time: |
|
||||
*d = s |
|
||||
return nil |
|
||||
case *string: |
|
||||
*d = s.Format(time.RFC3339Nano) |
|
||||
return nil |
|
||||
case *[]byte: |
|
||||
if d == nil { |
|
||||
return errNilPtr |
|
||||
} |
|
||||
*d = []byte(s.Format(time.RFC3339Nano)) |
|
||||
return nil |
|
||||
case *sql.RawBytes: |
|
||||
if d == nil { |
|
||||
return errNilPtr |
|
||||
} |
|
||||
*d = s.AppendFormat((*d)[:0], time.RFC3339Nano) |
|
||||
return nil |
|
||||
} |
|
||||
case nil: |
|
||||
switch d := dest.(type) { |
|
||||
case *interface{}: |
|
||||
if d == nil { |
|
||||
return errNilPtr |
|
||||
} |
|
||||
*d = nil |
|
||||
return nil |
|
||||
case *[]byte: |
|
||||
if d == nil { |
|
||||
return errNilPtr |
|
||||
} |
|
||||
*d = nil |
|
||||
return nil |
|
||||
case *sql.RawBytes: |
|
||||
if d == nil { |
|
||||
return errNilPtr |
|
||||
} |
|
||||
*d = nil |
|
||||
return nil |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
var sv reflect.Value |
|
||||
|
|
||||
switch d := dest.(type) { |
|
||||
case *string: |
|
||||
sv = reflect.ValueOf(src) |
|
||||
switch sv.Kind() { |
|
||||
case reflect.Bool, |
|
||||
reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, |
|
||||
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, |
|
||||
reflect.Float32, reflect.Float64: |
|
||||
*d = asString(src) |
|
||||
return nil |
|
||||
} |
|
||||
case *[]byte: |
|
||||
sv = reflect.ValueOf(src) |
|
||||
if b, ok := asBytes(nil, sv); ok { |
|
||||
*d = b |
|
||||
return nil |
|
||||
} |
|
||||
case *sql.RawBytes: |
|
||||
sv = reflect.ValueOf(src) |
|
||||
if b, ok := asBytes([]byte(*d)[:0], sv); ok { |
|
||||
*d = sql.RawBytes(b) |
|
||||
return nil |
|
||||
} |
|
||||
case *bool: |
|
||||
bv, err := driver.Bool.ConvertValue(src) |
|
||||
if err == nil { |
|
||||
*d = bv.(bool) |
|
||||
} |
|
||||
return err |
|
||||
case *interface{}: |
|
||||
*d = src |
|
||||
return nil |
|
||||
} |
|
||||
|
|
||||
if scanner, ok := dest.(sql.Scanner); ok { |
|
||||
return scanner.Scan(src) |
|
||||
} |
|
||||
|
|
||||
dpv := reflect.ValueOf(dest) |
|
||||
if dpv.Kind() != reflect.Ptr { |
|
||||
return errors.New("destination not a pointer") |
|
||||
} |
|
||||
if dpv.IsNil() { |
|
||||
return errNilPtr |
|
||||
} |
|
||||
|
|
||||
if !sv.IsValid() { |
|
||||
sv = reflect.ValueOf(src) |
|
||||
} |
|
||||
|
|
||||
dv := reflect.Indirect(dpv) |
|
||||
if sv.IsValid() && sv.Type().AssignableTo(dv.Type()) { |
|
||||
switch b := src.(type) { |
|
||||
case []byte: |
|
||||
dv.Set(reflect.ValueOf(cloneBytes(b))) |
|
||||
default: |
|
||||
dv.Set(sv) |
|
||||
} |
|
||||
return nil |
|
||||
} |
|
||||
|
|
||||
if dv.Kind() == sv.Kind() && sv.Type().ConvertibleTo(dv.Type()) { |
|
||||
dv.Set(sv.Convert(dv.Type())) |
|
||||
return nil |
|
||||
} |
|
||||
|
|
||||
// The following conversions use a string value as an intermediate representation
|
|
||||
// to convert between various numeric types.
|
|
||||
//
|
|
||||
// This also allows scanning into user defined types such as "type Int int64".
|
|
||||
// For symmetry, also check for string destination types.
|
|
||||
switch dv.Kind() { |
|
||||
case reflect.Ptr: |
|
||||
if src == nil { |
|
||||
dv.Set(reflect.Zero(dv.Type())) |
|
||||
return nil |
|
||||
} else { |
|
||||
dv.Set(reflect.New(dv.Type().Elem())) |
|
||||
return convertAssign(dv.Interface(), src) |
|
||||
} |
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: |
|
||||
s := asString(src) |
|
||||
i64, err := strconv.ParseInt(s, 10, dv.Type().Bits()) |
|
||||
if err != nil { |
|
||||
err = strconvErr(err) |
|
||||
return fmt.Errorf("converting driver.Value type %T (%q) to a %s: %v", src, s, dv.Kind(), err) |
|
||||
} |
|
||||
dv.SetInt(i64) |
|
||||
return nil |
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: |
|
||||
s := asString(src) |
|
||||
u64, err := strconv.ParseUint(s, 10, dv.Type().Bits()) |
|
||||
if err != nil { |
|
||||
err = strconvErr(err) |
|
||||
return fmt.Errorf("converting driver.Value type %T (%q) to a %s: %v", src, s, dv.Kind(), err) |
|
||||
} |
|
||||
dv.SetUint(u64) |
|
||||
return nil |
|
||||
case reflect.Float32, reflect.Float64: |
|
||||
s := asString(src) |
|
||||
f64, err := strconv.ParseFloat(s, dv.Type().Bits()) |
|
||||
if err != nil { |
|
||||
err = strconvErr(err) |
|
||||
return fmt.Errorf("converting driver.Value type %T (%q) to a %s: %v", src, s, dv.Kind(), err) |
|
||||
} |
|
||||
dv.SetFloat(f64) |
|
||||
return nil |
|
||||
case reflect.String: |
|
||||
switch v := src.(type) { |
|
||||
case string: |
|
||||
dv.SetString(v) |
|
||||
return nil |
|
||||
case []byte: |
|
||||
dv.SetString(string(v)) |
|
||||
return nil |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return fmt.Errorf("unsupported Scan, storing driver.Value type %T into type %T", src, dest) |
|
||||
} |
|
||||
|
|
||||
func strconvErr(err error) error { |
|
||||
if ne, ok := err.(*strconv.NumError); ok { |
|
||||
return ne.Err |
|
||||
} |
|
||||
return err |
|
||||
} |
|
||||
|
|
||||
func cloneBytes(b []byte) []byte { |
|
||||
if b == nil { |
|
||||
return nil |
|
||||
} else { |
|
||||
c := make([]byte, len(b)) |
|
||||
copy(c, b) |
|
||||
return c |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
func asString(src interface{}) string { |
|
||||
switch v := src.(type) { |
|
||||
case string: |
|
||||
return v |
|
||||
case []byte: |
|
||||
return string(v) |
|
||||
} |
|
||||
rv := reflect.ValueOf(src) |
|
||||
switch rv.Kind() { |
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: |
|
||||
return strconv.FormatInt(rv.Int(), 10) |
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: |
|
||||
return strconv.FormatUint(rv.Uint(), 10) |
|
||||
case reflect.Float64: |
|
||||
return strconv.FormatFloat(rv.Float(), 'g', -1, 64) |
|
||||
case reflect.Float32: |
|
||||
return strconv.FormatFloat(rv.Float(), 'g', -1, 32) |
|
||||
case reflect.Bool: |
|
||||
return strconv.FormatBool(rv.Bool()) |
|
||||
} |
|
||||
return fmt.Sprintf("%v", src) |
|
||||
} |
|
||||
|
|
||||
func asBytes(buf []byte, rv reflect.Value) (b []byte, ok bool) { |
|
||||
switch rv.Kind() { |
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: |
|
||||
return strconv.AppendInt(buf, rv.Int(), 10), true |
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: |
|
||||
return strconv.AppendUint(buf, rv.Uint(), 10), true |
|
||||
case reflect.Float32: |
|
||||
return strconv.AppendFloat(buf, rv.Float(), 'g', -1, 32), true |
|
||||
case reflect.Float64: |
|
||||
return strconv.AppendFloat(buf, rv.Float(), 'g', -1, 64), true |
|
||||
case reflect.Bool: |
|
||||
return strconv.AppendBool(buf, rv.Bool()), true |
|
||||
case reflect.String: |
|
||||
s := rv.String() |
|
||||
return append(buf, s...), true |
|
||||
} |
|
||||
return |
|
||||
} |
|
@ -1,14 +0,0 @@ |
|||||
// package mssql implements the TDS protocol used to connect to MS SQL Server (sqlserver)
|
|
||||
// database servers.
|
|
||||
//
|
|
||||
// This package registers the driver:
|
|
||||
// sqlserver: uses native "@" parameter placeholder names and does no pre-processing.
|
|
||||
//
|
|
||||
// If the ordinal position is used for query parameters, identifiers will be named
|
|
||||
// "@p1", "@p2", ... "@pN".
|
|
||||
//
|
|
||||
// Please refer to the README for the format of the DSN. There are multiple DSN
|
|
||||
// formats accepted: ADO style, ODBC style, and URL style. The following is an
|
|
||||
// example of a URL style DSN:
|
|
||||
// sqlserver://sa:mypass@localhost:1234?database=master&connection+timeout=30
|
|
||||
package mssql |
|
@ -1,73 +0,0 @@ |
|||||
package mssql |
|
||||
|
|
||||
import ( |
|
||||
"fmt" |
|
||||
) |
|
||||
|
|
||||
// Error represents an SQL Server error. This
|
|
||||
// type includes methods for reading the contents
|
|
||||
// of the struct, which allows calling programs
|
|
||||
// to check for specific error conditions without
|
|
||||
// having to import this package directly.
|
|
||||
type Error struct { |
|
||||
Number int32 |
|
||||
State uint8 |
|
||||
Class uint8 |
|
||||
Message string |
|
||||
ServerName string |
|
||||
ProcName string |
|
||||
LineNo int32 |
|
||||
} |
|
||||
|
|
||||
func (e Error) Error() string { |
|
||||
return "mssql: " + e.Message |
|
||||
} |
|
||||
|
|
||||
// SQLErrorNumber returns the SQL Server error number.
|
|
||||
func (e Error) SQLErrorNumber() int32 { |
|
||||
return e.Number |
|
||||
} |
|
||||
|
|
||||
func (e Error) SQLErrorState() uint8 { |
|
||||
return e.State |
|
||||
} |
|
||||
|
|
||||
func (e Error) SQLErrorClass() uint8 { |
|
||||
return e.Class |
|
||||
} |
|
||||
|
|
||||
func (e Error) SQLErrorMessage() string { |
|
||||
return e.Message |
|
||||
} |
|
||||
|
|
||||
func (e Error) SQLErrorServerName() string { |
|
||||
return e.ServerName |
|
||||
} |
|
||||
|
|
||||
func (e Error) SQLErrorProcName() string { |
|
||||
return e.ProcName |
|
||||
} |
|
||||
|
|
||||
func (e Error) SQLErrorLineNo() int32 { |
|
||||
return e.LineNo |
|
||||
} |
|
||||
|
|
||||
type StreamError struct { |
|
||||
Message string |
|
||||
} |
|
||||
|
|
||||
func (e StreamError) Error() string { |
|
||||
return e.Message |
|
||||
} |
|
||||
|
|
||||
func streamErrorf(format string, v ...interface{}) StreamError { |
|
||||
return StreamError{"Invalid TDS stream: " + fmt.Sprintf(format, v...)} |
|
||||
} |
|
||||
|
|
||||
func badStreamPanic(err error) { |
|
||||
panic(err) |
|
||||
} |
|
||||
|
|
||||
func badStreamPanicf(format string, v ...interface{}) { |
|
||||
panic(streamErrorf(format, v...)) |
|
||||
} |
|
@ -1,82 +0,0 @@ |
|||||
package mssql |
|
||||
|
|
||||
import ( |
|
||||
"context" |
|
||||
"errors" |
|
||||
) |
|
||||
|
|
||||
// Federated authentication library affects the login data structure and message sequence.
|
|
||||
const ( |
|
||||
// fedAuthLibraryLiveIDCompactToken specifies the Microsoft Live ID Compact Token authentication scheme
|
|
||||
fedAuthLibraryLiveIDCompactToken = 0x00 |
|
||||
|
|
||||
// fedAuthLibrarySecurityToken specifies a token-based authentication where the token is available
|
|
||||
// without additional information provided during the login sequence.
|
|
||||
fedAuthLibrarySecurityToken = 0x01 |
|
||||
|
|
||||
// fedAuthLibraryADAL specifies a token-based authentication where a token is obtained during the
|
|
||||
// login sequence using the server SPN and STS URL provided by the server during login.
|
|
||||
fedAuthLibraryADAL = 0x02 |
|
||||
|
|
||||
// fedAuthLibraryReserved is used to indicate that no federated authentication scheme applies.
|
|
||||
fedAuthLibraryReserved = 0x7F |
|
||||
) |
|
||||
|
|
||||
// Federated authentication ADAL workflow affects the mechanism used to authenticate.
|
|
||||
const ( |
|
||||
// fedAuthADALWorkflowPassword uses a username/password to obtain a token from Active Directory
|
|
||||
fedAuthADALWorkflowPassword = 0x01 |
|
||||
|
|
||||
// fedAuthADALWorkflowPassword uses the Windows identity to obtain a token from Active Directory
|
|
||||
fedAuthADALWorkflowIntegrated = 0x02 |
|
||||
|
|
||||
// fedAuthADALWorkflowMSI uses the managed identity service to obtain a token
|
|
||||
fedAuthADALWorkflowMSI = 0x03 |
|
||||
) |
|
||||
|
|
||||
// newSecurityTokenConnector creates a new connector from a DSN and a token provider.
|
|
||||
// When invoked, token provider implementations should contact the security token
|
|
||||
// service specified and obtain the appropriate token, or return an error
|
|
||||
// to indicate why a token is not available.
|
|
||||
// The returned connector may be used with sql.OpenDB.
|
|
||||
func newSecurityTokenConnector(dsn string, tokenProvider func(ctx context.Context) (string, error)) (*Connector, error) { |
|
||||
if tokenProvider == nil { |
|
||||
return nil, errors.New("mssql: tokenProvider cannot be nil") |
|
||||
} |
|
||||
|
|
||||
conn, err := NewConnector(dsn) |
|
||||
if err != nil { |
|
||||
return nil, err |
|
||||
} |
|
||||
|
|
||||
conn.params.fedAuthLibrary = fedAuthLibrarySecurityToken |
|
||||
conn.securityTokenProvider = tokenProvider |
|
||||
|
|
||||
return conn, nil |
|
||||
} |
|
||||
|
|
||||
// newADALTokenConnector creates a new connector from a DSN and a Active Directory token provider.
|
|
||||
// Token provider implementations are called during federated
|
|
||||
// authentication login sequences where the server provides a service
|
|
||||
// principal name and security token service endpoint that should be used
|
|
||||
// to obtain the token. Implementations should contact the security token
|
|
||||
// service specified and obtain the appropriate token, or return an error
|
|
||||
// to indicate why a token is not available.
|
|
||||
//
|
|
||||
// The returned connector may be used with sql.OpenDB.
|
|
||||
func newActiveDirectoryTokenConnector(dsn string, adalWorkflow byte, tokenProvider func(ctx context.Context, serverSPN, stsURL string) (string, error)) (*Connector, error) { |
|
||||
if tokenProvider == nil { |
|
||||
return nil, errors.New("mssql: tokenProvider cannot be nil") |
|
||||
} |
|
||||
|
|
||||
conn, err := NewConnector(dsn) |
|
||||
if err != nil { |
|
||||
return nil, err |
|
||||
} |
|
||||
|
|
||||
conn.params.fedAuthLibrary = fedAuthLibraryADAL |
|
||||
conn.params.fedAuthADALWorkflow = adalWorkflow |
|
||||
conn.adalTokenProvider = tokenProvider |
|
||||
|
|
||||
return conn, nil |
|
||||
} |
|
@ -1,8 +0,0 @@ |
|||||
module github.com/denisenkom/go-mssqldb |
|
||||
|
|
||||
go 1.11 |
|
||||
|
|
||||
require ( |
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe |
|
||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c |
|
||||
) |
|
@ -1,5 +0,0 @@ |
|||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= |
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= |
|
||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI= |
|
||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= |
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|
@ -1,113 +0,0 @@ |
|||||
package cp |
|
||||
|
|
||||
type charsetMap struct { |
|
||||
sb [256]rune // single byte runes, -1 for a double byte character lead byte
|
|
||||
db map[int]rune // double byte runes
|
|
||||
} |
|
||||
|
|
||||
func collation2charset(col Collation) *charsetMap { |
|
||||
// http://msdn.microsoft.com/en-us/library/ms144250.aspx
|
|
||||
// http://msdn.microsoft.com/en-us/library/ms144250(v=sql.105).aspx
|
|
||||
switch col.SortId { |
|
||||
case 30, 31, 32, 33, 34: |
|
||||
return cp437 |
|
||||
case 40, 41, 42, 44, 49, 55, 56, 57, 58, 59, 60, 61: |
|
||||
return cp850 |
|
||||
case 50, 51, 52, 53, 54, 71, 72, 73, 74, 75: |
|
||||
return cp1252 |
|
||||
case 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96: |
|
||||
return cp1250 |
|
||||
case 104, 105, 106, 107, 108: |
|
||||
return cp1251 |
|
||||
case 112, 113, 114, 121, 124: |
|
||||
return cp1253 |
|
||||
case 128, 129, 130: |
|
||||
return cp1254 |
|
||||
case 136, 137, 138: |
|
||||
return cp1255 |
|
||||
case 144, 145, 146: |
|
||||
return cp1256 |
|
||||
case 152, 153, 154, 155, 156, 157, 158, 159, 160: |
|
||||
return cp1257 |
|
||||
case 183, 184, 185, 186: |
|
||||
return cp1252 |
|
||||
case 192, 193: |
|
||||
return cp932 |
|
||||
case 194, 195: |
|
||||
return cp949 |
|
||||
case 196, 197: |
|
||||
return cp950 |
|
||||
case 198, 199: |
|
||||
return cp936 |
|
||||
case 200: |
|
||||
return cp932 |
|
||||
case 201: |
|
||||
return cp949 |
|
||||
case 202: |
|
||||
return cp950 |
|
||||
case 203: |
|
||||
return cp936 |
|
||||
case 204, 205, 206: |
|
||||
return cp874 |
|
||||
case 210, 211, 212, 213, 214, 215, 216, 217: |
|
||||
return cp1252 |
|
||||
} |
|
||||
// http://technet.microsoft.com/en-us/library/aa176553(v=sql.80).aspx
|
|
||||
switch col.getLcid() { |
|
||||
case 0x001e, 0x041e: |
|
||||
return cp874 |
|
||||
case 0x0411, 0x10411: |
|
||||
return cp932 |
|
||||
case 0x0804, 0x1004, 0x20804: |
|
||||
return cp936 |
|
||||
case 0x0012, 0x0412: |
|
||||
return cp949 |
|
||||
case 0x0404, 0x1404, 0x0c04, 0x7c04, 0x30404: |
|
||||
return cp950 |
|
||||
case 0x041c, 0x041a, 0x0405, 0x040e, 0x104e, 0x0415, 0x0418, 0x041b, 0x0424, 0x1040e: |
|
||||
return cp1250 |
|
||||
case 0x0423, 0x0402, 0x042f, 0x0419, 0x081a, 0x0c1a, 0x0422, 0x043f, 0x0444, 0x082c: |
|
||||
return cp1251 |
|
||||
case 0x0408: |
|
||||
return cp1253 |
|
||||
case 0x041f, 0x042c, 0x0443: |
|
||||
return cp1254 |
|
||||
case 0x040d: |
|
||||
return cp1255 |
|
||||
case 0x0401, 0x0801, 0xc01, 0x1001, 0x1401, 0x1801, 0x1c01, 0x2001, 0x2401, 0x2801, 0x2c01, 0x3001, 0x3401, 0x3801, 0x3c01, 0x4001, 0x0429, 0x0420: |
|
||||
return cp1256 |
|
||||
case 0x0425, 0x0426, 0x0427, 0x0827: |
|
||||
return cp1257 |
|
||||
case 0x042a: |
|
||||
return cp1258 |
|
||||
case 0x0439, 0x045a, 0x0465: |
|
||||
return nil |
|
||||
} |
|
||||
return cp1252 |
|
||||
} |
|
||||
|
|
||||
func CharsetToUTF8(col Collation, s []byte) string { |
|
||||
cm := collation2charset(col) |
|
||||
if cm == nil { |
|
||||
return string(s) |
|
||||
} |
|
||||
buf := make([]rune, 0, len(s)) |
|
||||
for i := 0; i < len(s); i++ { |
|
||||
ch := cm.sb[s[i]] |
|
||||
if ch == -1 { |
|
||||
if i+1 == len(s) { |
|
||||
ch = 0xfffd |
|
||||
} else { |
|
||||
n := int(s[i+1]) + (int(s[i]) << 8) |
|
||||
i++ |
|
||||
var ok bool |
|
||||
ch, ok = cm.db[n] |
|
||||
if !ok { |
|
||||
ch = 0xfffd |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
buf = append(buf, ch) |
|
||||
} |
|
||||
return string(buf) |
|
||||
} |
|
@ -1,20 +0,0 @@ |
|||||
package cp |
|
||||
|
|
||||
// http://msdn.microsoft.com/en-us/library/dd340437.aspx
|
|
||||
|
|
||||
type Collation struct { |
|
||||
LcidAndFlags uint32 |
|
||||
SortId uint8 |
|
||||
} |
|
||||
|
|
||||
func (c Collation) getLcid() uint32 { |
|
||||
return c.LcidAndFlags & 0x000fffff |
|
||||
} |
|
||||
|
|
||||
func (c Collation) getFlags() uint32 { |
|
||||
return (c.LcidAndFlags & 0x0ff00000) >> 20 |
|
||||
} |
|
||||
|
|
||||
func (c Collation) getVersion() uint32 { |
|
||||
return (c.LcidAndFlags & 0xf0000000) >> 28 |
|
||||
} |
|
@ -1,262 +0,0 @@ |
|||||
package cp |
|
||||
|
|
||||
var cp1250 *charsetMap = &charsetMap{ |
|
||||
sb: [256]rune{ |
|
||||
0x0000, //NULL
|
|
||||
0x0001, //START OF HEADING
|
|
||||
0x0002, //START OF TEXT
|
|
||||
0x0003, //END OF TEXT
|
|
||||
0x0004, //END OF TRANSMISSION
|
|
||||
0x0005, //ENQUIRY
|
|
||||
0x0006, //ACKNOWLEDGE
|
|
||||
0x0007, //BELL
|
|
||||
0x0008, //BACKSPACE
|
|
||||
0x0009, //HORIZONTAL TABULATION
|
|
||||
0x000A, //LINE FEED
|
|
||||
0x000B, //VERTICAL TABULATION
|
|
||||
0x000C, //FORM FEED
|
|
||||
0x000D, //CARRIAGE RETURN
|
|
||||
0x000E, //SHIFT OUT
|
|
||||
0x000F, //SHIFT IN
|
|
||||
0x0010, //DATA LINK ESCAPE
|
|
||||
0x0011, //DEVICE CONTROL ONE
|
|
||||
0x0012, //DEVICE CONTROL TWO
|
|
||||
0x0013, //DEVICE CONTROL THREE
|
|
||||
0x0014, //DEVICE CONTROL FOUR
|
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
|
||||
0x0016, //SYNCHRONOUS IDLE
|
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
|
||||
0x0018, //CANCEL
|
|
||||
0x0019, //END OF MEDIUM
|
|
||||
0x001A, //SUBSTITUTE
|
|
||||
0x001B, //ESCAPE
|
|
||||
0x001C, //FILE SEPARATOR
|
|
||||
0x001D, //GROUP SEPARATOR
|
|
||||
0x001E, //RECORD SEPARATOR
|
|
||||
0x001F, //UNIT SEPARATOR
|
|
||||
0x0020, //SPACE
|
|
||||
0x0021, //EXCLAMATION MARK
|
|
||||
0x0022, //QUOTATION MARK
|
|
||||
0x0023, //NUMBER SIGN
|
|
||||
0x0024, //DOLLAR SIGN
|
|
||||
0x0025, //PERCENT SIGN
|
|
||||
0x0026, //AMPERSAND
|
|
||||
0x0027, //APOSTROPHE
|
|
||||
0x0028, //LEFT PARENTHESIS
|
|
||||
0x0029, //RIGHT PARENTHESIS
|
|
||||
0x002A, //ASTERISK
|
|
||||
0x002B, //PLUS SIGN
|
|
||||
0x002C, //COMMA
|
|
||||
0x002D, //HYPHEN-MINUS
|
|
||||
0x002E, //FULL STOP
|
|
||||
0x002F, //SOLIDUS
|
|
||||
0x0030, //DIGIT ZERO
|
|
||||
0x0031, //DIGIT ONE
|
|
||||
0x0032, //DIGIT TWO
|
|
||||
0x0033, //DIGIT THREE
|
|
||||
0x0034, //DIGIT FOUR
|
|
||||
0x0035, //DIGIT FIVE
|
|
||||
0x0036, //DIGIT SIX
|
|
||||
0x0037, //DIGIT SEVEN
|
|
||||
0x0038, //DIGIT EIGHT
|
|
||||
0x0039, //DIGIT NINE
|
|
||||
0x003A, //COLON
|
|
||||
0x003B, //SEMICOLON
|
|
||||
0x003C, //LESS-THAN SIGN
|
|
||||
0x003D, //EQUALS SIGN
|
|
||||
0x003E, //GREATER-THAN SIGN
|
|
||||
0x003F, //QUESTION MARK
|
|
||||
0x0040, //COMMERCIAL AT
|
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
|
||||
0x004A, //LATIN CAPITAL LETTER J
|
|
||||
0x004B, //LATIN CAPITAL LETTER K
|
|
||||
0x004C, //LATIN CAPITAL LETTER L
|
|
||||
0x004D, //LATIN CAPITAL LETTER M
|
|
||||
0x004E, //LATIN CAPITAL LETTER N
|
|
||||
0x004F, //LATIN CAPITAL LETTER O
|
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
|
||||
0x005A, //LATIN CAPITAL LETTER Z
|
|
||||
0x005B, //LEFT SQUARE BRACKET
|
|
||||
0x005C, //REVERSE SOLIDUS
|
|
||||
0x005D, //RIGHT SQUARE BRACKET
|
|
||||
0x005E, //CIRCUMFLEX ACCENT
|
|
||||
0x005F, //LOW LINE
|
|
||||
0x0060, //GRAVE ACCENT
|
|
||||
0x0061, //LATIN SMALL LETTER A
|
|
||||
0x0062, //LATIN SMALL LETTER B
|
|
||||
0x0063, //LATIN SMALL LETTER C
|
|
||||
0x0064, //LATIN SMALL LETTER D
|
|
||||
0x0065, //LATIN SMALL LETTER E
|
|
||||
0x0066, //LATIN SMALL LETTER F
|
|
||||
0x0067, //LATIN SMALL LETTER G
|
|
||||
0x0068, //LATIN SMALL LETTER H
|
|
||||
0x0069, //LATIN SMALL LETTER I
|
|
||||
0x006A, //LATIN SMALL LETTER J
|
|
||||
0x006B, //LATIN SMALL LETTER K
|
|
||||
0x006C, //LATIN SMALL LETTER L
|
|
||||
0x006D, //LATIN SMALL LETTER M
|
|
||||
0x006E, //LATIN SMALL LETTER N
|
|
||||
0x006F, //LATIN SMALL LETTER O
|
|
||||
0x0070, //LATIN SMALL LETTER P
|
|
||||
0x0071, //LATIN SMALL LETTER Q
|
|
||||
0x0072, //LATIN SMALL LETTER R
|
|
||||
0x0073, //LATIN SMALL LETTER S
|
|
||||
0x0074, //LATIN SMALL LETTER T
|
|
||||
0x0075, //LATIN SMALL LETTER U
|
|
||||
0x0076, //LATIN SMALL LETTER V
|
|
||||
0x0077, //LATIN SMALL LETTER W
|
|
||||
0x0078, //LATIN SMALL LETTER X
|
|
||||
0x0079, //LATIN SMALL LETTER Y
|
|
||||
0x007A, //LATIN SMALL LETTER Z
|
|
||||
0x007B, //LEFT CURLY BRACKET
|
|
||||
0x007C, //VERTICAL LINE
|
|
||||
0x007D, //RIGHT CURLY BRACKET
|
|
||||
0x007E, //TILDE
|
|
||||
0x007F, //DELETE
|
|
||||
0x20AC, //EURO SIGN
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x201A, //SINGLE LOW-9 QUOTATION MARK
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x201E, //DOUBLE LOW-9 QUOTATION MARK
|
|
||||
0x2026, //HORIZONTAL ELLIPSIS
|
|
||||
0x2020, //DAGGER
|
|
||||
0x2021, //DOUBLE DAGGER
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x2030, //PER MILLE SIGN
|
|
||||
0x0160, //LATIN CAPITAL LETTER S WITH CARON
|
|
||||
0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
|
||||
0x015A, //LATIN CAPITAL LETTER S WITH ACUTE
|
|
||||
0x0164, //LATIN CAPITAL LETTER T WITH CARON
|
|
||||
0x017D, //LATIN CAPITAL LETTER Z WITH CARON
|
|
||||
0x0179, //LATIN CAPITAL LETTER Z WITH ACUTE
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x2018, //LEFT SINGLE QUOTATION MARK
|
|
||||
0x2019, //RIGHT SINGLE QUOTATION MARK
|
|
||||
0x201C, //LEFT DOUBLE QUOTATION MARK
|
|
||||
0x201D, //RIGHT DOUBLE QUOTATION MARK
|
|
||||
0x2022, //BULLET
|
|
||||
0x2013, //EN DASH
|
|
||||
0x2014, //EM DASH
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x2122, //TRADE MARK SIGN
|
|
||||
0x0161, //LATIN SMALL LETTER S WITH CARON
|
|
||||
0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
|
||||
0x015B, //LATIN SMALL LETTER S WITH ACUTE
|
|
||||
0x0165, //LATIN SMALL LETTER T WITH CARON
|
|
||||
0x017E, //LATIN SMALL LETTER Z WITH CARON
|
|
||||
0x017A, //LATIN SMALL LETTER Z WITH ACUTE
|
|
||||
0x00A0, //NO-BREAK SPACE
|
|
||||
0x02C7, //CARON
|
|
||||
0x02D8, //BREVE
|
|
||||
0x0141, //LATIN CAPITAL LETTER L WITH STROKE
|
|
||||
0x00A4, //CURRENCY SIGN
|
|
||||
0x0104, //LATIN CAPITAL LETTER A WITH OGONEK
|
|
||||
0x00A6, //BROKEN BAR
|
|
||||
0x00A7, //SECTION SIGN
|
|
||||
0x00A8, //DIAERESIS
|
|
||||
0x00A9, //COPYRIGHT SIGN
|
|
||||
0x015E, //LATIN CAPITAL LETTER S WITH CEDILLA
|
|
||||
0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x00AC, //NOT SIGN
|
|
||||
0x00AD, //SOFT HYPHEN
|
|
||||
0x00AE, //REGISTERED SIGN
|
|
||||
0x017B, //LATIN CAPITAL LETTER Z WITH DOT ABOVE
|
|
||||
0x00B0, //DEGREE SIGN
|
|
||||
0x00B1, //PLUS-MINUS SIGN
|
|
||||
0x02DB, //OGONEK
|
|
||||
0x0142, //LATIN SMALL LETTER L WITH STROKE
|
|
||||
0x00B4, //ACUTE ACCENT
|
|
||||
0x00B5, //MICRO SIGN
|
|
||||
0x00B6, //PILCROW SIGN
|
|
||||
0x00B7, //MIDDLE DOT
|
|
||||
0x00B8, //CEDILLA
|
|
||||
0x0105, //LATIN SMALL LETTER A WITH OGONEK
|
|
||||
0x015F, //LATIN SMALL LETTER S WITH CEDILLA
|
|
||||
0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x013D, //LATIN CAPITAL LETTER L WITH CARON
|
|
||||
0x02DD, //DOUBLE ACUTE ACCENT
|
|
||||
0x013E, //LATIN SMALL LETTER L WITH CARON
|
|
||||
0x017C, //LATIN SMALL LETTER Z WITH DOT ABOVE
|
|
||||
0x0154, //LATIN CAPITAL LETTER R WITH ACUTE
|
|
||||
0x00C1, //LATIN CAPITAL LETTER A WITH ACUTE
|
|
||||
0x00C2, //LATIN CAPITAL LETTER A WITH CIRCUMFLEX
|
|
||||
0x0102, //LATIN CAPITAL LETTER A WITH BREVE
|
|
||||
0x00C4, //LATIN CAPITAL LETTER A WITH DIAERESIS
|
|
||||
0x0139, //LATIN CAPITAL LETTER L WITH ACUTE
|
|
||||
0x0106, //LATIN CAPITAL LETTER C WITH ACUTE
|
|
||||
0x00C7, //LATIN CAPITAL LETTER C WITH CEDILLA
|
|
||||
0x010C, //LATIN CAPITAL LETTER C WITH CARON
|
|
||||
0x00C9, //LATIN CAPITAL LETTER E WITH ACUTE
|
|
||||
0x0118, //LATIN CAPITAL LETTER E WITH OGONEK
|
|
||||
0x00CB, //LATIN CAPITAL LETTER E WITH DIAERESIS
|
|
||||
0x011A, //LATIN CAPITAL LETTER E WITH CARON
|
|
||||
0x00CD, //LATIN CAPITAL LETTER I WITH ACUTE
|
|
||||
0x00CE, //LATIN CAPITAL LETTER I WITH CIRCUMFLEX
|
|
||||
0x010E, //LATIN CAPITAL LETTER D WITH CARON
|
|
||||
0x0110, //LATIN CAPITAL LETTER D WITH STROKE
|
|
||||
0x0143, //LATIN CAPITAL LETTER N WITH ACUTE
|
|
||||
0x0147, //LATIN CAPITAL LETTER N WITH CARON
|
|
||||
0x00D3, //LATIN CAPITAL LETTER O WITH ACUTE
|
|
||||
0x00D4, //LATIN CAPITAL LETTER O WITH CIRCUMFLEX
|
|
||||
0x0150, //LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
|
|
||||
0x00D6, //LATIN CAPITAL LETTER O WITH DIAERESIS
|
|
||||
0x00D7, //MULTIPLICATION SIGN
|
|
||||
0x0158, //LATIN CAPITAL LETTER R WITH CARON
|
|
||||
0x016E, //LATIN CAPITAL LETTER U WITH RING ABOVE
|
|
||||
0x00DA, //LATIN CAPITAL LETTER U WITH ACUTE
|
|
||||
0x0170, //LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
|
|
||||
0x00DC, //LATIN CAPITAL LETTER U WITH DIAERESIS
|
|
||||
0x00DD, //LATIN CAPITAL LETTER Y WITH ACUTE
|
|
||||
0x0162, //LATIN CAPITAL LETTER T WITH CEDILLA
|
|
||||
0x00DF, //LATIN SMALL LETTER SHARP S
|
|
||||
0x0155, //LATIN SMALL LETTER R WITH ACUTE
|
|
||||
0x00E1, //LATIN SMALL LETTER A WITH ACUTE
|
|
||||
0x00E2, //LATIN SMALL LETTER A WITH CIRCUMFLEX
|
|
||||
0x0103, //LATIN SMALL LETTER A WITH BREVE
|
|
||||
0x00E4, //LATIN SMALL LETTER A WITH DIAERESIS
|
|
||||
0x013A, //LATIN SMALL LETTER L WITH ACUTE
|
|
||||
0x0107, //LATIN SMALL LETTER C WITH ACUTE
|
|
||||
0x00E7, //LATIN SMALL LETTER C WITH CEDILLA
|
|
||||
0x010D, //LATIN SMALL LETTER C WITH CARON
|
|
||||
0x00E9, //LATIN SMALL LETTER E WITH ACUTE
|
|
||||
0x0119, //LATIN SMALL LETTER E WITH OGONEK
|
|
||||
0x00EB, //LATIN SMALL LETTER E WITH DIAERESIS
|
|
||||
0x011B, //LATIN SMALL LETTER E WITH CARON
|
|
||||
0x00ED, //LATIN SMALL LETTER I WITH ACUTE
|
|
||||
0x00EE, //LATIN SMALL LETTER I WITH CIRCUMFLEX
|
|
||||
0x010F, //LATIN SMALL LETTER D WITH CARON
|
|
||||
0x0111, //LATIN SMALL LETTER D WITH STROKE
|
|
||||
0x0144, //LATIN SMALL LETTER N WITH ACUTE
|
|
||||
0x0148, //LATIN SMALL LETTER N WITH CARON
|
|
||||
0x00F3, //LATIN SMALL LETTER O WITH ACUTE
|
|
||||
0x00F4, //LATIN SMALL LETTER O WITH CIRCUMFLEX
|
|
||||
0x0151, //LATIN SMALL LETTER O WITH DOUBLE ACUTE
|
|
||||
0x00F6, //LATIN SMALL LETTER O WITH DIAERESIS
|
|
||||
0x00F7, //DIVISION SIGN
|
|
||||
0x0159, //LATIN SMALL LETTER R WITH CARON
|
|
||||
0x016F, //LATIN SMALL LETTER U WITH RING ABOVE
|
|
||||
0x00FA, //LATIN SMALL LETTER U WITH ACUTE
|
|
||||
0x0171, //LATIN SMALL LETTER U WITH DOUBLE ACUTE
|
|
||||
0x00FC, //LATIN SMALL LETTER U WITH DIAERESIS
|
|
||||
0x00FD, //LATIN SMALL LETTER Y WITH ACUTE
|
|
||||
0x0163, //LATIN SMALL LETTER T WITH CEDILLA
|
|
||||
0x02D9, //DOT ABOVE
|
|
||||
}, |
|
||||
} |
|
@ -1,262 +0,0 @@ |
|||||
package cp |
|
||||
|
|
||||
var cp1251 *charsetMap = &charsetMap{ |
|
||||
sb: [256]rune{ |
|
||||
0x0000, //NULL
|
|
||||
0x0001, //START OF HEADING
|
|
||||
0x0002, //START OF TEXT
|
|
||||
0x0003, //END OF TEXT
|
|
||||
0x0004, //END OF TRANSMISSION
|
|
||||
0x0005, //ENQUIRY
|
|
||||
0x0006, //ACKNOWLEDGE
|
|
||||
0x0007, //BELL
|
|
||||
0x0008, //BACKSPACE
|
|
||||
0x0009, //HORIZONTAL TABULATION
|
|
||||
0x000A, //LINE FEED
|
|
||||
0x000B, //VERTICAL TABULATION
|
|
||||
0x000C, //FORM FEED
|
|
||||
0x000D, //CARRIAGE RETURN
|
|
||||
0x000E, //SHIFT OUT
|
|
||||
0x000F, //SHIFT IN
|
|
||||
0x0010, //DATA LINK ESCAPE
|
|
||||
0x0011, //DEVICE CONTROL ONE
|
|
||||
0x0012, //DEVICE CONTROL TWO
|
|
||||
0x0013, //DEVICE CONTROL THREE
|
|
||||
0x0014, //DEVICE CONTROL FOUR
|
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
|
||||
0x0016, //SYNCHRONOUS IDLE
|
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
|
||||
0x0018, //CANCEL
|
|
||||
0x0019, //END OF MEDIUM
|
|
||||
0x001A, //SUBSTITUTE
|
|
||||
0x001B, //ESCAPE
|
|
||||
0x001C, //FILE SEPARATOR
|
|
||||
0x001D, //GROUP SEPARATOR
|
|
||||
0x001E, //RECORD SEPARATOR
|
|
||||
0x001F, //UNIT SEPARATOR
|
|
||||
0x0020, //SPACE
|
|
||||
0x0021, //EXCLAMATION MARK
|
|
||||
0x0022, //QUOTATION MARK
|
|
||||
0x0023, //NUMBER SIGN
|
|
||||
0x0024, //DOLLAR SIGN
|
|
||||
0x0025, //PERCENT SIGN
|
|
||||
0x0026, //AMPERSAND
|
|
||||
0x0027, //APOSTROPHE
|
|
||||
0x0028, //LEFT PARENTHESIS
|
|
||||
0x0029, //RIGHT PARENTHESIS
|
|
||||
0x002A, //ASTERISK
|
|
||||
0x002B, //PLUS SIGN
|
|
||||
0x002C, //COMMA
|
|
||||
0x002D, //HYPHEN-MINUS
|
|
||||
0x002E, //FULL STOP
|
|
||||
0x002F, //SOLIDUS
|
|
||||
0x0030, //DIGIT ZERO
|
|
||||
0x0031, //DIGIT ONE
|
|
||||
0x0032, //DIGIT TWO
|
|
||||
0x0033, //DIGIT THREE
|
|
||||
0x0034, //DIGIT FOUR
|
|
||||
0x0035, //DIGIT FIVE
|
|
||||
0x0036, //DIGIT SIX
|
|
||||
0x0037, //DIGIT SEVEN
|
|
||||
0x0038, //DIGIT EIGHT
|
|
||||
0x0039, //DIGIT NINE
|
|
||||
0x003A, //COLON
|
|
||||
0x003B, //SEMICOLON
|
|
||||
0x003C, //LESS-THAN SIGN
|
|
||||
0x003D, //EQUALS SIGN
|
|
||||
0x003E, //GREATER-THAN SIGN
|
|
||||
0x003F, //QUESTION MARK
|
|
||||
0x0040, //COMMERCIAL AT
|
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
|
||||
0x004A, //LATIN CAPITAL LETTER J
|
|
||||
0x004B, //LATIN CAPITAL LETTER K
|
|
||||
0x004C, //LATIN CAPITAL LETTER L
|
|
||||
0x004D, //LATIN CAPITAL LETTER M
|
|
||||
0x004E, //LATIN CAPITAL LETTER N
|
|
||||
0x004F, //LATIN CAPITAL LETTER O
|
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
|
||||
0x005A, //LATIN CAPITAL LETTER Z
|
|
||||
0x005B, //LEFT SQUARE BRACKET
|
|
||||
0x005C, //REVERSE SOLIDUS
|
|
||||
0x005D, //RIGHT SQUARE BRACKET
|
|
||||
0x005E, //CIRCUMFLEX ACCENT
|
|
||||
0x005F, //LOW LINE
|
|
||||
0x0060, //GRAVE ACCENT
|
|
||||
0x0061, //LATIN SMALL LETTER A
|
|
||||
0x0062, //LATIN SMALL LETTER B
|
|
||||
0x0063, //LATIN SMALL LETTER C
|
|
||||
0x0064, //LATIN SMALL LETTER D
|
|
||||
0x0065, //LATIN SMALL LETTER E
|
|
||||
0x0066, //LATIN SMALL LETTER F
|
|
||||
0x0067, //LATIN SMALL LETTER G
|
|
||||
0x0068, //LATIN SMALL LETTER H
|
|
||||
0x0069, //LATIN SMALL LETTER I
|
|
||||
0x006A, //LATIN SMALL LETTER J
|
|
||||
0x006B, //LATIN SMALL LETTER K
|
|
||||
0x006C, //LATIN SMALL LETTER L
|
|
||||
0x006D, //LATIN SMALL LETTER M
|
|
||||
0x006E, //LATIN SMALL LETTER N
|
|
||||
0x006F, //LATIN SMALL LETTER O
|
|
||||
0x0070, //LATIN SMALL LETTER P
|
|
||||
0x0071, //LATIN SMALL LETTER Q
|
|
||||
0x0072, //LATIN SMALL LETTER R
|
|
||||
0x0073, //LATIN SMALL LETTER S
|
|
||||
0x0074, //LATIN SMALL LETTER T
|
|
||||
0x0075, //LATIN SMALL LETTER U
|
|
||||
0x0076, //LATIN SMALL LETTER V
|
|
||||
0x0077, //LATIN SMALL LETTER W
|
|
||||
0x0078, //LATIN SMALL LETTER X
|
|
||||
0x0079, //LATIN SMALL LETTER Y
|
|
||||
0x007A, //LATIN SMALL LETTER Z
|
|
||||
0x007B, //LEFT CURLY BRACKET
|
|
||||
0x007C, //VERTICAL LINE
|
|
||||
0x007D, //RIGHT CURLY BRACKET
|
|
||||
0x007E, //TILDE
|
|
||||
0x007F, //DELETE
|
|
||||
0x0402, //CYRILLIC CAPITAL LETTER DJE
|
|
||||
0x0403, //CYRILLIC CAPITAL LETTER GJE
|
|
||||
0x201A, //SINGLE LOW-9 QUOTATION MARK
|
|
||||
0x0453, //CYRILLIC SMALL LETTER GJE
|
|
||||
0x201E, //DOUBLE LOW-9 QUOTATION MARK
|
|
||||
0x2026, //HORIZONTAL ELLIPSIS
|
|
||||
0x2020, //DAGGER
|
|
||||
0x2021, //DOUBLE DAGGER
|
|
||||
0x20AC, //EURO SIGN
|
|
||||
0x2030, //PER MILLE SIGN
|
|
||||
0x0409, //CYRILLIC CAPITAL LETTER LJE
|
|
||||
0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
|
||||
0x040A, //CYRILLIC CAPITAL LETTER NJE
|
|
||||
0x040C, //CYRILLIC CAPITAL LETTER KJE
|
|
||||
0x040B, //CYRILLIC CAPITAL LETTER TSHE
|
|
||||
0x040F, //CYRILLIC CAPITAL LETTER DZHE
|
|
||||
0x0452, //CYRILLIC SMALL LETTER DJE
|
|
||||
0x2018, //LEFT SINGLE QUOTATION MARK
|
|
||||
0x2019, //RIGHT SINGLE QUOTATION MARK
|
|
||||
0x201C, //LEFT DOUBLE QUOTATION MARK
|
|
||||
0x201D, //RIGHT DOUBLE QUOTATION MARK
|
|
||||
0x2022, //BULLET
|
|
||||
0x2013, //EN DASH
|
|
||||
0x2014, //EM DASH
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x2122, //TRADE MARK SIGN
|
|
||||
0x0459, //CYRILLIC SMALL LETTER LJE
|
|
||||
0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
|
||||
0x045A, //CYRILLIC SMALL LETTER NJE
|
|
||||
0x045C, //CYRILLIC SMALL LETTER KJE
|
|
||||
0x045B, //CYRILLIC SMALL LETTER TSHE
|
|
||||
0x045F, //CYRILLIC SMALL LETTER DZHE
|
|
||||
0x00A0, //NO-BREAK SPACE
|
|
||||
0x040E, //CYRILLIC CAPITAL LETTER SHORT U
|
|
||||
0x045E, //CYRILLIC SMALL LETTER SHORT U
|
|
||||
0x0408, //CYRILLIC CAPITAL LETTER JE
|
|
||||
0x00A4, //CURRENCY SIGN
|
|
||||
0x0490, //CYRILLIC CAPITAL LETTER GHE WITH UPTURN
|
|
||||
0x00A6, //BROKEN BAR
|
|
||||
0x00A7, //SECTION SIGN
|
|
||||
0x0401, //CYRILLIC CAPITAL LETTER IO
|
|
||||
0x00A9, //COPYRIGHT SIGN
|
|
||||
0x0404, //CYRILLIC CAPITAL LETTER UKRAINIAN IE
|
|
||||
0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x00AC, //NOT SIGN
|
|
||||
0x00AD, //SOFT HYPHEN
|
|
||||
0x00AE, //REGISTERED SIGN
|
|
||||
0x0407, //CYRILLIC CAPITAL LETTER YI
|
|
||||
0x00B0, //DEGREE SIGN
|
|
||||
0x00B1, //PLUS-MINUS SIGN
|
|
||||
0x0406, //CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
|
|
||||
0x0456, //CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
|
|
||||
0x0491, //CYRILLIC SMALL LETTER GHE WITH UPTURN
|
|
||||
0x00B5, //MICRO SIGN
|
|
||||
0x00B6, //PILCROW SIGN
|
|
||||
0x00B7, //MIDDLE DOT
|
|
||||
0x0451, //CYRILLIC SMALL LETTER IO
|
|
||||
0x2116, //NUMERO SIGN
|
|
||||
0x0454, //CYRILLIC SMALL LETTER UKRAINIAN IE
|
|
||||
0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x0458, //CYRILLIC SMALL LETTER JE
|
|
||||
0x0405, //CYRILLIC CAPITAL LETTER DZE
|
|
||||
0x0455, //CYRILLIC SMALL LETTER DZE
|
|
||||
0x0457, //CYRILLIC SMALL LETTER YI
|
|
||||
0x0410, //CYRILLIC CAPITAL LETTER A
|
|
||||
0x0411, //CYRILLIC CAPITAL LETTER BE
|
|
||||
0x0412, //CYRILLIC CAPITAL LETTER VE
|
|
||||
0x0413, //CYRILLIC CAPITAL LETTER GHE
|
|
||||
0x0414, //CYRILLIC CAPITAL LETTER DE
|
|
||||
0x0415, //CYRILLIC CAPITAL LETTER IE
|
|
||||
0x0416, //CYRILLIC CAPITAL LETTER ZHE
|
|
||||
0x0417, //CYRILLIC CAPITAL LETTER ZE
|
|
||||
0x0418, //CYRILLIC CAPITAL LETTER I
|
|
||||
0x0419, //CYRILLIC CAPITAL LETTER SHORT I
|
|
||||
0x041A, //CYRILLIC CAPITAL LETTER KA
|
|
||||
0x041B, //CYRILLIC CAPITAL LETTER EL
|
|
||||
0x041C, //CYRILLIC CAPITAL LETTER EM
|
|
||||
0x041D, //CYRILLIC CAPITAL LETTER EN
|
|
||||
0x041E, //CYRILLIC CAPITAL LETTER O
|
|
||||
0x041F, //CYRILLIC CAPITAL LETTER PE
|
|
||||
0x0420, //CYRILLIC CAPITAL LETTER ER
|
|
||||
0x0421, //CYRILLIC CAPITAL LETTER ES
|
|
||||
0x0422, //CYRILLIC CAPITAL LETTER TE
|
|
||||
0x0423, //CYRILLIC CAPITAL LETTER U
|
|
||||
0x0424, //CYRILLIC CAPITAL LETTER EF
|
|
||||
0x0425, //CYRILLIC CAPITAL LETTER HA
|
|
||||
0x0426, //CYRILLIC CAPITAL LETTER TSE
|
|
||||
0x0427, //CYRILLIC CAPITAL LETTER CHE
|
|
||||
0x0428, //CYRILLIC CAPITAL LETTER SHA
|
|
||||
0x0429, //CYRILLIC CAPITAL LETTER SHCHA
|
|
||||
0x042A, //CYRILLIC CAPITAL LETTER HARD SIGN
|
|
||||
0x042B, //CYRILLIC CAPITAL LETTER YERU
|
|
||||
0x042C, //CYRILLIC CAPITAL LETTER SOFT SIGN
|
|
||||
0x042D, //CYRILLIC CAPITAL LETTER E
|
|
||||
0x042E, //CYRILLIC CAPITAL LETTER YU
|
|
||||
0x042F, //CYRILLIC CAPITAL LETTER YA
|
|
||||
0x0430, //CYRILLIC SMALL LETTER A
|
|
||||
0x0431, //CYRILLIC SMALL LETTER BE
|
|
||||
0x0432, //CYRILLIC SMALL LETTER VE
|
|
||||
0x0433, //CYRILLIC SMALL LETTER GHE
|
|
||||
0x0434, //CYRILLIC SMALL LETTER DE
|
|
||||
0x0435, //CYRILLIC SMALL LETTER IE
|
|
||||
0x0436, //CYRILLIC SMALL LETTER ZHE
|
|
||||
0x0437, //CYRILLIC SMALL LETTER ZE
|
|
||||
0x0438, //CYRILLIC SMALL LETTER I
|
|
||||
0x0439, //CYRILLIC SMALL LETTER SHORT I
|
|
||||
0x043A, //CYRILLIC SMALL LETTER KA
|
|
||||
0x043B, //CYRILLIC SMALL LETTER EL
|
|
||||
0x043C, //CYRILLIC SMALL LETTER EM
|
|
||||
0x043D, //CYRILLIC SMALL LETTER EN
|
|
||||
0x043E, //CYRILLIC SMALL LETTER O
|
|
||||
0x043F, //CYRILLIC SMALL LETTER PE
|
|
||||
0x0440, //CYRILLIC SMALL LETTER ER
|
|
||||
0x0441, //CYRILLIC SMALL LETTER ES
|
|
||||
0x0442, //CYRILLIC SMALL LETTER TE
|
|
||||
0x0443, //CYRILLIC SMALL LETTER U
|
|
||||
0x0444, //CYRILLIC SMALL LETTER EF
|
|
||||
0x0445, //CYRILLIC SMALL LETTER HA
|
|
||||
0x0446, //CYRILLIC SMALL LETTER TSE
|
|
||||
0x0447, //CYRILLIC SMALL LETTER CHE
|
|
||||
0x0448, //CYRILLIC SMALL LETTER SHA
|
|
||||
0x0449, //CYRILLIC SMALL LETTER SHCHA
|
|
||||
0x044A, //CYRILLIC SMALL LETTER HARD SIGN
|
|
||||
0x044B, //CYRILLIC SMALL LETTER YERU
|
|
||||
0x044C, //CYRILLIC SMALL LETTER SOFT SIGN
|
|
||||
0x044D, //CYRILLIC SMALL LETTER E
|
|
||||
0x044E, //CYRILLIC SMALL LETTER YU
|
|
||||
0x044F, //CYRILLIC SMALL LETTER YA
|
|
||||
}, |
|
||||
} |
|
@ -1,262 +0,0 @@ |
|||||
package cp |
|
||||
|
|
||||
var cp1252 *charsetMap = &charsetMap{ |
|
||||
sb: [256]rune{ |
|
||||
0x0000, //NULL
|
|
||||
0x0001, //START OF HEADING
|
|
||||
0x0002, //START OF TEXT
|
|
||||
0x0003, //END OF TEXT
|
|
||||
0x0004, //END OF TRANSMISSION
|
|
||||
0x0005, //ENQUIRY
|
|
||||
0x0006, //ACKNOWLEDGE
|
|
||||
0x0007, //BELL
|
|
||||
0x0008, //BACKSPACE
|
|
||||
0x0009, //HORIZONTAL TABULATION
|
|
||||
0x000A, //LINE FEED
|
|
||||
0x000B, //VERTICAL TABULATION
|
|
||||
0x000C, //FORM FEED
|
|
||||
0x000D, //CARRIAGE RETURN
|
|
||||
0x000E, //SHIFT OUT
|
|
||||
0x000F, //SHIFT IN
|
|
||||
0x0010, //DATA LINK ESCAPE
|
|
||||
0x0011, //DEVICE CONTROL ONE
|
|
||||
0x0012, //DEVICE CONTROL TWO
|
|
||||
0x0013, //DEVICE CONTROL THREE
|
|
||||
0x0014, //DEVICE CONTROL FOUR
|
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
|
||||
0x0016, //SYNCHRONOUS IDLE
|
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
|
||||
0x0018, //CANCEL
|
|
||||
0x0019, //END OF MEDIUM
|
|
||||
0x001A, //SUBSTITUTE
|
|
||||
0x001B, //ESCAPE
|
|
||||
0x001C, //FILE SEPARATOR
|
|
||||
0x001D, //GROUP SEPARATOR
|
|
||||
0x001E, //RECORD SEPARATOR
|
|
||||
0x001F, //UNIT SEPARATOR
|
|
||||
0x0020, //SPACE
|
|
||||
0x0021, //EXCLAMATION MARK
|
|
||||
0x0022, //QUOTATION MARK
|
|
||||
0x0023, //NUMBER SIGN
|
|
||||
0x0024, //DOLLAR SIGN
|
|
||||
0x0025, //PERCENT SIGN
|
|
||||
0x0026, //AMPERSAND
|
|
||||
0x0027, //APOSTROPHE
|
|
||||
0x0028, //LEFT PARENTHESIS
|
|
||||
0x0029, //RIGHT PARENTHESIS
|
|
||||
0x002A, //ASTERISK
|
|
||||
0x002B, //PLUS SIGN
|
|
||||
0x002C, //COMMA
|
|
||||
0x002D, //HYPHEN-MINUS
|
|
||||
0x002E, //FULL STOP
|
|
||||
0x002F, //SOLIDUS
|
|
||||
0x0030, //DIGIT ZERO
|
|
||||
0x0031, //DIGIT ONE
|
|
||||
0x0032, //DIGIT TWO
|
|
||||
0x0033, //DIGIT THREE
|
|
||||
0x0034, //DIGIT FOUR
|
|
||||
0x0035, //DIGIT FIVE
|
|
||||
0x0036, //DIGIT SIX
|
|
||||
0x0037, //DIGIT SEVEN
|
|
||||
0x0038, //DIGIT EIGHT
|
|
||||
0x0039, //DIGIT NINE
|
|
||||
0x003A, //COLON
|
|
||||
0x003B, //SEMICOLON
|
|
||||
0x003C, //LESS-THAN SIGN
|
|
||||
0x003D, //EQUALS SIGN
|
|
||||
0x003E, //GREATER-THAN SIGN
|
|
||||
0x003F, //QUESTION MARK
|
|
||||
0x0040, //COMMERCIAL AT
|
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
|
||||
0x004A, //LATIN CAPITAL LETTER J
|
|
||||
0x004B, //LATIN CAPITAL LETTER K
|
|
||||
0x004C, //LATIN CAPITAL LETTER L
|
|
||||
0x004D, //LATIN CAPITAL LETTER M
|
|
||||
0x004E, //LATIN CAPITAL LETTER N
|
|
||||
0x004F, //LATIN CAPITAL LETTER O
|
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
|
||||
0x005A, //LATIN CAPITAL LETTER Z
|
|
||||
0x005B, //LEFT SQUARE BRACKET
|
|
||||
0x005C, //REVERSE SOLIDUS
|
|
||||
0x005D, //RIGHT SQUARE BRACKET
|
|
||||
0x005E, //CIRCUMFLEX ACCENT
|
|
||||
0x005F, //LOW LINE
|
|
||||
0x0060, //GRAVE ACCENT
|
|
||||
0x0061, //LATIN SMALL LETTER A
|
|
||||
0x0062, //LATIN SMALL LETTER B
|
|
||||
0x0063, //LATIN SMALL LETTER C
|
|
||||
0x0064, //LATIN SMALL LETTER D
|
|
||||
0x0065, //LATIN SMALL LETTER E
|
|
||||
0x0066, //LATIN SMALL LETTER F
|
|
||||
0x0067, //LATIN SMALL LETTER G
|
|
||||
0x0068, //LATIN SMALL LETTER H
|
|
||||
0x0069, //LATIN SMALL LETTER I
|
|
||||
0x006A, //LATIN SMALL LETTER J
|
|
||||
0x006B, //LATIN SMALL LETTER K
|
|
||||
0x006C, //LATIN SMALL LETTER L
|
|
||||
0x006D, //LATIN SMALL LETTER M
|
|
||||
0x006E, //LATIN SMALL LETTER N
|
|
||||
0x006F, //LATIN SMALL LETTER O
|
|
||||
0x0070, //LATIN SMALL LETTER P
|
|
||||
0x0071, //LATIN SMALL LETTER Q
|
|
||||
0x0072, //LATIN SMALL LETTER R
|
|
||||
0x0073, //LATIN SMALL LETTER S
|
|
||||
0x0074, //LATIN SMALL LETTER T
|
|
||||
0x0075, //LATIN SMALL LETTER U
|
|
||||
0x0076, //LATIN SMALL LETTER V
|
|
||||
0x0077, //LATIN SMALL LETTER W
|
|
||||
0x0078, //LATIN SMALL LETTER X
|
|
||||
0x0079, //LATIN SMALL LETTER Y
|
|
||||
0x007A, //LATIN SMALL LETTER Z
|
|
||||
0x007B, //LEFT CURLY BRACKET
|
|
||||
0x007C, //VERTICAL LINE
|
|
||||
0x007D, //RIGHT CURLY BRACKET
|
|
||||
0x007E, //TILDE
|
|
||||
0x007F, //DELETE
|
|
||||
0x20AC, //EURO SIGN
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x201A, //SINGLE LOW-9 QUOTATION MARK
|
|
||||
0x0192, //LATIN SMALL LETTER F WITH HOOK
|
|
||||
0x201E, //DOUBLE LOW-9 QUOTATION MARK
|
|
||||
0x2026, //HORIZONTAL ELLIPSIS
|
|
||||
0x2020, //DAGGER
|
|
||||
0x2021, //DOUBLE DAGGER
|
|
||||
0x02C6, //MODIFIER LETTER CIRCUMFLEX ACCENT
|
|
||||
0x2030, //PER MILLE SIGN
|
|
||||
0x0160, //LATIN CAPITAL LETTER S WITH CARON
|
|
||||
0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
|
||||
0x0152, //LATIN CAPITAL LIGATURE OE
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x017D, //LATIN CAPITAL LETTER Z WITH CARON
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x2018, //LEFT SINGLE QUOTATION MARK
|
|
||||
0x2019, //RIGHT SINGLE QUOTATION MARK
|
|
||||
0x201C, //LEFT DOUBLE QUOTATION MARK
|
|
||||
0x201D, //RIGHT DOUBLE QUOTATION MARK
|
|
||||
0x2022, //BULLET
|
|
||||
0x2013, //EN DASH
|
|
||||
0x2014, //EM DASH
|
|
||||
0x02DC, //SMALL TILDE
|
|
||||
0x2122, //TRADE MARK SIGN
|
|
||||
0x0161, //LATIN SMALL LETTER S WITH CARON
|
|
||||
0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
|
||||
0x0153, //LATIN SMALL LIGATURE OE
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x017E, //LATIN SMALL LETTER Z WITH CARON
|
|
||||
0x0178, //LATIN CAPITAL LETTER Y WITH DIAERESIS
|
|
||||
0x00A0, //NO-BREAK SPACE
|
|
||||
0x00A1, //INVERTED EXCLAMATION MARK
|
|
||||
0x00A2, //CENT SIGN
|
|
||||
0x00A3, //POUND SIGN
|
|
||||
0x00A4, //CURRENCY SIGN
|
|
||||
0x00A5, //YEN SIGN
|
|
||||
0x00A6, //BROKEN BAR
|
|
||||
0x00A7, //SECTION SIGN
|
|
||||
0x00A8, //DIAERESIS
|
|
||||
0x00A9, //COPYRIGHT SIGN
|
|
||||
0x00AA, //FEMININE ORDINAL INDICATOR
|
|
||||
0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x00AC, //NOT SIGN
|
|
||||
0x00AD, //SOFT HYPHEN
|
|
||||
0x00AE, //REGISTERED SIGN
|
|
||||
0x00AF, //MACRON
|
|
||||
0x00B0, //DEGREE SIGN
|
|
||||
0x00B1, //PLUS-MINUS SIGN
|
|
||||
0x00B2, //SUPERSCRIPT TWO
|
|
||||
0x00B3, //SUPERSCRIPT THREE
|
|
||||
0x00B4, //ACUTE ACCENT
|
|
||||
0x00B5, //MICRO SIGN
|
|
||||
0x00B6, //PILCROW SIGN
|
|
||||
0x00B7, //MIDDLE DOT
|
|
||||
0x00B8, //CEDILLA
|
|
||||
0x00B9, //SUPERSCRIPT ONE
|
|
||||
0x00BA, //MASCULINE ORDINAL INDICATOR
|
|
||||
0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x00BC, //VULGAR FRACTION ONE QUARTER
|
|
||||
0x00BD, //VULGAR FRACTION ONE HALF
|
|
||||
0x00BE, //VULGAR FRACTION THREE QUARTERS
|
|
||||
0x00BF, //INVERTED QUESTION MARK
|
|
||||
0x00C0, //LATIN CAPITAL LETTER A WITH GRAVE
|
|
||||
0x00C1, //LATIN CAPITAL LETTER A WITH ACUTE
|
|
||||
0x00C2, //LATIN CAPITAL LETTER A WITH CIRCUMFLEX
|
|
||||
0x00C3, //LATIN CAPITAL LETTER A WITH TILDE
|
|
||||
0x00C4, //LATIN CAPITAL LETTER A WITH DIAERESIS
|
|
||||
0x00C5, //LATIN CAPITAL LETTER A WITH RING ABOVE
|
|
||||
0x00C6, //LATIN CAPITAL LETTER AE
|
|
||||
0x00C7, //LATIN CAPITAL LETTER C WITH CEDILLA
|
|
||||
0x00C8, //LATIN CAPITAL LETTER E WITH GRAVE
|
|
||||
0x00C9, //LATIN CAPITAL LETTER E WITH ACUTE
|
|
||||
0x00CA, //LATIN CAPITAL LETTER E WITH CIRCUMFLEX
|
|
||||
0x00CB, //LATIN CAPITAL LETTER E WITH DIAERESIS
|
|
||||
0x00CC, //LATIN CAPITAL LETTER I WITH GRAVE
|
|
||||
0x00CD, //LATIN CAPITAL LETTER I WITH ACUTE
|
|
||||
0x00CE, //LATIN CAPITAL LETTER I WITH CIRCUMFLEX
|
|
||||
0x00CF, //LATIN CAPITAL LETTER I WITH DIAERESIS
|
|
||||
0x00D0, //LATIN CAPITAL LETTER ETH
|
|
||||
0x00D1, //LATIN CAPITAL LETTER N WITH TILDE
|
|
||||
0x00D2, //LATIN CAPITAL LETTER O WITH GRAVE
|
|
||||
0x00D3, //LATIN CAPITAL LETTER O WITH ACUTE
|
|
||||
0x00D4, //LATIN CAPITAL LETTER O WITH CIRCUMFLEX
|
|
||||
0x00D5, //LATIN CAPITAL LETTER O WITH TILDE
|
|
||||
0x00D6, //LATIN CAPITAL LETTER O WITH DIAERESIS
|
|
||||
0x00D7, //MULTIPLICATION SIGN
|
|
||||
0x00D8, //LATIN CAPITAL LETTER O WITH STROKE
|
|
||||
0x00D9, //LATIN CAPITAL LETTER U WITH GRAVE
|
|
||||
0x00DA, //LATIN CAPITAL LETTER U WITH ACUTE
|
|
||||
0x00DB, //LATIN CAPITAL LETTER U WITH CIRCUMFLEX
|
|
||||
0x00DC, //LATIN CAPITAL LETTER U WITH DIAERESIS
|
|
||||
0x00DD, //LATIN CAPITAL LETTER Y WITH ACUTE
|
|
||||
0x00DE, //LATIN CAPITAL LETTER THORN
|
|
||||
0x00DF, //LATIN SMALL LETTER SHARP S
|
|
||||
0x00E0, //LATIN SMALL LETTER A WITH GRAVE
|
|
||||
0x00E1, //LATIN SMALL LETTER A WITH ACUTE
|
|
||||
0x00E2, //LATIN SMALL LETTER A WITH CIRCUMFLEX
|
|
||||
0x00E3, //LATIN SMALL LETTER A WITH TILDE
|
|
||||
0x00E4, //LATIN SMALL LETTER A WITH DIAERESIS
|
|
||||
0x00E5, //LATIN SMALL LETTER A WITH RING ABOVE
|
|
||||
0x00E6, //LATIN SMALL LETTER AE
|
|
||||
0x00E7, //LATIN SMALL LETTER C WITH CEDILLA
|
|
||||
0x00E8, //LATIN SMALL LETTER E WITH GRAVE
|
|
||||
0x00E9, //LATIN SMALL LETTER E WITH ACUTE
|
|
||||
0x00EA, //LATIN SMALL LETTER E WITH CIRCUMFLEX
|
|
||||
0x00EB, //LATIN SMALL LETTER E WITH DIAERESIS
|
|
||||
0x00EC, //LATIN SMALL LETTER I WITH GRAVE
|
|
||||
0x00ED, //LATIN SMALL LETTER I WITH ACUTE
|
|
||||
0x00EE, //LATIN SMALL LETTER I WITH CIRCUMFLEX
|
|
||||
0x00EF, //LATIN SMALL LETTER I WITH DIAERESIS
|
|
||||
0x00F0, //LATIN SMALL LETTER ETH
|
|
||||
0x00F1, //LATIN SMALL LETTER N WITH TILDE
|
|
||||
0x00F2, //LATIN SMALL LETTER O WITH GRAVE
|
|
||||
0x00F3, //LATIN SMALL LETTER O WITH ACUTE
|
|
||||
0x00F4, //LATIN SMALL LETTER O WITH CIRCUMFLEX
|
|
||||
0x00F5, //LATIN SMALL LETTER O WITH TILDE
|
|
||||
0x00F6, //LATIN SMALL LETTER O WITH DIAERESIS
|
|
||||
0x00F7, //DIVISION SIGN
|
|
||||
0x00F8, //LATIN SMALL LETTER O WITH STROKE
|
|
||||
0x00F9, //LATIN SMALL LETTER U WITH GRAVE
|
|
||||
0x00FA, //LATIN SMALL LETTER U WITH ACUTE
|
|
||||
0x00FB, //LATIN SMALL LETTER U WITH CIRCUMFLEX
|
|
||||
0x00FC, //LATIN SMALL LETTER U WITH DIAERESIS
|
|
||||
0x00FD, //LATIN SMALL LETTER Y WITH ACUTE
|
|
||||
0x00FE, //LATIN SMALL LETTER THORN
|
|
||||
0x00FF, //LATIN SMALL LETTER Y WITH DIAERESIS
|
|
||||
}, |
|
||||
} |
|
@ -1,262 +0,0 @@ |
|||||
package cp |
|
||||
|
|
||||
var cp1253 *charsetMap = &charsetMap{ |
|
||||
sb: [256]rune{ |
|
||||
0x0000, //NULL
|
|
||||
0x0001, //START OF HEADING
|
|
||||
0x0002, //START OF TEXT
|
|
||||
0x0003, //END OF TEXT
|
|
||||
0x0004, //END OF TRANSMISSION
|
|
||||
0x0005, //ENQUIRY
|
|
||||
0x0006, //ACKNOWLEDGE
|
|
||||
0x0007, //BELL
|
|
||||
0x0008, //BACKSPACE
|
|
||||
0x0009, //HORIZONTAL TABULATION
|
|
||||
0x000A, //LINE FEED
|
|
||||
0x000B, //VERTICAL TABULATION
|
|
||||
0x000C, //FORM FEED
|
|
||||
0x000D, //CARRIAGE RETURN
|
|
||||
0x000E, //SHIFT OUT
|
|
||||
0x000F, //SHIFT IN
|
|
||||
0x0010, //DATA LINK ESCAPE
|
|
||||
0x0011, //DEVICE CONTROL ONE
|
|
||||
0x0012, //DEVICE CONTROL TWO
|
|
||||
0x0013, //DEVICE CONTROL THREE
|
|
||||
0x0014, //DEVICE CONTROL FOUR
|
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
|
||||
0x0016, //SYNCHRONOUS IDLE
|
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
|
||||
0x0018, //CANCEL
|
|
||||
0x0019, //END OF MEDIUM
|
|
||||
0x001A, //SUBSTITUTE
|
|
||||
0x001B, //ESCAPE
|
|
||||
0x001C, //FILE SEPARATOR
|
|
||||
0x001D, //GROUP SEPARATOR
|
|
||||
0x001E, //RECORD SEPARATOR
|
|
||||
0x001F, //UNIT SEPARATOR
|
|
||||
0x0020, //SPACE
|
|
||||
0x0021, //EXCLAMATION MARK
|
|
||||
0x0022, //QUOTATION MARK
|
|
||||
0x0023, //NUMBER SIGN
|
|
||||
0x0024, //DOLLAR SIGN
|
|
||||
0x0025, //PERCENT SIGN
|
|
||||
0x0026, //AMPERSAND
|
|
||||
0x0027, //APOSTROPHE
|
|
||||
0x0028, //LEFT PARENTHESIS
|
|
||||
0x0029, //RIGHT PARENTHESIS
|
|
||||
0x002A, //ASTERISK
|
|
||||
0x002B, //PLUS SIGN
|
|
||||
0x002C, //COMMA
|
|
||||
0x002D, //HYPHEN-MINUS
|
|
||||
0x002E, //FULL STOP
|
|
||||
0x002F, //SOLIDUS
|
|
||||
0x0030, //DIGIT ZERO
|
|
||||
0x0031, //DIGIT ONE
|
|
||||
0x0032, //DIGIT TWO
|
|
||||
0x0033, //DIGIT THREE
|
|
||||
0x0034, //DIGIT FOUR
|
|
||||
0x0035, //DIGIT FIVE
|
|
||||
0x0036, //DIGIT SIX
|
|
||||
0x0037, //DIGIT SEVEN
|
|
||||
0x0038, //DIGIT EIGHT
|
|
||||
0x0039, //DIGIT NINE
|
|
||||
0x003A, //COLON
|
|
||||
0x003B, //SEMICOLON
|
|
||||
0x003C, //LESS-THAN SIGN
|
|
||||
0x003D, //EQUALS SIGN
|
|
||||
0x003E, //GREATER-THAN SIGN
|
|
||||
0x003F, //QUESTION MARK
|
|
||||
0x0040, //COMMERCIAL AT
|
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
|
||||
0x004A, //LATIN CAPITAL LETTER J
|
|
||||
0x004B, //LATIN CAPITAL LETTER K
|
|
||||
0x004C, //LATIN CAPITAL LETTER L
|
|
||||
0x004D, //LATIN CAPITAL LETTER M
|
|
||||
0x004E, //LATIN CAPITAL LETTER N
|
|
||||
0x004F, //LATIN CAPITAL LETTER O
|
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
|
||||
0x005A, //LATIN CAPITAL LETTER Z
|
|
||||
0x005B, //LEFT SQUARE BRACKET
|
|
||||
0x005C, //REVERSE SOLIDUS
|
|
||||
0x005D, //RIGHT SQUARE BRACKET
|
|
||||
0x005E, //CIRCUMFLEX ACCENT
|
|
||||
0x005F, //LOW LINE
|
|
||||
0x0060, //GRAVE ACCENT
|
|
||||
0x0061, //LATIN SMALL LETTER A
|
|
||||
0x0062, //LATIN SMALL LETTER B
|
|
||||
0x0063, //LATIN SMALL LETTER C
|
|
||||
0x0064, //LATIN SMALL LETTER D
|
|
||||
0x0065, //LATIN SMALL LETTER E
|
|
||||
0x0066, //LATIN SMALL LETTER F
|
|
||||
0x0067, //LATIN SMALL LETTER G
|
|
||||
0x0068, //LATIN SMALL LETTER H
|
|
||||
0x0069, //LATIN SMALL LETTER I
|
|
||||
0x006A, //LATIN SMALL LETTER J
|
|
||||
0x006B, //LATIN SMALL LETTER K
|
|
||||
0x006C, //LATIN SMALL LETTER L
|
|
||||
0x006D, //LATIN SMALL LETTER M
|
|
||||
0x006E, //LATIN SMALL LETTER N
|
|
||||
0x006F, //LATIN SMALL LETTER O
|
|
||||
0x0070, //LATIN SMALL LETTER P
|
|
||||
0x0071, //LATIN SMALL LETTER Q
|
|
||||
0x0072, //LATIN SMALL LETTER R
|
|
||||
0x0073, //LATIN SMALL LETTER S
|
|
||||
0x0074, //LATIN SMALL LETTER T
|
|
||||
0x0075, //LATIN SMALL LETTER U
|
|
||||
0x0076, //LATIN SMALL LETTER V
|
|
||||
0x0077, //LATIN SMALL LETTER W
|
|
||||
0x0078, //LATIN SMALL LETTER X
|
|
||||
0x0079, //LATIN SMALL LETTER Y
|
|
||||
0x007A, //LATIN SMALL LETTER Z
|
|
||||
0x007B, //LEFT CURLY BRACKET
|
|
||||
0x007C, //VERTICAL LINE
|
|
||||
0x007D, //RIGHT CURLY BRACKET
|
|
||||
0x007E, //TILDE
|
|
||||
0x007F, //DELETE
|
|
||||
0x20AC, //EURO SIGN
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x201A, //SINGLE LOW-9 QUOTATION MARK
|
|
||||
0x0192, //LATIN SMALL LETTER F WITH HOOK
|
|
||||
0x201E, //DOUBLE LOW-9 QUOTATION MARK
|
|
||||
0x2026, //HORIZONTAL ELLIPSIS
|
|
||||
0x2020, //DAGGER
|
|
||||
0x2021, //DOUBLE DAGGER
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x2030, //PER MILLE SIGN
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x2018, //LEFT SINGLE QUOTATION MARK
|
|
||||
0x2019, //RIGHT SINGLE QUOTATION MARK
|
|
||||
0x201C, //LEFT DOUBLE QUOTATION MARK
|
|
||||
0x201D, //RIGHT DOUBLE QUOTATION MARK
|
|
||||
0x2022, //BULLET
|
|
||||
0x2013, //EN DASH
|
|
||||
0x2014, //EM DASH
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x2122, //TRADE MARK SIGN
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x00A0, //NO-BREAK SPACE
|
|
||||
0x0385, //GREEK DIALYTIKA TONOS
|
|
||||
0x0386, //GREEK CAPITAL LETTER ALPHA WITH TONOS
|
|
||||
0x00A3, //POUND SIGN
|
|
||||
0x00A4, //CURRENCY SIGN
|
|
||||
0x00A5, //YEN SIGN
|
|
||||
0x00A6, //BROKEN BAR
|
|
||||
0x00A7, //SECTION SIGN
|
|
||||
0x00A8, //DIAERESIS
|
|
||||
0x00A9, //COPYRIGHT SIGN
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x00AC, //NOT SIGN
|
|
||||
0x00AD, //SOFT HYPHEN
|
|
||||
0x00AE, //REGISTERED SIGN
|
|
||||
0x2015, //HORIZONTAL BAR
|
|
||||
0x00B0, //DEGREE SIGN
|
|
||||
0x00B1, //PLUS-MINUS SIGN
|
|
||||
0x00B2, //SUPERSCRIPT TWO
|
|
||||
0x00B3, //SUPERSCRIPT THREE
|
|
||||
0x0384, //GREEK TONOS
|
|
||||
0x00B5, //MICRO SIGN
|
|
||||
0x00B6, //PILCROW SIGN
|
|
||||
0x00B7, //MIDDLE DOT
|
|
||||
0x0388, //GREEK CAPITAL LETTER EPSILON WITH TONOS
|
|
||||
0x0389, //GREEK CAPITAL LETTER ETA WITH TONOS
|
|
||||
0x038A, //GREEK CAPITAL LETTER IOTA WITH TONOS
|
|
||||
0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x038C, //GREEK CAPITAL LETTER OMICRON WITH TONOS
|
|
||||
0x00BD, //VULGAR FRACTION ONE HALF
|
|
||||
0x038E, //GREEK CAPITAL LETTER UPSILON WITH TONOS
|
|
||||
0x038F, //GREEK CAPITAL LETTER OMEGA WITH TONOS
|
|
||||
0x0390, //GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
|
|
||||
0x0391, //GREEK CAPITAL LETTER ALPHA
|
|
||||
0x0392, //GREEK CAPITAL LETTER BETA
|
|
||||
0x0393, //GREEK CAPITAL LETTER GAMMA
|
|
||||
0x0394, //GREEK CAPITAL LETTER DELTA
|
|
||||
0x0395, //GREEK CAPITAL LETTER EPSILON
|
|
||||
0x0396, //GREEK CAPITAL LETTER ZETA
|
|
||||
0x0397, //GREEK CAPITAL LETTER ETA
|
|
||||
0x0398, //GREEK CAPITAL LETTER THETA
|
|
||||
0x0399, //GREEK CAPITAL LETTER IOTA
|
|
||||
0x039A, //GREEK CAPITAL LETTER KAPPA
|
|
||||
0x039B, //GREEK CAPITAL LETTER LAMDA
|
|
||||
0x039C, //GREEK CAPITAL LETTER MU
|
|
||||
0x039D, //GREEK CAPITAL LETTER NU
|
|
||||
0x039E, //GREEK CAPITAL LETTER XI
|
|
||||
0x039F, //GREEK CAPITAL LETTER OMICRON
|
|
||||
0x03A0, //GREEK CAPITAL LETTER PI
|
|
||||
0x03A1, //GREEK CAPITAL LETTER RHO
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x03A3, //GREEK CAPITAL LETTER SIGMA
|
|
||||
0x03A4, //GREEK CAPITAL LETTER TAU
|
|
||||
0x03A5, //GREEK CAPITAL LETTER UPSILON
|
|
||||
0x03A6, //GREEK CAPITAL LETTER PHI
|
|
||||
0x03A7, //GREEK CAPITAL LETTER CHI
|
|
||||
0x03A8, //GREEK CAPITAL LETTER PSI
|
|
||||
0x03A9, //GREEK CAPITAL LETTER OMEGA
|
|
||||
0x03AA, //GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
|
|
||||
0x03AB, //GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
|
|
||||
0x03AC, //GREEK SMALL LETTER ALPHA WITH TONOS
|
|
||||
0x03AD, //GREEK SMALL LETTER EPSILON WITH TONOS
|
|
||||
0x03AE, //GREEK SMALL LETTER ETA WITH TONOS
|
|
||||
0x03AF, //GREEK SMALL LETTER IOTA WITH TONOS
|
|
||||
0x03B0, //GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
|
|
||||
0x03B1, //GREEK SMALL LETTER ALPHA
|
|
||||
0x03B2, //GREEK SMALL LETTER BETA
|
|
||||
0x03B3, //GREEK SMALL LETTER GAMMA
|
|
||||
0x03B4, //GREEK SMALL LETTER DELTA
|
|
||||
0x03B5, //GREEK SMALL LETTER EPSILON
|
|
||||
0x03B6, //GREEK SMALL LETTER ZETA
|
|
||||
0x03B7, //GREEK SMALL LETTER ETA
|
|
||||
0x03B8, //GREEK SMALL LETTER THETA
|
|
||||
0x03B9, //GREEK SMALL LETTER IOTA
|
|
||||
0x03BA, //GREEK SMALL LETTER KAPPA
|
|
||||
0x03BB, //GREEK SMALL LETTER LAMDA
|
|
||||
0x03BC, //GREEK SMALL LETTER MU
|
|
||||
0x03BD, //GREEK SMALL LETTER NU
|
|
||||
0x03BE, //GREEK SMALL LETTER XI
|
|
||||
0x03BF, //GREEK SMALL LETTER OMICRON
|
|
||||
0x03C0, //GREEK SMALL LETTER PI
|
|
||||
0x03C1, //GREEK SMALL LETTER RHO
|
|
||||
0x03C2, //GREEK SMALL LETTER FINAL SIGMA
|
|
||||
0x03C3, //GREEK SMALL LETTER SIGMA
|
|
||||
0x03C4, //GREEK SMALL LETTER TAU
|
|
||||
0x03C5, //GREEK SMALL LETTER UPSILON
|
|
||||
0x03C6, //GREEK SMALL LETTER PHI
|
|
||||
0x03C7, //GREEK SMALL LETTER CHI
|
|
||||
0x03C8, //GREEK SMALL LETTER PSI
|
|
||||
0x03C9, //GREEK SMALL LETTER OMEGA
|
|
||||
0x03CA, //GREEK SMALL LETTER IOTA WITH DIALYTIKA
|
|
||||
0x03CB, //GREEK SMALL LETTER UPSILON WITH DIALYTIKA
|
|
||||
0x03CC, //GREEK SMALL LETTER OMICRON WITH TONOS
|
|
||||
0x03CD, //GREEK SMALL LETTER UPSILON WITH TONOS
|
|
||||
0x03CE, //GREEK SMALL LETTER OMEGA WITH TONOS
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
}, |
|
||||
} |
|
@ -1,262 +0,0 @@ |
|||||
package cp |
|
||||
|
|
||||
var cp1254 *charsetMap = &charsetMap{ |
|
||||
sb: [256]rune{ |
|
||||
0x0000, //NULL
|
|
||||
0x0001, //START OF HEADING
|
|
||||
0x0002, //START OF TEXT
|
|
||||
0x0003, //END OF TEXT
|
|
||||
0x0004, //END OF TRANSMISSION
|
|
||||
0x0005, //ENQUIRY
|
|
||||
0x0006, //ACKNOWLEDGE
|
|
||||
0x0007, //BELL
|
|
||||
0x0008, //BACKSPACE
|
|
||||
0x0009, //HORIZONTAL TABULATION
|
|
||||
0x000A, //LINE FEED
|
|
||||
0x000B, //VERTICAL TABULATION
|
|
||||
0x000C, //FORM FEED
|
|
||||
0x000D, //CARRIAGE RETURN
|
|
||||
0x000E, //SHIFT OUT
|
|
||||
0x000F, //SHIFT IN
|
|
||||
0x0010, //DATA LINK ESCAPE
|
|
||||
0x0011, //DEVICE CONTROL ONE
|
|
||||
0x0012, //DEVICE CONTROL TWO
|
|
||||
0x0013, //DEVICE CONTROL THREE
|
|
||||
0x0014, //DEVICE CONTROL FOUR
|
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
|
||||
0x0016, //SYNCHRONOUS IDLE
|
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
|
||||
0x0018, //CANCEL
|
|
||||
0x0019, //END OF MEDIUM
|
|
||||
0x001A, //SUBSTITUTE
|
|
||||
0x001B, //ESCAPE
|
|
||||
0x001C, //FILE SEPARATOR
|
|
||||
0x001D, //GROUP SEPARATOR
|
|
||||
0x001E, //RECORD SEPARATOR
|
|
||||
0x001F, //UNIT SEPARATOR
|
|
||||
0x0020, //SPACE
|
|
||||
0x0021, //EXCLAMATION MARK
|
|
||||
0x0022, //QUOTATION MARK
|
|
||||
0x0023, //NUMBER SIGN
|
|
||||
0x0024, //DOLLAR SIGN
|
|
||||
0x0025, //PERCENT SIGN
|
|
||||
0x0026, //AMPERSAND
|
|
||||
0x0027, //APOSTROPHE
|
|
||||
0x0028, //LEFT PARENTHESIS
|
|
||||
0x0029, //RIGHT PARENTHESIS
|
|
||||
0x002A, //ASTERISK
|
|
||||
0x002B, //PLUS SIGN
|
|
||||
0x002C, //COMMA
|
|
||||
0x002D, //HYPHEN-MINUS
|
|
||||
0x002E, //FULL STOP
|
|
||||
0x002F, //SOLIDUS
|
|
||||
0x0030, //DIGIT ZERO
|
|
||||
0x0031, //DIGIT ONE
|
|
||||
0x0032, //DIGIT TWO
|
|
||||
0x0033, //DIGIT THREE
|
|
||||
0x0034, //DIGIT FOUR
|
|
||||
0x0035, //DIGIT FIVE
|
|
||||
0x0036, //DIGIT SIX
|
|
||||
0x0037, //DIGIT SEVEN
|
|
||||
0x0038, //DIGIT EIGHT
|
|
||||
0x0039, //DIGIT NINE
|
|
||||
0x003A, //COLON
|
|
||||
0x003B, //SEMICOLON
|
|
||||
0x003C, //LESS-THAN SIGN
|
|
||||
0x003D, //EQUALS SIGN
|
|
||||
0x003E, //GREATER-THAN SIGN
|
|
||||
0x003F, //QUESTION MARK
|
|
||||
0x0040, //COMMERCIAL AT
|
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
|
||||
0x004A, //LATIN CAPITAL LETTER J
|
|
||||
0x004B, //LATIN CAPITAL LETTER K
|
|
||||
0x004C, //LATIN CAPITAL LETTER L
|
|
||||
0x004D, //LATIN CAPITAL LETTER M
|
|
||||
0x004E, //LATIN CAPITAL LETTER N
|
|
||||
0x004F, //LATIN CAPITAL LETTER O
|
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
|
||||
0x005A, //LATIN CAPITAL LETTER Z
|
|
||||
0x005B, //LEFT SQUARE BRACKET
|
|
||||
0x005C, //REVERSE SOLIDUS
|
|
||||
0x005D, //RIGHT SQUARE BRACKET
|
|
||||
0x005E, //CIRCUMFLEX ACCENT
|
|
||||
0x005F, //LOW LINE
|
|
||||
0x0060, //GRAVE ACCENT
|
|
||||
0x0061, //LATIN SMALL LETTER A
|
|
||||
0x0062, //LATIN SMALL LETTER B
|
|
||||
0x0063, //LATIN SMALL LETTER C
|
|
||||
0x0064, //LATIN SMALL LETTER D
|
|
||||
0x0065, //LATIN SMALL LETTER E
|
|
||||
0x0066, //LATIN SMALL LETTER F
|
|
||||
0x0067, //LATIN SMALL LETTER G
|
|
||||
0x0068, //LATIN SMALL LETTER H
|
|
||||
0x0069, //LATIN SMALL LETTER I
|
|
||||
0x006A, //LATIN SMALL LETTER J
|
|
||||
0x006B, //LATIN SMALL LETTER K
|
|
||||
0x006C, //LATIN SMALL LETTER L
|
|
||||
0x006D, //LATIN SMALL LETTER M
|
|
||||
0x006E, //LATIN SMALL LETTER N
|
|
||||
0x006F, //LATIN SMALL LETTER O
|
|
||||
0x0070, //LATIN SMALL LETTER P
|
|
||||
0x0071, //LATIN SMALL LETTER Q
|
|
||||
0x0072, //LATIN SMALL LETTER R
|
|
||||
0x0073, //LATIN SMALL LETTER S
|
|
||||
0x0074, //LATIN SMALL LETTER T
|
|
||||
0x0075, //LATIN SMALL LETTER U
|
|
||||
0x0076, //LATIN SMALL LETTER V
|
|
||||
0x0077, //LATIN SMALL LETTER W
|
|
||||
0x0078, //LATIN SMALL LETTER X
|
|
||||
0x0079, //LATIN SMALL LETTER Y
|
|
||||
0x007A, //LATIN SMALL LETTER Z
|
|
||||
0x007B, //LEFT CURLY BRACKET
|
|
||||
0x007C, //VERTICAL LINE
|
|
||||
0x007D, //RIGHT CURLY BRACKET
|
|
||||
0x007E, //TILDE
|
|
||||
0x007F, //DELETE
|
|
||||
0x20AC, //EURO SIGN
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x201A, //SINGLE LOW-9 QUOTATION MARK
|
|
||||
0x0192, //LATIN SMALL LETTER F WITH HOOK
|
|
||||
0x201E, //DOUBLE LOW-9 QUOTATION MARK
|
|
||||
0x2026, //HORIZONTAL ELLIPSIS
|
|
||||
0x2020, //DAGGER
|
|
||||
0x2021, //DOUBLE DAGGER
|
|
||||
0x02C6, //MODIFIER LETTER CIRCUMFLEX ACCENT
|
|
||||
0x2030, //PER MILLE SIGN
|
|
||||
0x0160, //LATIN CAPITAL LETTER S WITH CARON
|
|
||||
0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
|
||||
0x0152, //LATIN CAPITAL LIGATURE OE
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x2018, //LEFT SINGLE QUOTATION MARK
|
|
||||
0x2019, //RIGHT SINGLE QUOTATION MARK
|
|
||||
0x201C, //LEFT DOUBLE QUOTATION MARK
|
|
||||
0x201D, //RIGHT DOUBLE QUOTATION MARK
|
|
||||
0x2022, //BULLET
|
|
||||
0x2013, //EN DASH
|
|
||||
0x2014, //EM DASH
|
|
||||
0x02DC, //SMALL TILDE
|
|
||||
0x2122, //TRADE MARK SIGN
|
|
||||
0x0161, //LATIN SMALL LETTER S WITH CARON
|
|
||||
0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
|
||||
0x0153, //LATIN SMALL LIGATURE OE
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x0178, //LATIN CAPITAL LETTER Y WITH DIAERESIS
|
|
||||
0x00A0, //NO-BREAK SPACE
|
|
||||
0x00A1, //INVERTED EXCLAMATION MARK
|
|
||||
0x00A2, //CENT SIGN
|
|
||||
0x00A3, //POUND SIGN
|
|
||||
0x00A4, //CURRENCY SIGN
|
|
||||
0x00A5, //YEN SIGN
|
|
||||
0x00A6, //BROKEN BAR
|
|
||||
0x00A7, //SECTION SIGN
|
|
||||
0x00A8, //DIAERESIS
|
|
||||
0x00A9, //COPYRIGHT SIGN
|
|
||||
0x00AA, //FEMININE ORDINAL INDICATOR
|
|
||||
0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x00AC, //NOT SIGN
|
|
||||
0x00AD, //SOFT HYPHEN
|
|
||||
0x00AE, //REGISTERED SIGN
|
|
||||
0x00AF, //MACRON
|
|
||||
0x00B0, //DEGREE SIGN
|
|
||||
0x00B1, //PLUS-MINUS SIGN
|
|
||||
0x00B2, //SUPERSCRIPT TWO
|
|
||||
0x00B3, //SUPERSCRIPT THREE
|
|
||||
0x00B4, //ACUTE ACCENT
|
|
||||
0x00B5, //MICRO SIGN
|
|
||||
0x00B6, //PILCROW SIGN
|
|
||||
0x00B7, //MIDDLE DOT
|
|
||||
0x00B8, //CEDILLA
|
|
||||
0x00B9, //SUPERSCRIPT ONE
|
|
||||
0x00BA, //MASCULINE ORDINAL INDICATOR
|
|
||||
0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x00BC, //VULGAR FRACTION ONE QUARTER
|
|
||||
0x00BD, //VULGAR FRACTION ONE HALF
|
|
||||
0x00BE, //VULGAR FRACTION THREE QUARTERS
|
|
||||
0x00BF, //INVERTED QUESTION MARK
|
|
||||
0x00C0, //LATIN CAPITAL LETTER A WITH GRAVE
|
|
||||
0x00C1, //LATIN CAPITAL LETTER A WITH ACUTE
|
|
||||
0x00C2, //LATIN CAPITAL LETTER A WITH CIRCUMFLEX
|
|
||||
0x00C3, //LATIN CAPITAL LETTER A WITH TILDE
|
|
||||
0x00C4, //LATIN CAPITAL LETTER A WITH DIAERESIS
|
|
||||
0x00C5, //LATIN CAPITAL LETTER A WITH RING ABOVE
|
|
||||
0x00C6, //LATIN CAPITAL LETTER AE
|
|
||||
0x00C7, //LATIN CAPITAL LETTER C WITH CEDILLA
|
|
||||
0x00C8, //LATIN CAPITAL LETTER E WITH GRAVE
|
|
||||
0x00C9, //LATIN CAPITAL LETTER E WITH ACUTE
|
|
||||
0x00CA, //LATIN CAPITAL LETTER E WITH CIRCUMFLEX
|
|
||||
0x00CB, //LATIN CAPITAL LETTER E WITH DIAERESIS
|
|
||||
0x00CC, //LATIN CAPITAL LETTER I WITH GRAVE
|
|
||||
0x00CD, //LATIN CAPITAL LETTER I WITH ACUTE
|
|
||||
0x00CE, //LATIN CAPITAL LETTER I WITH CIRCUMFLEX
|
|
||||
0x00CF, //LATIN CAPITAL LETTER I WITH DIAERESIS
|
|
||||
0x011E, //LATIN CAPITAL LETTER G WITH BREVE
|
|
||||
0x00D1, //LATIN CAPITAL LETTER N WITH TILDE
|
|
||||
0x00D2, //LATIN CAPITAL LETTER O WITH GRAVE
|
|
||||
0x00D3, //LATIN CAPITAL LETTER O WITH ACUTE
|
|
||||
0x00D4, //LATIN CAPITAL LETTER O WITH CIRCUMFLEX
|
|
||||
0x00D5, //LATIN CAPITAL LETTER O WITH TILDE
|
|
||||
0x00D6, //LATIN CAPITAL LETTER O WITH DIAERESIS
|
|
||||
0x00D7, //MULTIPLICATION SIGN
|
|
||||
0x00D8, //LATIN CAPITAL LETTER O WITH STROKE
|
|
||||
0x00D9, //LATIN CAPITAL LETTER U WITH GRAVE
|
|
||||
0x00DA, //LATIN CAPITAL LETTER U WITH ACUTE
|
|
||||
0x00DB, //LATIN CAPITAL LETTER U WITH CIRCUMFLEX
|
|
||||
0x00DC, //LATIN CAPITAL LETTER U WITH DIAERESIS
|
|
||||
0x0130, //LATIN CAPITAL LETTER I WITH DOT ABOVE
|
|
||||
0x015E, //LATIN CAPITAL LETTER S WITH CEDILLA
|
|
||||
0x00DF, //LATIN SMALL LETTER SHARP S
|
|
||||
0x00E0, //LATIN SMALL LETTER A WITH GRAVE
|
|
||||
0x00E1, //LATIN SMALL LETTER A WITH ACUTE
|
|
||||
0x00E2, //LATIN SMALL LETTER A WITH CIRCUMFLEX
|
|
||||
0x00E3, //LATIN SMALL LETTER A WITH TILDE
|
|
||||
0x00E4, //LATIN SMALL LETTER A WITH DIAERESIS
|
|
||||
0x00E5, //LATIN SMALL LETTER A WITH RING ABOVE
|
|
||||
0x00E6, //LATIN SMALL LETTER AE
|
|
||||
0x00E7, //LATIN SMALL LETTER C WITH CEDILLA
|
|
||||
0x00E8, //LATIN SMALL LETTER E WITH GRAVE
|
|
||||
0x00E9, //LATIN SMALL LETTER E WITH ACUTE
|
|
||||
0x00EA, //LATIN SMALL LETTER E WITH CIRCUMFLEX
|
|
||||
0x00EB, //LATIN SMALL LETTER E WITH DIAERESIS
|
|
||||
0x00EC, //LATIN SMALL LETTER I WITH GRAVE
|
|
||||
0x00ED, //LATIN SMALL LETTER I WITH ACUTE
|
|
||||
0x00EE, //LATIN SMALL LETTER I WITH CIRCUMFLEX
|
|
||||
0x00EF, //LATIN SMALL LETTER I WITH DIAERESIS
|
|
||||
0x011F, //LATIN SMALL LETTER G WITH BREVE
|
|
||||
0x00F1, //LATIN SMALL LETTER N WITH TILDE
|
|
||||
0x00F2, //LATIN SMALL LETTER O WITH GRAVE
|
|
||||
0x00F3, //LATIN SMALL LETTER O WITH ACUTE
|
|
||||
0x00F4, //LATIN SMALL LETTER O WITH CIRCUMFLEX
|
|
||||
0x00F5, //LATIN SMALL LETTER O WITH TILDE
|
|
||||
0x00F6, //LATIN SMALL LETTER O WITH DIAERESIS
|
|
||||
0x00F7, //DIVISION SIGN
|
|
||||
0x00F8, //LATIN SMALL LETTER O WITH STROKE
|
|
||||
0x00F9, //LATIN SMALL LETTER U WITH GRAVE
|
|
||||
0x00FA, //LATIN SMALL LETTER U WITH ACUTE
|
|
||||
0x00FB, //LATIN SMALL LETTER U WITH CIRCUMFLEX
|
|
||||
0x00FC, //LATIN SMALL LETTER U WITH DIAERESIS
|
|
||||
0x0131, //LATIN SMALL LETTER DOTLESS I
|
|
||||
0x015F, //LATIN SMALL LETTER S WITH CEDILLA
|
|
||||
0x00FF, //LATIN SMALL LETTER Y WITH DIAERESIS
|
|
||||
}, |
|
||||
} |
|
@ -1,262 +0,0 @@ |
|||||
package cp |
|
||||
|
|
||||
var cp1255 *charsetMap = &charsetMap{ |
|
||||
sb: [256]rune{ |
|
||||
0x0000, //NULL
|
|
||||
0x0001, //START OF HEADING
|
|
||||
0x0002, //START OF TEXT
|
|
||||
0x0003, //END OF TEXT
|
|
||||
0x0004, //END OF TRANSMISSION
|
|
||||
0x0005, //ENQUIRY
|
|
||||
0x0006, //ACKNOWLEDGE
|
|
||||
0x0007, //BELL
|
|
||||
0x0008, //BACKSPACE
|
|
||||
0x0009, //HORIZONTAL TABULATION
|
|
||||
0x000A, //LINE FEED
|
|
||||
0x000B, //VERTICAL TABULATION
|
|
||||
0x000C, //FORM FEED
|
|
||||
0x000D, //CARRIAGE RETURN
|
|
||||
0x000E, //SHIFT OUT
|
|
||||
0x000F, //SHIFT IN
|
|
||||
0x0010, //DATA LINK ESCAPE
|
|
||||
0x0011, //DEVICE CONTROL ONE
|
|
||||
0x0012, //DEVICE CONTROL TWO
|
|
||||
0x0013, //DEVICE CONTROL THREE
|
|
||||
0x0014, //DEVICE CONTROL FOUR
|
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
|
||||
0x0016, //SYNCHRONOUS IDLE
|
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
|
||||
0x0018, //CANCEL
|
|
||||
0x0019, //END OF MEDIUM
|
|
||||
0x001A, //SUBSTITUTE
|
|
||||
0x001B, //ESCAPE
|
|
||||
0x001C, //FILE SEPARATOR
|
|
||||
0x001D, //GROUP SEPARATOR
|
|
||||
0x001E, //RECORD SEPARATOR
|
|
||||
0x001F, //UNIT SEPARATOR
|
|
||||
0x0020, //SPACE
|
|
||||
0x0021, //EXCLAMATION MARK
|
|
||||
0x0022, //QUOTATION MARK
|
|
||||
0x0023, //NUMBER SIGN
|
|
||||
0x0024, //DOLLAR SIGN
|
|
||||
0x0025, //PERCENT SIGN
|
|
||||
0x0026, //AMPERSAND
|
|
||||
0x0027, //APOSTROPHE
|
|
||||
0x0028, //LEFT PARENTHESIS
|
|
||||
0x0029, //RIGHT PARENTHESIS
|
|
||||
0x002A, //ASTERISK
|
|
||||
0x002B, //PLUS SIGN
|
|
||||
0x002C, //COMMA
|
|
||||
0x002D, //HYPHEN-MINUS
|
|
||||
0x002E, //FULL STOP
|
|
||||
0x002F, //SOLIDUS
|
|
||||
0x0030, //DIGIT ZERO
|
|
||||
0x0031, //DIGIT ONE
|
|
||||
0x0032, //DIGIT TWO
|
|
||||
0x0033, //DIGIT THREE
|
|
||||
0x0034, //DIGIT FOUR
|
|
||||
0x0035, //DIGIT FIVE
|
|
||||
0x0036, //DIGIT SIX
|
|
||||
0x0037, //DIGIT SEVEN
|
|
||||
0x0038, //DIGIT EIGHT
|
|
||||
0x0039, //DIGIT NINE
|
|
||||
0x003A, //COLON
|
|
||||
0x003B, //SEMICOLON
|
|
||||
0x003C, //LESS-THAN SIGN
|
|
||||
0x003D, //EQUALS SIGN
|
|
||||
0x003E, //GREATER-THAN SIGN
|
|
||||
0x003F, //QUESTION MARK
|
|
||||
0x0040, //COMMERCIAL AT
|
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
|
||||
0x004A, //LATIN CAPITAL LETTER J
|
|
||||
0x004B, //LATIN CAPITAL LETTER K
|
|
||||
0x004C, //LATIN CAPITAL LETTER L
|
|
||||
0x004D, //LATIN CAPITAL LETTER M
|
|
||||
0x004E, //LATIN CAPITAL LETTER N
|
|
||||
0x004F, //LATIN CAPITAL LETTER O
|
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
|
||||
0x005A, //LATIN CAPITAL LETTER Z
|
|
||||
0x005B, //LEFT SQUARE BRACKET
|
|
||||
0x005C, //REVERSE SOLIDUS
|
|
||||
0x005D, //RIGHT SQUARE BRACKET
|
|
||||
0x005E, //CIRCUMFLEX ACCENT
|
|
||||
0x005F, //LOW LINE
|
|
||||
0x0060, //GRAVE ACCENT
|
|
||||
0x0061, //LATIN SMALL LETTER A
|
|
||||
0x0062, //LATIN SMALL LETTER B
|
|
||||
0x0063, //LATIN SMALL LETTER C
|
|
||||
0x0064, //LATIN SMALL LETTER D
|
|
||||
0x0065, //LATIN SMALL LETTER E
|
|
||||
0x0066, //LATIN SMALL LETTER F
|
|
||||
0x0067, //LATIN SMALL LETTER G
|
|
||||
0x0068, //LATIN SMALL LETTER H
|
|
||||
0x0069, //LATIN SMALL LETTER I
|
|
||||
0x006A, //LATIN SMALL LETTER J
|
|
||||
0x006B, //LATIN SMALL LETTER K
|
|
||||
0x006C, //LATIN SMALL LETTER L
|
|
||||
0x006D, //LATIN SMALL LETTER M
|
|
||||
0x006E, //LATIN SMALL LETTER N
|
|
||||
0x006F, //LATIN SMALL LETTER O
|
|
||||
0x0070, //LATIN SMALL LETTER P
|
|
||||
0x0071, //LATIN SMALL LETTER Q
|
|
||||
0x0072, //LATIN SMALL LETTER R
|
|
||||
0x0073, //LATIN SMALL LETTER S
|
|
||||
0x0074, //LATIN SMALL LETTER T
|
|
||||
0x0075, //LATIN SMALL LETTER U
|
|
||||
0x0076, //LATIN SMALL LETTER V
|
|
||||
0x0077, //LATIN SMALL LETTER W
|
|
||||
0x0078, //LATIN SMALL LETTER X
|
|
||||
0x0079, //LATIN SMALL LETTER Y
|
|
||||
0x007A, //LATIN SMALL LETTER Z
|
|
||||
0x007B, //LEFT CURLY BRACKET
|
|
||||
0x007C, //VERTICAL LINE
|
|
||||
0x007D, //RIGHT CURLY BRACKET
|
|
||||
0x007E, //TILDE
|
|
||||
0x007F, //DELETE
|
|
||||
0x20AC, //EURO SIGN
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x201A, //SINGLE LOW-9 QUOTATION MARK
|
|
||||
0x0192, //LATIN SMALL LETTER F WITH HOOK
|
|
||||
0x201E, //DOUBLE LOW-9 QUOTATION MARK
|
|
||||
0x2026, //HORIZONTAL ELLIPSIS
|
|
||||
0x2020, //DAGGER
|
|
||||
0x2021, //DOUBLE DAGGER
|
|
||||
0x02C6, //MODIFIER LETTER CIRCUMFLEX ACCENT
|
|
||||
0x2030, //PER MILLE SIGN
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x2018, //LEFT SINGLE QUOTATION MARK
|
|
||||
0x2019, //RIGHT SINGLE QUOTATION MARK
|
|
||||
0x201C, //LEFT DOUBLE QUOTATION MARK
|
|
||||
0x201D, //RIGHT DOUBLE QUOTATION MARK
|
|
||||
0x2022, //BULLET
|
|
||||
0x2013, //EN DASH
|
|
||||
0x2014, //EM DASH
|
|
||||
0x02DC, //SMALL TILDE
|
|
||||
0x2122, //TRADE MARK SIGN
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x00A0, //NO-BREAK SPACE
|
|
||||
0x00A1, //INVERTED EXCLAMATION MARK
|
|
||||
0x00A2, //CENT SIGN
|
|
||||
0x00A3, //POUND SIGN
|
|
||||
0x20AA, //NEW SHEQEL SIGN
|
|
||||
0x00A5, //YEN SIGN
|
|
||||
0x00A6, //BROKEN BAR
|
|
||||
0x00A7, //SECTION SIGN
|
|
||||
0x00A8, //DIAERESIS
|
|
||||
0x00A9, //COPYRIGHT SIGN
|
|
||||
0x00D7, //MULTIPLICATION SIGN
|
|
||||
0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x00AC, //NOT SIGN
|
|
||||
0x00AD, //SOFT HYPHEN
|
|
||||
0x00AE, //REGISTERED SIGN
|
|
||||
0x00AF, //MACRON
|
|
||||
0x00B0, //DEGREE SIGN
|
|
||||
0x00B1, //PLUS-MINUS SIGN
|
|
||||
0x00B2, //SUPERSCRIPT TWO
|
|
||||
0x00B3, //SUPERSCRIPT THREE
|
|
||||
0x00B4, //ACUTE ACCENT
|
|
||||
0x00B5, //MICRO SIGN
|
|
||||
0x00B6, //PILCROW SIGN
|
|
||||
0x00B7, //MIDDLE DOT
|
|
||||
0x00B8, //CEDILLA
|
|
||||
0x00B9, //SUPERSCRIPT ONE
|
|
||||
0x00F7, //DIVISION SIGN
|
|
||||
0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x00BC, //VULGAR FRACTION ONE QUARTER
|
|
||||
0x00BD, //VULGAR FRACTION ONE HALF
|
|
||||
0x00BE, //VULGAR FRACTION THREE QUARTERS
|
|
||||
0x00BF, //INVERTED QUESTION MARK
|
|
||||
0x05B0, //HEBREW POINT SHEVA
|
|
||||
0x05B1, //HEBREW POINT HATAF SEGOL
|
|
||||
0x05B2, //HEBREW POINT HATAF PATAH
|
|
||||
0x05B3, //HEBREW POINT HATAF QAMATS
|
|
||||
0x05B4, //HEBREW POINT HIRIQ
|
|
||||
0x05B5, //HEBREW POINT TSERE
|
|
||||
0x05B6, //HEBREW POINT SEGOL
|
|
||||
0x05B7, //HEBREW POINT PATAH
|
|
||||
0x05B8, //HEBREW POINT QAMATS
|
|
||||
0x05B9, //HEBREW POINT HOLAM
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x05BB, //HEBREW POINT QUBUTS
|
|
||||
0x05BC, //HEBREW POINT DAGESH OR MAPIQ
|
|
||||
0x05BD, //HEBREW POINT METEG
|
|
||||
0x05BE, //HEBREW PUNCTUATION MAQAF
|
|
||||
0x05BF, //HEBREW POINT RAFE
|
|
||||
0x05C0, //HEBREW PUNCTUATION PASEQ
|
|
||||
0x05C1, //HEBREW POINT SHIN DOT
|
|
||||
0x05C2, //HEBREW POINT SIN DOT
|
|
||||
0x05C3, //HEBREW PUNCTUATION SOF PASUQ
|
|
||||
0x05F0, //HEBREW LIGATURE YIDDISH DOUBLE VAV
|
|
||||
0x05F1, //HEBREW LIGATURE YIDDISH VAV YOD
|
|
||||
0x05F2, //HEBREW LIGATURE YIDDISH DOUBLE YOD
|
|
||||
0x05F3, //HEBREW PUNCTUATION GERESH
|
|
||||
0x05F4, //HEBREW PUNCTUATION GERSHAYIM
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x05D0, //HEBREW LETTER ALEF
|
|
||||
0x05D1, //HEBREW LETTER BET
|
|
||||
0x05D2, //HEBREW LETTER GIMEL
|
|
||||
0x05D3, //HEBREW LETTER DALET
|
|
||||
0x05D4, //HEBREW LETTER HE
|
|
||||
0x05D5, //HEBREW LETTER VAV
|
|
||||
0x05D6, //HEBREW LETTER ZAYIN
|
|
||||
0x05D7, //HEBREW LETTER HET
|
|
||||
0x05D8, //HEBREW LETTER TET
|
|
||||
0x05D9, //HEBREW LETTER YOD
|
|
||||
0x05DA, //HEBREW LETTER FINAL KAF
|
|
||||
0x05DB, //HEBREW LETTER KAF
|
|
||||
0x05DC, //HEBREW LETTER LAMED
|
|
||||
0x05DD, //HEBREW LETTER FINAL MEM
|
|
||||
0x05DE, //HEBREW LETTER MEM
|
|
||||
0x05DF, //HEBREW LETTER FINAL NUN
|
|
||||
0x05E0, //HEBREW LETTER NUN
|
|
||||
0x05E1, //HEBREW LETTER SAMEKH
|
|
||||
0x05E2, //HEBREW LETTER AYIN
|
|
||||
0x05E3, //HEBREW LETTER FINAL PE
|
|
||||
0x05E4, //HEBREW LETTER PE
|
|
||||
0x05E5, //HEBREW LETTER FINAL TSADI
|
|
||||
0x05E6, //HEBREW LETTER TSADI
|
|
||||
0x05E7, //HEBREW LETTER QOF
|
|
||||
0x05E8, //HEBREW LETTER RESH
|
|
||||
0x05E9, //HEBREW LETTER SHIN
|
|
||||
0x05EA, //HEBREW LETTER TAV
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x200E, //LEFT-TO-RIGHT MARK
|
|
||||
0x200F, //RIGHT-TO-LEFT MARK
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
}, |
|
||||
} |
|
@ -1,262 +0,0 @@ |
|||||
package cp |
|
||||
|
|
||||
var cp1256 *charsetMap = &charsetMap{ |
|
||||
sb: [256]rune{ |
|
||||
0x0000, //NULL
|
|
||||
0x0001, //START OF HEADING
|
|
||||
0x0002, //START OF TEXT
|
|
||||
0x0003, //END OF TEXT
|
|
||||
0x0004, //END OF TRANSMISSION
|
|
||||
0x0005, //ENQUIRY
|
|
||||
0x0006, //ACKNOWLEDGE
|
|
||||
0x0007, //BELL
|
|
||||
0x0008, //BACKSPACE
|
|
||||
0x0009, //HORIZONTAL TABULATION
|
|
||||
0x000A, //LINE FEED
|
|
||||
0x000B, //VERTICAL TABULATION
|
|
||||
0x000C, //FORM FEED
|
|
||||
0x000D, //CARRIAGE RETURN
|
|
||||
0x000E, //SHIFT OUT
|
|
||||
0x000F, //SHIFT IN
|
|
||||
0x0010, //DATA LINK ESCAPE
|
|
||||
0x0011, //DEVICE CONTROL ONE
|
|
||||
0x0012, //DEVICE CONTROL TWO
|
|
||||
0x0013, //DEVICE CONTROL THREE
|
|
||||
0x0014, //DEVICE CONTROL FOUR
|
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
|
||||
0x0016, //SYNCHRONOUS IDLE
|
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
|
||||
0x0018, //CANCEL
|
|
||||
0x0019, //END OF MEDIUM
|
|
||||
0x001A, //SUBSTITUTE
|
|
||||
0x001B, //ESCAPE
|
|
||||
0x001C, //FILE SEPARATOR
|
|
||||
0x001D, //GROUP SEPARATOR
|
|
||||
0x001E, //RECORD SEPARATOR
|
|
||||
0x001F, //UNIT SEPARATOR
|
|
||||
0x0020, //SPACE
|
|
||||
0x0021, //EXCLAMATION MARK
|
|
||||
0x0022, //QUOTATION MARK
|
|
||||
0x0023, //NUMBER SIGN
|
|
||||
0x0024, //DOLLAR SIGN
|
|
||||
0x0025, //PERCENT SIGN
|
|
||||
0x0026, //AMPERSAND
|
|
||||
0x0027, //APOSTROPHE
|
|
||||
0x0028, //LEFT PARENTHESIS
|
|
||||
0x0029, //RIGHT PARENTHESIS
|
|
||||
0x002A, //ASTERISK
|
|
||||
0x002B, //PLUS SIGN
|
|
||||
0x002C, //COMMA
|
|
||||
0x002D, //HYPHEN-MINUS
|
|
||||
0x002E, //FULL STOP
|
|
||||
0x002F, //SOLIDUS
|
|
||||
0x0030, //DIGIT ZERO
|
|
||||
0x0031, //DIGIT ONE
|
|
||||
0x0032, //DIGIT TWO
|
|
||||
0x0033, //DIGIT THREE
|
|
||||
0x0034, //DIGIT FOUR
|
|
||||
0x0035, //DIGIT FIVE
|
|
||||
0x0036, //DIGIT SIX
|
|
||||
0x0037, //DIGIT SEVEN
|
|
||||
0x0038, //DIGIT EIGHT
|
|
||||
0x0039, //DIGIT NINE
|
|
||||
0x003A, //COLON
|
|
||||
0x003B, //SEMICOLON
|
|
||||
0x003C, //LESS-THAN SIGN
|
|
||||
0x003D, //EQUALS SIGN
|
|
||||
0x003E, //GREATER-THAN SIGN
|
|
||||
0x003F, //QUESTION MARK
|
|
||||
0x0040, //COMMERCIAL AT
|
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
|
||||
0x004A, //LATIN CAPITAL LETTER J
|
|
||||
0x004B, //LATIN CAPITAL LETTER K
|
|
||||
0x004C, //LATIN CAPITAL LETTER L
|
|
||||
0x004D, //LATIN CAPITAL LETTER M
|
|
||||
0x004E, //LATIN CAPITAL LETTER N
|
|
||||
0x004F, //LATIN CAPITAL LETTER O
|
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
|
||||
0x005A, //LATIN CAPITAL LETTER Z
|
|
||||
0x005B, //LEFT SQUARE BRACKET
|
|
||||
0x005C, //REVERSE SOLIDUS
|
|
||||
0x005D, //RIGHT SQUARE BRACKET
|
|
||||
0x005E, //CIRCUMFLEX ACCENT
|
|
||||
0x005F, //LOW LINE
|
|
||||
0x0060, //GRAVE ACCENT
|
|
||||
0x0061, //LATIN SMALL LETTER A
|
|
||||
0x0062, //LATIN SMALL LETTER B
|
|
||||
0x0063, //LATIN SMALL LETTER C
|
|
||||
0x0064, //LATIN SMALL LETTER D
|
|
||||
0x0065, //LATIN SMALL LETTER E
|
|
||||
0x0066, //LATIN SMALL LETTER F
|
|
||||
0x0067, //LATIN SMALL LETTER G
|
|
||||
0x0068, //LATIN SMALL LETTER H
|
|
||||
0x0069, //LATIN SMALL LETTER I
|
|
||||
0x006A, //LATIN SMALL LETTER J
|
|
||||
0x006B, //LATIN SMALL LETTER K
|
|
||||
0x006C, //LATIN SMALL LETTER L
|
|
||||
0x006D, //LATIN SMALL LETTER M
|
|
||||
0x006E, //LATIN SMALL LETTER N
|
|
||||
0x006F, //LATIN SMALL LETTER O
|
|
||||
0x0070, //LATIN SMALL LETTER P
|
|
||||
0x0071, //LATIN SMALL LETTER Q
|
|
||||
0x0072, //LATIN SMALL LETTER R
|
|
||||
0x0073, //LATIN SMALL LETTER S
|
|
||||
0x0074, //LATIN SMALL LETTER T
|
|
||||
0x0075, //LATIN SMALL LETTER U
|
|
||||
0x0076, //LATIN SMALL LETTER V
|
|
||||
0x0077, //LATIN SMALL LETTER W
|
|
||||
0x0078, //LATIN SMALL LETTER X
|
|
||||
0x0079, //LATIN SMALL LETTER Y
|
|
||||
0x007A, //LATIN SMALL LETTER Z
|
|
||||
0x007B, //LEFT CURLY BRACKET
|
|
||||
0x007C, //VERTICAL LINE
|
|
||||
0x007D, //RIGHT CURLY BRACKET
|
|
||||
0x007E, //TILDE
|
|
||||
0x007F, //DELETE
|
|
||||
0x20AC, //EURO SIGN
|
|
||||
0x067E, //ARABIC LETTER PEH
|
|
||||
0x201A, //SINGLE LOW-9 QUOTATION MARK
|
|
||||
0x0192, //LATIN SMALL LETTER F WITH HOOK
|
|
||||
0x201E, //DOUBLE LOW-9 QUOTATION MARK
|
|
||||
0x2026, //HORIZONTAL ELLIPSIS
|
|
||||
0x2020, //DAGGER
|
|
||||
0x2021, //DOUBLE DAGGER
|
|
||||
0x02C6, //MODIFIER LETTER CIRCUMFLEX ACCENT
|
|
||||
0x2030, //PER MILLE SIGN
|
|
||||
0x0679, //ARABIC LETTER TTEH
|
|
||||
0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
|
||||
0x0152, //LATIN CAPITAL LIGATURE OE
|
|
||||
0x0686, //ARABIC LETTER TCHEH
|
|
||||
0x0698, //ARABIC LETTER JEH
|
|
||||
0x0688, //ARABIC LETTER DDAL
|
|
||||
0x06AF, //ARABIC LETTER GAF
|
|
||||
0x2018, //LEFT SINGLE QUOTATION MARK
|
|
||||
0x2019, //RIGHT SINGLE QUOTATION MARK
|
|
||||
0x201C, //LEFT DOUBLE QUOTATION MARK
|
|
||||
0x201D, //RIGHT DOUBLE QUOTATION MARK
|
|
||||
0x2022, //BULLET
|
|
||||
0x2013, //EN DASH
|
|
||||
0x2014, //EM DASH
|
|
||||
0x06A9, //ARABIC LETTER KEHEH
|
|
||||
0x2122, //TRADE MARK SIGN
|
|
||||
0x0691, //ARABIC LETTER RREH
|
|
||||
0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
|
||||
0x0153, //LATIN SMALL LIGATURE OE
|
|
||||
0x200C, //ZERO WIDTH NON-JOINER
|
|
||||
0x200D, //ZERO WIDTH JOINER
|
|
||||
0x06BA, //ARABIC LETTER NOON GHUNNA
|
|
||||
0x00A0, //NO-BREAK SPACE
|
|
||||
0x060C, //ARABIC COMMA
|
|
||||
0x00A2, //CENT SIGN
|
|
||||
0x00A3, //POUND SIGN
|
|
||||
0x00A4, //CURRENCY SIGN
|
|
||||
0x00A5, //YEN SIGN
|
|
||||
0x00A6, //BROKEN BAR
|
|
||||
0x00A7, //SECTION SIGN
|
|
||||
0x00A8, //DIAERESIS
|
|
||||
0x00A9, //COPYRIGHT SIGN
|
|
||||
0x06BE, //ARABIC LETTER HEH DOACHASHMEE
|
|
||||
0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x00AC, //NOT SIGN
|
|
||||
0x00AD, //SOFT HYPHEN
|
|
||||
0x00AE, //REGISTERED SIGN
|
|
||||
0x00AF, //MACRON
|
|
||||
0x00B0, //DEGREE SIGN
|
|
||||
0x00B1, //PLUS-MINUS SIGN
|
|
||||
0x00B2, //SUPERSCRIPT TWO
|
|
||||
0x00B3, //SUPERSCRIPT THREE
|
|
||||
0x00B4, //ACUTE ACCENT
|
|
||||
0x00B5, //MICRO SIGN
|
|
||||
0x00B6, //PILCROW SIGN
|
|
||||
0x00B7, //MIDDLE DOT
|
|
||||
0x00B8, //CEDILLA
|
|
||||
0x00B9, //SUPERSCRIPT ONE
|
|
||||
0x061B, //ARABIC SEMICOLON
|
|
||||
0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x00BC, //VULGAR FRACTION ONE QUARTER
|
|
||||
0x00BD, //VULGAR FRACTION ONE HALF
|
|
||||
0x00BE, //VULGAR FRACTION THREE QUARTERS
|
|
||||
0x061F, //ARABIC QUESTION MARK
|
|
||||
0x06C1, //ARABIC LETTER HEH GOAL
|
|
||||
0x0621, //ARABIC LETTER HAMZA
|
|
||||
0x0622, //ARABIC LETTER ALEF WITH MADDA ABOVE
|
|
||||
0x0623, //ARABIC LETTER ALEF WITH HAMZA ABOVE
|
|
||||
0x0624, //ARABIC LETTER WAW WITH HAMZA ABOVE
|
|
||||
0x0625, //ARABIC LETTER ALEF WITH HAMZA BELOW
|
|
||||
0x0626, //ARABIC LETTER YEH WITH HAMZA ABOVE
|
|
||||
0x0627, //ARABIC LETTER ALEF
|
|
||||
0x0628, //ARABIC LETTER BEH
|
|
||||
0x0629, //ARABIC LETTER TEH MARBUTA
|
|
||||
0x062A, //ARABIC LETTER TEH
|
|
||||
0x062B, //ARABIC LETTER THEH
|
|
||||
0x062C, //ARABIC LETTER JEEM
|
|
||||
0x062D, //ARABIC LETTER HAH
|
|
||||
0x062E, //ARABIC LETTER KHAH
|
|
||||
0x062F, //ARABIC LETTER DAL
|
|
||||
0x0630, //ARABIC LETTER THAL
|
|
||||
0x0631, //ARABIC LETTER REH
|
|
||||
0x0632, //ARABIC LETTER ZAIN
|
|
||||
0x0633, //ARABIC LETTER SEEN
|
|
||||
0x0634, //ARABIC LETTER SHEEN
|
|
||||
0x0635, //ARABIC LETTER SAD
|
|
||||
0x0636, //ARABIC LETTER DAD
|
|
||||
0x00D7, //MULTIPLICATION SIGN
|
|
||||
0x0637, //ARABIC LETTER TAH
|
|
||||
0x0638, //ARABIC LETTER ZAH
|
|
||||
0x0639, //ARABIC LETTER AIN
|
|
||||
0x063A, //ARABIC LETTER GHAIN
|
|
||||
0x0640, //ARABIC TATWEEL
|
|
||||
0x0641, //ARABIC LETTER FEH
|
|
||||
0x0642, //ARABIC LETTER QAF
|
|
||||
0x0643, //ARABIC LETTER KAF
|
|
||||
0x00E0, //LATIN SMALL LETTER A WITH GRAVE
|
|
||||
0x0644, //ARABIC LETTER LAM
|
|
||||
0x00E2, //LATIN SMALL LETTER A WITH CIRCUMFLEX
|
|
||||
0x0645, //ARABIC LETTER MEEM
|
|
||||
0x0646, //ARABIC LETTER NOON
|
|
||||
0x0647, //ARABIC LETTER HEH
|
|
||||
0x0648, //ARABIC LETTER WAW
|
|
||||
0x00E7, //LATIN SMALL LETTER C WITH CEDILLA
|
|
||||
0x00E8, //LATIN SMALL LETTER E WITH GRAVE
|
|
||||
0x00E9, //LATIN SMALL LETTER E WITH ACUTE
|
|
||||
0x00EA, //LATIN SMALL LETTER E WITH CIRCUMFLEX
|
|
||||
0x00EB, //LATIN SMALL LETTER E WITH DIAERESIS
|
|
||||
0x0649, //ARABIC LETTER ALEF MAKSURA
|
|
||||
0x064A, //ARABIC LETTER YEH
|
|
||||
0x00EE, //LATIN SMALL LETTER I WITH CIRCUMFLEX
|
|
||||
0x00EF, //LATIN SMALL LETTER I WITH DIAERESIS
|
|
||||
0x064B, //ARABIC FATHATAN
|
|
||||
0x064C, //ARABIC DAMMATAN
|
|
||||
0x064D, //ARABIC KASRATAN
|
|
||||
0x064E, //ARABIC FATHA
|
|
||||
0x00F4, //LATIN SMALL LETTER O WITH CIRCUMFLEX
|
|
||||
0x064F, //ARABIC DAMMA
|
|
||||
0x0650, //ARABIC KASRA
|
|
||||
0x00F7, //DIVISION SIGN
|
|
||||
0x0651, //ARABIC SHADDA
|
|
||||
0x00F9, //LATIN SMALL LETTER U WITH GRAVE
|
|
||||
0x0652, //ARABIC SUKUN
|
|
||||
0x00FB, //LATIN SMALL LETTER U WITH CIRCUMFLEX
|
|
||||
0x00FC, //LATIN SMALL LETTER U WITH DIAERESIS
|
|
||||
0x200E, //LEFT-TO-RIGHT MARK
|
|
||||
0x200F, //RIGHT-TO-LEFT MARK
|
|
||||
0x06D2, //ARABIC LETTER YEH BARREE
|
|
||||
}, |
|
||||
} |
|
@ -1,262 +0,0 @@ |
|||||
package cp |
|
||||
|
|
||||
var cp1257 *charsetMap = &charsetMap{ |
|
||||
sb: [256]rune{ |
|
||||
0x0000, //NULL
|
|
||||
0x0001, //START OF HEADING
|
|
||||
0x0002, //START OF TEXT
|
|
||||
0x0003, //END OF TEXT
|
|
||||
0x0004, //END OF TRANSMISSION
|
|
||||
0x0005, //ENQUIRY
|
|
||||
0x0006, //ACKNOWLEDGE
|
|
||||
0x0007, //BELL
|
|
||||
0x0008, //BACKSPACE
|
|
||||
0x0009, //HORIZONTAL TABULATION
|
|
||||
0x000A, //LINE FEED
|
|
||||
0x000B, //VERTICAL TABULATION
|
|
||||
0x000C, //FORM FEED
|
|
||||
0x000D, //CARRIAGE RETURN
|
|
||||
0x000E, //SHIFT OUT
|
|
||||
0x000F, //SHIFT IN
|
|
||||
0x0010, //DATA LINK ESCAPE
|
|
||||
0x0011, //DEVICE CONTROL ONE
|
|
||||
0x0012, //DEVICE CONTROL TWO
|
|
||||
0x0013, //DEVICE CONTROL THREE
|
|
||||
0x0014, //DEVICE CONTROL FOUR
|
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
|
||||
0x0016, //SYNCHRONOUS IDLE
|
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
|
||||
0x0018, //CANCEL
|
|
||||
0x0019, //END OF MEDIUM
|
|
||||
0x001A, //SUBSTITUTE
|
|
||||
0x001B, //ESCAPE
|
|
||||
0x001C, //FILE SEPARATOR
|
|
||||
0x001D, //GROUP SEPARATOR
|
|
||||
0x001E, //RECORD SEPARATOR
|
|
||||
0x001F, //UNIT SEPARATOR
|
|
||||
0x0020, //SPACE
|
|
||||
0x0021, //EXCLAMATION MARK
|
|
||||
0x0022, //QUOTATION MARK
|
|
||||
0x0023, //NUMBER SIGN
|
|
||||
0x0024, //DOLLAR SIGN
|
|
||||
0x0025, //PERCENT SIGN
|
|
||||
0x0026, //AMPERSAND
|
|
||||
0x0027, //APOSTROPHE
|
|
||||
0x0028, //LEFT PARENTHESIS
|
|
||||
0x0029, //RIGHT PARENTHESIS
|
|
||||
0x002A, //ASTERISK
|
|
||||
0x002B, //PLUS SIGN
|
|
||||
0x002C, //COMMA
|
|
||||
0x002D, //HYPHEN-MINUS
|
|
||||
0x002E, //FULL STOP
|
|
||||
0x002F, //SOLIDUS
|
|
||||
0x0030, //DIGIT ZERO
|
|
||||
0x0031, //DIGIT ONE
|
|
||||
0x0032, //DIGIT TWO
|
|
||||
0x0033, //DIGIT THREE
|
|
||||
0x0034, //DIGIT FOUR
|
|
||||
0x0035, //DIGIT FIVE
|
|
||||
0x0036, //DIGIT SIX
|
|
||||
0x0037, //DIGIT SEVEN
|
|
||||
0x0038, //DIGIT EIGHT
|
|
||||
0x0039, //DIGIT NINE
|
|
||||
0x003A, //COLON
|
|
||||
0x003B, //SEMICOLON
|
|
||||
0x003C, //LESS-THAN SIGN
|
|
||||
0x003D, //EQUALS SIGN
|
|
||||
0x003E, //GREATER-THAN SIGN
|
|
||||
0x003F, //QUESTION MARK
|
|
||||
0x0040, //COMMERCIAL AT
|
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
|
||||
0x004A, //LATIN CAPITAL LETTER J
|
|
||||
0x004B, //LATIN CAPITAL LETTER K
|
|
||||
0x004C, //LATIN CAPITAL LETTER L
|
|
||||
0x004D, //LATIN CAPITAL LETTER M
|
|
||||
0x004E, //LATIN CAPITAL LETTER N
|
|
||||
0x004F, //LATIN CAPITAL LETTER O
|
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
|
||||
0x005A, //LATIN CAPITAL LETTER Z
|
|
||||
0x005B, //LEFT SQUARE BRACKET
|
|
||||
0x005C, //REVERSE SOLIDUS
|
|
||||
0x005D, //RIGHT SQUARE BRACKET
|
|
||||
0x005E, //CIRCUMFLEX ACCENT
|
|
||||
0x005F, //LOW LINE
|
|
||||
0x0060, //GRAVE ACCENT
|
|
||||
0x0061, //LATIN SMALL LETTER A
|
|
||||
0x0062, //LATIN SMALL LETTER B
|
|
||||
0x0063, //LATIN SMALL LETTER C
|
|
||||
0x0064, //LATIN SMALL LETTER D
|
|
||||
0x0065, //LATIN SMALL LETTER E
|
|
||||
0x0066, //LATIN SMALL LETTER F
|
|
||||
0x0067, //LATIN SMALL LETTER G
|
|
||||
0x0068, //LATIN SMALL LETTER H
|
|
||||
0x0069, //LATIN SMALL LETTER I
|
|
||||
0x006A, //LATIN SMALL LETTER J
|
|
||||
0x006B, //LATIN SMALL LETTER K
|
|
||||
0x006C, //LATIN SMALL LETTER L
|
|
||||
0x006D, //LATIN SMALL LETTER M
|
|
||||
0x006E, //LATIN SMALL LETTER N
|
|
||||
0x006F, //LATIN SMALL LETTER O
|
|
||||
0x0070, //LATIN SMALL LETTER P
|
|
||||
0x0071, //LATIN SMALL LETTER Q
|
|
||||
0x0072, //LATIN SMALL LETTER R
|
|
||||
0x0073, //LATIN SMALL LETTER S
|
|
||||
0x0074, //LATIN SMALL LETTER T
|
|
||||
0x0075, //LATIN SMALL LETTER U
|
|
||||
0x0076, //LATIN SMALL LETTER V
|
|
||||
0x0077, //LATIN SMALL LETTER W
|
|
||||
0x0078, //LATIN SMALL LETTER X
|
|
||||
0x0079, //LATIN SMALL LETTER Y
|
|
||||
0x007A, //LATIN SMALL LETTER Z
|
|
||||
0x007B, //LEFT CURLY BRACKET
|
|
||||
0x007C, //VERTICAL LINE
|
|
||||
0x007D, //RIGHT CURLY BRACKET
|
|
||||
0x007E, //TILDE
|
|
||||
0x007F, //DELETE
|
|
||||
0x20AC, //EURO SIGN
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x201A, //SINGLE LOW-9 QUOTATION MARK
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x201E, //DOUBLE LOW-9 QUOTATION MARK
|
|
||||
0x2026, //HORIZONTAL ELLIPSIS
|
|
||||
0x2020, //DAGGER
|
|
||||
0x2021, //DOUBLE DAGGER
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x2030, //PER MILLE SIGN
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x00A8, //DIAERESIS
|
|
||||
0x02C7, //CARON
|
|
||||
0x00B8, //CEDILLA
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x2018, //LEFT SINGLE QUOTATION MARK
|
|
||||
0x2019, //RIGHT SINGLE QUOTATION MARK
|
|
||||
0x201C, //LEFT DOUBLE QUOTATION MARK
|
|
||||
0x201D, //RIGHT DOUBLE QUOTATION MARK
|
|
||||
0x2022, //BULLET
|
|
||||
0x2013, //EN DASH
|
|
||||
0x2014, //EM DASH
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x2122, //TRADE MARK SIGN
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x00AF, //MACRON
|
|
||||
0x02DB, //OGONEK
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x00A0, //NO-BREAK SPACE
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x00A2, //CENT SIGN
|
|
||||
0x00A3, //POUND SIGN
|
|
||||
0x00A4, //CURRENCY SIGN
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x00A6, //BROKEN BAR
|
|
||||
0x00A7, //SECTION SIGN
|
|
||||
0x00D8, //LATIN CAPITAL LETTER O WITH STROKE
|
|
||||
0x00A9, //COPYRIGHT SIGN
|
|
||||
0x0156, //LATIN CAPITAL LETTER R WITH CEDILLA
|
|
||||
0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x00AC, //NOT SIGN
|
|
||||
0x00AD, //SOFT HYPHEN
|
|
||||
0x00AE, //REGISTERED SIGN
|
|
||||
0x00C6, //LATIN CAPITAL LETTER AE
|
|
||||
0x00B0, //DEGREE SIGN
|
|
||||
0x00B1, //PLUS-MINUS SIGN
|
|
||||
0x00B2, //SUPERSCRIPT TWO
|
|
||||
0x00B3, //SUPERSCRIPT THREE
|
|
||||
0x00B4, //ACUTE ACCENT
|
|
||||
0x00B5, //MICRO SIGN
|
|
||||
0x00B6, //PILCROW SIGN
|
|
||||
0x00B7, //MIDDLE DOT
|
|
||||
0x00F8, //LATIN SMALL LETTER O WITH STROKE
|
|
||||
0x00B9, //SUPERSCRIPT ONE
|
|
||||
0x0157, //LATIN SMALL LETTER R WITH CEDILLA
|
|
||||
0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x00BC, //VULGAR FRACTION ONE QUARTER
|
|
||||
0x00BD, //VULGAR FRACTION ONE HALF
|
|
||||
0x00BE, //VULGAR FRACTION THREE QUARTERS
|
|
||||
0x00E6, //LATIN SMALL LETTER AE
|
|
||||
0x0104, //LATIN CAPITAL LETTER A WITH OGONEK
|
|
||||
0x012E, //LATIN CAPITAL LETTER I WITH OGONEK
|
|
||||
0x0100, //LATIN CAPITAL LETTER A WITH MACRON
|
|
||||
0x0106, //LATIN CAPITAL LETTER C WITH ACUTE
|
|
||||
0x00C4, //LATIN CAPITAL LETTER A WITH DIAERESIS
|
|
||||
0x00C5, //LATIN CAPITAL LETTER A WITH RING ABOVE
|
|
||||
0x0118, //LATIN CAPITAL LETTER E WITH OGONEK
|
|
||||
0x0112, //LATIN CAPITAL LETTER E WITH MACRON
|
|
||||
0x010C, //LATIN CAPITAL LETTER C WITH CARON
|
|
||||
0x00C9, //LATIN CAPITAL LETTER E WITH ACUTE
|
|
||||
0x0179, //LATIN CAPITAL LETTER Z WITH ACUTE
|
|
||||
0x0116, //LATIN CAPITAL LETTER E WITH DOT ABOVE
|
|
||||
0x0122, //LATIN CAPITAL LETTER G WITH CEDILLA
|
|
||||
0x0136, //LATIN CAPITAL LETTER K WITH CEDILLA
|
|
||||
0x012A, //LATIN CAPITAL LETTER I WITH MACRON
|
|
||||
0x013B, //LATIN CAPITAL LETTER L WITH CEDILLA
|
|
||||
0x0160, //LATIN CAPITAL LETTER S WITH CARON
|
|
||||
0x0143, //LATIN CAPITAL LETTER N WITH ACUTE
|
|
||||
0x0145, //LATIN CAPITAL LETTER N WITH CEDILLA
|
|
||||
0x00D3, //LATIN CAPITAL LETTER O WITH ACUTE
|
|
||||
0x014C, //LATIN CAPITAL LETTER O WITH MACRON
|
|
||||
0x00D5, //LATIN CAPITAL LETTER O WITH TILDE
|
|
||||
0x00D6, //LATIN CAPITAL LETTER O WITH DIAERESIS
|
|
||||
0x00D7, //MULTIPLICATION SIGN
|
|
||||
0x0172, //LATIN CAPITAL LETTER U WITH OGONEK
|
|
||||
0x0141, //LATIN CAPITAL LETTER L WITH STROKE
|
|
||||
0x015A, //LATIN CAPITAL LETTER S WITH ACUTE
|
|
||||
0x016A, //LATIN CAPITAL LETTER U WITH MACRON
|
|
||||
0x00DC, //LATIN CAPITAL LETTER U WITH DIAERESIS
|
|
||||
0x017B, //LATIN CAPITAL LETTER Z WITH DOT ABOVE
|
|
||||
0x017D, //LATIN CAPITAL LETTER Z WITH CARON
|
|
||||
0x00DF, //LATIN SMALL LETTER SHARP S
|
|
||||
0x0105, //LATIN SMALL LETTER A WITH OGONEK
|
|
||||
0x012F, //LATIN SMALL LETTER I WITH OGONEK
|
|
||||
0x0101, //LATIN SMALL LETTER A WITH MACRON
|
|
||||
0x0107, //LATIN SMALL LETTER C WITH ACUTE
|
|
||||
0x00E4, //LATIN SMALL LETTER A WITH DIAERESIS
|
|
||||
0x00E5, //LATIN SMALL LETTER A WITH RING ABOVE
|
|
||||
0x0119, //LATIN SMALL LETTER E WITH OGONEK
|
|
||||
0x0113, //LATIN SMALL LETTER E WITH MACRON
|
|
||||
0x010D, //LATIN SMALL LETTER C WITH CARON
|
|
||||
0x00E9, //LATIN SMALL LETTER E WITH ACUTE
|
|
||||
0x017A, //LATIN SMALL LETTER Z WITH ACUTE
|
|
||||
0x0117, //LATIN SMALL LETTER E WITH DOT ABOVE
|
|
||||
0x0123, //LATIN SMALL LETTER G WITH CEDILLA
|
|
||||
0x0137, //LATIN SMALL LETTER K WITH CEDILLA
|
|
||||
0x012B, //LATIN SMALL LETTER I WITH MACRON
|
|
||||
0x013C, //LATIN SMALL LETTER L WITH CEDILLA
|
|
||||
0x0161, //LATIN SMALL LETTER S WITH CARON
|
|
||||
0x0144, //LATIN SMALL LETTER N WITH ACUTE
|
|
||||
0x0146, //LATIN SMALL LETTER N WITH CEDILLA
|
|
||||
0x00F3, //LATIN SMALL LETTER O WITH ACUTE
|
|
||||
0x014D, //LATIN SMALL LETTER O WITH MACRON
|
|
||||
0x00F5, //LATIN SMALL LETTER O WITH TILDE
|
|
||||
0x00F6, //LATIN SMALL LETTER O WITH DIAERESIS
|
|
||||
0x00F7, //DIVISION SIGN
|
|
||||
0x0173, //LATIN SMALL LETTER U WITH OGONEK
|
|
||||
0x0142, //LATIN SMALL LETTER L WITH STROKE
|
|
||||
0x015B, //LATIN SMALL LETTER S WITH ACUTE
|
|
||||
0x016B, //LATIN SMALL LETTER U WITH MACRON
|
|
||||
0x00FC, //LATIN SMALL LETTER U WITH DIAERESIS
|
|
||||
0x017C, //LATIN SMALL LETTER Z WITH DOT ABOVE
|
|
||||
0x017E, //LATIN SMALL LETTER Z WITH CARON
|
|
||||
0x02D9, //DOT ABOVE
|
|
||||
}, |
|
||||
} |
|
@ -1,262 +0,0 @@ |
|||||
package cp |
|
||||
|
|
||||
var cp1258 *charsetMap = &charsetMap{ |
|
||||
sb: [256]rune{ |
|
||||
0x0000, //NULL
|
|
||||
0x0001, //START OF HEADING
|
|
||||
0x0002, //START OF TEXT
|
|
||||
0x0003, //END OF TEXT
|
|
||||
0x0004, //END OF TRANSMISSION
|
|
||||
0x0005, //ENQUIRY
|
|
||||
0x0006, //ACKNOWLEDGE
|
|
||||
0x0007, //BELL
|
|
||||
0x0008, //BACKSPACE
|
|
||||
0x0009, //HORIZONTAL TABULATION
|
|
||||
0x000A, //LINE FEED
|
|
||||
0x000B, //VERTICAL TABULATION
|
|
||||
0x000C, //FORM FEED
|
|
||||
0x000D, //CARRIAGE RETURN
|
|
||||
0x000E, //SHIFT OUT
|
|
||||
0x000F, //SHIFT IN
|
|
||||
0x0010, //DATA LINK ESCAPE
|
|
||||
0x0011, //DEVICE CONTROL ONE
|
|
||||
0x0012, //DEVICE CONTROL TWO
|
|
||||
0x0013, //DEVICE CONTROL THREE
|
|
||||
0x0014, //DEVICE CONTROL FOUR
|
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
|
||||
0x0016, //SYNCHRONOUS IDLE
|
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
|
||||
0x0018, //CANCEL
|
|
||||
0x0019, //END OF MEDIUM
|
|
||||
0x001A, //SUBSTITUTE
|
|
||||
0x001B, //ESCAPE
|
|
||||
0x001C, //FILE SEPARATOR
|
|
||||
0x001D, //GROUP SEPARATOR
|
|
||||
0x001E, //RECORD SEPARATOR
|
|
||||
0x001F, //UNIT SEPARATOR
|
|
||||
0x0020, //SPACE
|
|
||||
0x0021, //EXCLAMATION MARK
|
|
||||
0x0022, //QUOTATION MARK
|
|
||||
0x0023, //NUMBER SIGN
|
|
||||
0x0024, //DOLLAR SIGN
|
|
||||
0x0025, //PERCENT SIGN
|
|
||||
0x0026, //AMPERSAND
|
|
||||
0x0027, //APOSTROPHE
|
|
||||
0x0028, //LEFT PARENTHESIS
|
|
||||
0x0029, //RIGHT PARENTHESIS
|
|
||||
0x002A, //ASTERISK
|
|
||||
0x002B, //PLUS SIGN
|
|
||||
0x002C, //COMMA
|
|
||||
0x002D, //HYPHEN-MINUS
|
|
||||
0x002E, //FULL STOP
|
|
||||
0x002F, //SOLIDUS
|
|
||||
0x0030, //DIGIT ZERO
|
|
||||
0x0031, //DIGIT ONE
|
|
||||
0x0032, //DIGIT TWO
|
|
||||
0x0033, //DIGIT THREE
|
|
||||
0x0034, //DIGIT FOUR
|
|
||||
0x0035, //DIGIT FIVE
|
|
||||
0x0036, //DIGIT SIX
|
|
||||
0x0037, //DIGIT SEVEN
|
|
||||
0x0038, //DIGIT EIGHT
|
|
||||
0x0039, //DIGIT NINE
|
|
||||
0x003A, //COLON
|
|
||||
0x003B, //SEMICOLON
|
|
||||
0x003C, //LESS-THAN SIGN
|
|
||||
0x003D, //EQUALS SIGN
|
|
||||
0x003E, //GREATER-THAN SIGN
|
|
||||
0x003F, //QUESTION MARK
|
|
||||
0x0040, //COMMERCIAL AT
|
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
|
||||
0x004A, //LATIN CAPITAL LETTER J
|
|
||||
0x004B, //LATIN CAPITAL LETTER K
|
|
||||
0x004C, //LATIN CAPITAL LETTER L
|
|
||||
0x004D, //LATIN CAPITAL LETTER M
|
|
||||
0x004E, //LATIN CAPITAL LETTER N
|
|
||||
0x004F, //LATIN CAPITAL LETTER O
|
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
|
||||
0x005A, //LATIN CAPITAL LETTER Z
|
|
||||
0x005B, //LEFT SQUARE BRACKET
|
|
||||
0x005C, //REVERSE SOLIDUS
|
|
||||
0x005D, //RIGHT SQUARE BRACKET
|
|
||||
0x005E, //CIRCUMFLEX ACCENT
|
|
||||
0x005F, //LOW LINE
|
|
||||
0x0060, //GRAVE ACCENT
|
|
||||
0x0061, //LATIN SMALL LETTER A
|
|
||||
0x0062, //LATIN SMALL LETTER B
|
|
||||
0x0063, //LATIN SMALL LETTER C
|
|
||||
0x0064, //LATIN SMALL LETTER D
|
|
||||
0x0065, //LATIN SMALL LETTER E
|
|
||||
0x0066, //LATIN SMALL LETTER F
|
|
||||
0x0067, //LATIN SMALL LETTER G
|
|
||||
0x0068, //LATIN SMALL LETTER H
|
|
||||
0x0069, //LATIN SMALL LETTER I
|
|
||||
0x006A, //LATIN SMALL LETTER J
|
|
||||
0x006B, //LATIN SMALL LETTER K
|
|
||||
0x006C, //LATIN SMALL LETTER L
|
|
||||
0x006D, //LATIN SMALL LETTER M
|
|
||||
0x006E, //LATIN SMALL LETTER N
|
|
||||
0x006F, //LATIN SMALL LETTER O
|
|
||||
0x0070, //LATIN SMALL LETTER P
|
|
||||
0x0071, //LATIN SMALL LETTER Q
|
|
||||
0x0072, //LATIN SMALL LETTER R
|
|
||||
0x0073, //LATIN SMALL LETTER S
|
|
||||
0x0074, //LATIN SMALL LETTER T
|
|
||||
0x0075, //LATIN SMALL LETTER U
|
|
||||
0x0076, //LATIN SMALL LETTER V
|
|
||||
0x0077, //LATIN SMALL LETTER W
|
|
||||
0x0078, //LATIN SMALL LETTER X
|
|
||||
0x0079, //LATIN SMALL LETTER Y
|
|
||||
0x007A, //LATIN SMALL LETTER Z
|
|
||||
0x007B, //LEFT CURLY BRACKET
|
|
||||
0x007C, //VERTICAL LINE
|
|
||||
0x007D, //RIGHT CURLY BRACKET
|
|
||||
0x007E, //TILDE
|
|
||||
0x007F, //DELETE
|
|
||||
0x20AC, //EURO SIGN
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x201A, //SINGLE LOW-9 QUOTATION MARK
|
|
||||
0x0192, //LATIN SMALL LETTER F WITH HOOK
|
|
||||
0x201E, //DOUBLE LOW-9 QUOTATION MARK
|
|
||||
0x2026, //HORIZONTAL ELLIPSIS
|
|
||||
0x2020, //DAGGER
|
|
||||
0x2021, //DOUBLE DAGGER
|
|
||||
0x02C6, //MODIFIER LETTER CIRCUMFLEX ACCENT
|
|
||||
0x2030, //PER MILLE SIGN
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
|
||||
0x0152, //LATIN CAPITAL LIGATURE OE
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x2018, //LEFT SINGLE QUOTATION MARK
|
|
||||
0x2019, //RIGHT SINGLE QUOTATION MARK
|
|
||||
0x201C, //LEFT DOUBLE QUOTATION MARK
|
|
||||
0x201D, //RIGHT DOUBLE QUOTATION MARK
|
|
||||
0x2022, //BULLET
|
|
||||
0x2013, //EN DASH
|
|
||||
0x2014, //EM DASH
|
|
||||
0x02DC, //SMALL TILDE
|
|
||||
0x2122, //TRADE MARK SIGN
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
|
||||
0x0153, //LATIN SMALL LIGATURE OE
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x0178, //LATIN CAPITAL LETTER Y WITH DIAERESIS
|
|
||||
0x00A0, //NO-BREAK SPACE
|
|
||||
0x00A1, //INVERTED EXCLAMATION MARK
|
|
||||
0x00A2, //CENT SIGN
|
|
||||
0x00A3, //POUND SIGN
|
|
||||
0x00A4, //CURRENCY SIGN
|
|
||||
0x00A5, //YEN SIGN
|
|
||||
0x00A6, //BROKEN BAR
|
|
||||
0x00A7, //SECTION SIGN
|
|
||||
0x00A8, //DIAERESIS
|
|
||||
0x00A9, //COPYRIGHT SIGN
|
|
||||
0x00AA, //FEMININE ORDINAL INDICATOR
|
|
||||
0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x00AC, //NOT SIGN
|
|
||||
0x00AD, //SOFT HYPHEN
|
|
||||
0x00AE, //REGISTERED SIGN
|
|
||||
0x00AF, //MACRON
|
|
||||
0x00B0, //DEGREE SIGN
|
|
||||
0x00B1, //PLUS-MINUS SIGN
|
|
||||
0x00B2, //SUPERSCRIPT TWO
|
|
||||
0x00B3, //SUPERSCRIPT THREE
|
|
||||
0x00B4, //ACUTE ACCENT
|
|
||||
0x00B5, //MICRO SIGN
|
|
||||
0x00B6, //PILCROW SIGN
|
|
||||
0x00B7, //MIDDLE DOT
|
|
||||
0x00B8, //CEDILLA
|
|
||||
0x00B9, //SUPERSCRIPT ONE
|
|
||||
0x00BA, //MASCULINE ORDINAL INDICATOR
|
|
||||
0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x00BC, //VULGAR FRACTION ONE QUARTER
|
|
||||
0x00BD, //VULGAR FRACTION ONE HALF
|
|
||||
0x00BE, //VULGAR FRACTION THREE QUARTERS
|
|
||||
0x00BF, //INVERTED QUESTION MARK
|
|
||||
0x00C0, //LATIN CAPITAL LETTER A WITH GRAVE
|
|
||||
0x00C1, //LATIN CAPITAL LETTER A WITH ACUTE
|
|
||||
0x00C2, //LATIN CAPITAL LETTER A WITH CIRCUMFLEX
|
|
||||
0x0102, //LATIN CAPITAL LETTER A WITH BREVE
|
|
||||
0x00C4, //LATIN CAPITAL LETTER A WITH DIAERESIS
|
|
||||
0x00C5, //LATIN CAPITAL LETTER A WITH RING ABOVE
|
|
||||
0x00C6, //LATIN CAPITAL LETTER AE
|
|
||||
0x00C7, //LATIN CAPITAL LETTER C WITH CEDILLA
|
|
||||
0x00C8, //LATIN CAPITAL LETTER E WITH GRAVE
|
|
||||
0x00C9, //LATIN CAPITAL LETTER E WITH ACUTE
|
|
||||
0x00CA, //LATIN CAPITAL LETTER E WITH CIRCUMFLEX
|
|
||||
0x00CB, //LATIN CAPITAL LETTER E WITH DIAERESIS
|
|
||||
0x0300, //COMBINING GRAVE ACCENT
|
|
||||
0x00CD, //LATIN CAPITAL LETTER I WITH ACUTE
|
|
||||
0x00CE, //LATIN CAPITAL LETTER I WITH CIRCUMFLEX
|
|
||||
0x00CF, //LATIN CAPITAL LETTER I WITH DIAERESIS
|
|
||||
0x0110, //LATIN CAPITAL LETTER D WITH STROKE
|
|
||||
0x00D1, //LATIN CAPITAL LETTER N WITH TILDE
|
|
||||
0x0309, //COMBINING HOOK ABOVE
|
|
||||
0x00D3, //LATIN CAPITAL LETTER O WITH ACUTE
|
|
||||
0x00D4, //LATIN CAPITAL LETTER O WITH CIRCUMFLEX
|
|
||||
0x01A0, //LATIN CAPITAL LETTER O WITH HORN
|
|
||||
0x00D6, //LATIN CAPITAL LETTER O WITH DIAERESIS
|
|
||||
0x00D7, //MULTIPLICATION SIGN
|
|
||||
0x00D8, //LATIN CAPITAL LETTER O WITH STROKE
|
|
||||
0x00D9, //LATIN CAPITAL LETTER U WITH GRAVE
|
|
||||
0x00DA, //LATIN CAPITAL LETTER U WITH ACUTE
|
|
||||
0x00DB, //LATIN CAPITAL LETTER U WITH CIRCUMFLEX
|
|
||||
0x00DC, //LATIN CAPITAL LETTER U WITH DIAERESIS
|
|
||||
0x01AF, //LATIN CAPITAL LETTER U WITH HORN
|
|
||||
0x0303, //COMBINING TILDE
|
|
||||
0x00DF, //LATIN SMALL LETTER SHARP S
|
|
||||
0x00E0, //LATIN SMALL LETTER A WITH GRAVE
|
|
||||
0x00E1, //LATIN SMALL LETTER A WITH ACUTE
|
|
||||
0x00E2, //LATIN SMALL LETTER A WITH CIRCUMFLEX
|
|
||||
0x0103, //LATIN SMALL LETTER A WITH BREVE
|
|
||||
0x00E4, //LATIN SMALL LETTER A WITH DIAERESIS
|
|
||||
0x00E5, //LATIN SMALL LETTER A WITH RING ABOVE
|
|
||||
0x00E6, //LATIN SMALL LETTER AE
|
|
||||
0x00E7, //LATIN SMALL LETTER C WITH CEDILLA
|
|
||||
0x00E8, //LATIN SMALL LETTER E WITH GRAVE
|
|
||||
0x00E9, //LATIN SMALL LETTER E WITH ACUTE
|
|
||||
0x00EA, //LATIN SMALL LETTER E WITH CIRCUMFLEX
|
|
||||
0x00EB, //LATIN SMALL LETTER E WITH DIAERESIS
|
|
||||
0x0301, //COMBINING ACUTE ACCENT
|
|
||||
0x00ED, //LATIN SMALL LETTER I WITH ACUTE
|
|
||||
0x00EE, //LATIN SMALL LETTER I WITH CIRCUMFLEX
|
|
||||
0x00EF, //LATIN SMALL LETTER I WITH DIAERESIS
|
|
||||
0x0111, //LATIN SMALL LETTER D WITH STROKE
|
|
||||
0x00F1, //LATIN SMALL LETTER N WITH TILDE
|
|
||||
0x0323, //COMBINING DOT BELOW
|
|
||||
0x00F3, //LATIN SMALL LETTER O WITH ACUTE
|
|
||||
0x00F4, //LATIN SMALL LETTER O WITH CIRCUMFLEX
|
|
||||
0x01A1, //LATIN SMALL LETTER O WITH HORN
|
|
||||
0x00F6, //LATIN SMALL LETTER O WITH DIAERESIS
|
|
||||
0x00F7, //DIVISION SIGN
|
|
||||
0x00F8, //LATIN SMALL LETTER O WITH STROKE
|
|
||||
0x00F9, //LATIN SMALL LETTER U WITH GRAVE
|
|
||||
0x00FA, //LATIN SMALL LETTER U WITH ACUTE
|
|
||||
0x00FB, //LATIN SMALL LETTER U WITH CIRCUMFLEX
|
|
||||
0x00FC, //LATIN SMALL LETTER U WITH DIAERESIS
|
|
||||
0x01B0, //LATIN SMALL LETTER U WITH HORN
|
|
||||
0x20AB, //DONG SIGN
|
|
||||
0x00FF, //LATIN SMALL LETTER Y WITH DIAERESIS
|
|
||||
}, |
|
||||
} |
|
@ -1,262 +0,0 @@ |
|||||
package cp |
|
||||
|
|
||||
var cp437 *charsetMap = &charsetMap{ |
|
||||
sb: [256]rune{ |
|
||||
0x0000, //NULL
|
|
||||
0x0001, //START OF HEADING
|
|
||||
0x0002, //START OF TEXT
|
|
||||
0x0003, //END OF TEXT
|
|
||||
0x0004, //END OF TRANSMISSION
|
|
||||
0x0005, //ENQUIRY
|
|
||||
0x0006, //ACKNOWLEDGE
|
|
||||
0x0007, //BELL
|
|
||||
0x0008, //BACKSPACE
|
|
||||
0x0009, //HORIZONTAL TABULATION
|
|
||||
0x000a, //LINE FEED
|
|
||||
0x000b, //VERTICAL TABULATION
|
|
||||
0x000c, //FORM FEED
|
|
||||
0x000d, //CARRIAGE RETURN
|
|
||||
0x000e, //SHIFT OUT
|
|
||||
0x000f, //SHIFT IN
|
|
||||
0x0010, //DATA LINK ESCAPE
|
|
||||
0x0011, //DEVICE CONTROL ONE
|
|
||||
0x0012, //DEVICE CONTROL TWO
|
|
||||
0x0013, //DEVICE CONTROL THREE
|
|
||||
0x0014, //DEVICE CONTROL FOUR
|
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
|
||||
0x0016, //SYNCHRONOUS IDLE
|
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
|
||||
0x0018, //CANCEL
|
|
||||
0x0019, //END OF MEDIUM
|
|
||||
0x001a, //SUBSTITUTE
|
|
||||
0x001b, //ESCAPE
|
|
||||
0x001c, //FILE SEPARATOR
|
|
||||
0x001d, //GROUP SEPARATOR
|
|
||||
0x001e, //RECORD SEPARATOR
|
|
||||
0x001f, //UNIT SEPARATOR
|
|
||||
0x0020, //SPACE
|
|
||||
0x0021, //EXCLAMATION MARK
|
|
||||
0x0022, //QUOTATION MARK
|
|
||||
0x0023, //NUMBER SIGN
|
|
||||
0x0024, //DOLLAR SIGN
|
|
||||
0x0025, //PERCENT SIGN
|
|
||||
0x0026, //AMPERSAND
|
|
||||
0x0027, //APOSTROPHE
|
|
||||
0x0028, //LEFT PARENTHESIS
|
|
||||
0x0029, //RIGHT PARENTHESIS
|
|
||||
0x002a, //ASTERISK
|
|
||||
0x002b, //PLUS SIGN
|
|
||||
0x002c, //COMMA
|
|
||||
0x002d, //HYPHEN-MINUS
|
|
||||
0x002e, //FULL STOP
|
|
||||
0x002f, //SOLIDUS
|
|
||||
0x0030, //DIGIT ZERO
|
|
||||
0x0031, //DIGIT ONE
|
|
||||
0x0032, //DIGIT TWO
|
|
||||
0x0033, //DIGIT THREE
|
|
||||
0x0034, //DIGIT FOUR
|
|
||||
0x0035, //DIGIT FIVE
|
|
||||
0x0036, //DIGIT SIX
|
|
||||
0x0037, //DIGIT SEVEN
|
|
||||
0x0038, //DIGIT EIGHT
|
|
||||
0x0039, //DIGIT NINE
|
|
||||
0x003a, //COLON
|
|
||||
0x003b, //SEMICOLON
|
|
||||
0x003c, //LESS-THAN SIGN
|
|
||||
0x003d, //EQUALS SIGN
|
|
||||
0x003e, //GREATER-THAN SIGN
|
|
||||
0x003f, //QUESTION MARK
|
|
||||
0x0040, //COMMERCIAL AT
|
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
|
||||
0x004a, //LATIN CAPITAL LETTER J
|
|
||||
0x004b, //LATIN CAPITAL LETTER K
|
|
||||
0x004c, //LATIN CAPITAL LETTER L
|
|
||||
0x004d, //LATIN CAPITAL LETTER M
|
|
||||
0x004e, //LATIN CAPITAL LETTER N
|
|
||||
0x004f, //LATIN CAPITAL LETTER O
|
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
|
||||
0x005a, //LATIN CAPITAL LETTER Z
|
|
||||
0x005b, //LEFT SQUARE BRACKET
|
|
||||
0x005c, //REVERSE SOLIDUS
|
|
||||
0x005d, //RIGHT SQUARE BRACKET
|
|
||||
0x005e, //CIRCUMFLEX ACCENT
|
|
||||
0x005f, //LOW LINE
|
|
||||
0x0060, //GRAVE ACCENT
|
|
||||
0x0061, //LATIN SMALL LETTER A
|
|
||||
0x0062, //LATIN SMALL LETTER B
|
|
||||
0x0063, //LATIN SMALL LETTER C
|
|
||||
0x0064, //LATIN SMALL LETTER D
|
|
||||
0x0065, //LATIN SMALL LETTER E
|
|
||||
0x0066, //LATIN SMALL LETTER F
|
|
||||
0x0067, //LATIN SMALL LETTER G
|
|
||||
0x0068, //LATIN SMALL LETTER H
|
|
||||
0x0069, //LATIN SMALL LETTER I
|
|
||||
0x006a, //LATIN SMALL LETTER J
|
|
||||
0x006b, //LATIN SMALL LETTER K
|
|
||||
0x006c, //LATIN SMALL LETTER L
|
|
||||
0x006d, //LATIN SMALL LETTER M
|
|
||||
0x006e, //LATIN SMALL LETTER N
|
|
||||
0x006f, //LATIN SMALL LETTER O
|
|
||||
0x0070, //LATIN SMALL LETTER P
|
|
||||
0x0071, //LATIN SMALL LETTER Q
|
|
||||
0x0072, //LATIN SMALL LETTER R
|
|
||||
0x0073, //LATIN SMALL LETTER S
|
|
||||
0x0074, //LATIN SMALL LETTER T
|
|
||||
0x0075, //LATIN SMALL LETTER U
|
|
||||
0x0076, //LATIN SMALL LETTER V
|
|
||||
0x0077, //LATIN SMALL LETTER W
|
|
||||
0x0078, //LATIN SMALL LETTER X
|
|
||||
0x0079, //LATIN SMALL LETTER Y
|
|
||||
0x007a, //LATIN SMALL LETTER Z
|
|
||||
0x007b, //LEFT CURLY BRACKET
|
|
||||
0x007c, //VERTICAL LINE
|
|
||||
0x007d, //RIGHT CURLY BRACKET
|
|
||||
0x007e, //TILDE
|
|
||||
0x007f, //DELETE
|
|
||||
0x00c7, //LATIN CAPITAL LETTER C WITH CEDILLA
|
|
||||
0x00fc, //LATIN SMALL LETTER U WITH DIAERESIS
|
|
||||
0x00e9, //LATIN SMALL LETTER E WITH ACUTE
|
|
||||
0x00e2, //LATIN SMALL LETTER A WITH CIRCUMFLEX
|
|
||||
0x00e4, //LATIN SMALL LETTER A WITH DIAERESIS
|
|
||||
0x00e0, //LATIN SMALL LETTER A WITH GRAVE
|
|
||||
0x00e5, //LATIN SMALL LETTER A WITH RING ABOVE
|
|
||||
0x00e7, //LATIN SMALL LETTER C WITH CEDILLA
|
|
||||
0x00ea, //LATIN SMALL LETTER E WITH CIRCUMFLEX
|
|
||||
0x00eb, //LATIN SMALL LETTER E WITH DIAERESIS
|
|
||||
0x00e8, //LATIN SMALL LETTER E WITH GRAVE
|
|
||||
0x00ef, //LATIN SMALL LETTER I WITH DIAERESIS
|
|
||||
0x00ee, //LATIN SMALL LETTER I WITH CIRCUMFLEX
|
|
||||
0x00ec, //LATIN SMALL LETTER I WITH GRAVE
|
|
||||
0x00c4, //LATIN CAPITAL LETTER A WITH DIAERESIS
|
|
||||
0x00c5, //LATIN CAPITAL LETTER A WITH RING ABOVE
|
|
||||
0x00c9, //LATIN CAPITAL LETTER E WITH ACUTE
|
|
||||
0x00e6, //LATIN SMALL LIGATURE AE
|
|
||||
0x00c6, //LATIN CAPITAL LIGATURE AE
|
|
||||
0x00f4, //LATIN SMALL LETTER O WITH CIRCUMFLEX
|
|
||||
0x00f6, //LATIN SMALL LETTER O WITH DIAERESIS
|
|
||||
0x00f2, //LATIN SMALL LETTER O WITH GRAVE
|
|
||||
0x00fb, //LATIN SMALL LETTER U WITH CIRCUMFLEX
|
|
||||
0x00f9, //LATIN SMALL LETTER U WITH GRAVE
|
|
||||
0x00ff, //LATIN SMALL LETTER Y WITH DIAERESIS
|
|
||||
0x00d6, //LATIN CAPITAL LETTER O WITH DIAERESIS
|
|
||||
0x00dc, //LATIN CAPITAL LETTER U WITH DIAERESIS
|
|
||||
0x00a2, //CENT SIGN
|
|
||||
0x00a3, //POUND SIGN
|
|
||||
0x00a5, //YEN SIGN
|
|
||||
0x20a7, //PESETA SIGN
|
|
||||
0x0192, //LATIN SMALL LETTER F WITH HOOK
|
|
||||
0x00e1, //LATIN SMALL LETTER A WITH ACUTE
|
|
||||
0x00ed, //LATIN SMALL LETTER I WITH ACUTE
|
|
||||
0x00f3, //LATIN SMALL LETTER O WITH ACUTE
|
|
||||
0x00fa, //LATIN SMALL LETTER U WITH ACUTE
|
|
||||
0x00f1, //LATIN SMALL LETTER N WITH TILDE
|
|
||||
0x00d1, //LATIN CAPITAL LETTER N WITH TILDE
|
|
||||
0x00aa, //FEMININE ORDINAL INDICATOR
|
|
||||
0x00ba, //MASCULINE ORDINAL INDICATOR
|
|
||||
0x00bf, //INVERTED QUESTION MARK
|
|
||||
0x2310, //REVERSED NOT SIGN
|
|
||||
0x00ac, //NOT SIGN
|
|
||||
0x00bd, //VULGAR FRACTION ONE HALF
|
|
||||
0x00bc, //VULGAR FRACTION ONE QUARTER
|
|
||||
0x00a1, //INVERTED EXCLAMATION MARK
|
|
||||
0x00ab, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x00bb, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x2591, //LIGHT SHADE
|
|
||||
0x2592, //MEDIUM SHADE
|
|
||||
0x2593, //DARK SHADE
|
|
||||
0x2502, //BOX DRAWINGS LIGHT VERTICAL
|
|
||||
0x2524, //BOX DRAWINGS LIGHT VERTICAL AND LEFT
|
|
||||
0x2561, //BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
|
|
||||
0x2562, //BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
|
|
||||
0x2556, //BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
|
|
||||
0x2555, //BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
|
|
||||
0x2563, //BOX DRAWINGS DOUBLE VERTICAL AND LEFT
|
|
||||
0x2551, //BOX DRAWINGS DOUBLE VERTICAL
|
|
||||
0x2557, //BOX DRAWINGS DOUBLE DOWN AND LEFT
|
|
||||
0x255d, //BOX DRAWINGS DOUBLE UP AND LEFT
|
|
||||
0x255c, //BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
|
|
||||
0x255b, //BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
|
|
||||
0x2510, //BOX DRAWINGS LIGHT DOWN AND LEFT
|
|
||||
0x2514, //BOX DRAWINGS LIGHT UP AND RIGHT
|
|
||||
0x2534, //BOX DRAWINGS LIGHT UP AND HORIZONTAL
|
|
||||
0x252c, //BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
|
|
||||
0x251c, //BOX DRAWINGS LIGHT VERTICAL AND RIGHT
|
|
||||
0x2500, //BOX DRAWINGS LIGHT HORIZONTAL
|
|
||||
0x253c, //BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
|
|
||||
0x255e, //BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
|
|
||||
0x255f, //BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
|
|
||||
0x255a, //BOX DRAWINGS DOUBLE UP AND RIGHT
|
|
||||
0x2554, //BOX DRAWINGS DOUBLE DOWN AND RIGHT
|
|
||||
0x2569, //BOX DRAWINGS DOUBLE UP AND HORIZONTAL
|
|
||||
0x2566, //BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
|
|
||||
0x2560, //BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
|
|
||||
0x2550, //BOX DRAWINGS DOUBLE HORIZONTAL
|
|
||||
0x256c, //BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
|
|
||||
0x2567, //BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
|
|
||||
0x2568, //BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
|
|
||||
0x2564, //BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
|
|
||||
0x2565, //BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
|
|
||||
0x2559, //BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
|
|
||||
0x2558, //BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
|
|
||||
0x2552, //BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
|
|
||||
0x2553, //BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
|
|
||||
0x256b, //BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
|
|
||||
0x256a, //BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
|
|
||||
0x2518, //BOX DRAWINGS LIGHT UP AND LEFT
|
|
||||
0x250c, //BOX DRAWINGS LIGHT DOWN AND RIGHT
|
|
||||
0x2588, //FULL BLOCK
|
|
||||
0x2584, //LOWER HALF BLOCK
|
|
||||
0x258c, //LEFT HALF BLOCK
|
|
||||
0x2590, //RIGHT HALF BLOCK
|
|
||||
0x2580, //UPPER HALF BLOCK
|
|
||||
0x03b1, //GREEK SMALL LETTER ALPHA
|
|
||||
0x00df, //LATIN SMALL LETTER SHARP S
|
|
||||
0x0393, //GREEK CAPITAL LETTER GAMMA
|
|
||||
0x03c0, //GREEK SMALL LETTER PI
|
|
||||
0x03a3, //GREEK CAPITAL LETTER SIGMA
|
|
||||
0x03c3, //GREEK SMALL LETTER SIGMA
|
|
||||
0x00b5, //MICRO SIGN
|
|
||||
0x03c4, //GREEK SMALL LETTER TAU
|
|
||||
0x03a6, //GREEK CAPITAL LETTER PHI
|
|
||||
0x0398, //GREEK CAPITAL LETTER THETA
|
|
||||
0x03a9, //GREEK CAPITAL LETTER OMEGA
|
|
||||
0x03b4, //GREEK SMALL LETTER DELTA
|
|
||||
0x221e, //INFINITY
|
|
||||
0x03c6, //GREEK SMALL LETTER PHI
|
|
||||
0x03b5, //GREEK SMALL LETTER EPSILON
|
|
||||
0x2229, //INTERSECTION
|
|
||||
0x2261, //IDENTICAL TO
|
|
||||
0x00b1, //PLUS-MINUS SIGN
|
|
||||
0x2265, //GREATER-THAN OR EQUAL TO
|
|
||||
0x2264, //LESS-THAN OR EQUAL TO
|
|
||||
0x2320, //TOP HALF INTEGRAL
|
|
||||
0x2321, //BOTTOM HALF INTEGRAL
|
|
||||
0x00f7, //DIVISION SIGN
|
|
||||
0x2248, //ALMOST EQUAL TO
|
|
||||
0x00b0, //DEGREE SIGN
|
|
||||
0x2219, //BULLET OPERATOR
|
|
||||
0x00b7, //MIDDLE DOT
|
|
||||
0x221a, //SQUARE ROOT
|
|
||||
0x207f, //SUPERSCRIPT LATIN SMALL LETTER N
|
|
||||
0x00b2, //SUPERSCRIPT TWO
|
|
||||
0x25a0, //BLACK SQUARE
|
|
||||
0x00a0, //NO-BREAK SPACE
|
|
||||
}, |
|
||||
} |
|
@ -1,262 +0,0 @@ |
|||||
package cp |
|
||||
|
|
||||
var cp850 *charsetMap = &charsetMap{ |
|
||||
sb: [256]rune{ |
|
||||
0x0000, //NULL
|
|
||||
0x0001, //START OF HEADING
|
|
||||
0x0002, //START OF TEXT
|
|
||||
0x0003, //END OF TEXT
|
|
||||
0x0004, //END OF TRANSMISSION
|
|
||||
0x0005, //ENQUIRY
|
|
||||
0x0006, //ACKNOWLEDGE
|
|
||||
0x0007, //BELL
|
|
||||
0x0008, //BACKSPACE
|
|
||||
0x0009, //HORIZONTAL TABULATION
|
|
||||
0x000a, //LINE FEED
|
|
||||
0x000b, //VERTICAL TABULATION
|
|
||||
0x000c, //FORM FEED
|
|
||||
0x000d, //CARRIAGE RETURN
|
|
||||
0x000e, //SHIFT OUT
|
|
||||
0x000f, //SHIFT IN
|
|
||||
0x0010, //DATA LINK ESCAPE
|
|
||||
0x0011, //DEVICE CONTROL ONE
|
|
||||
0x0012, //DEVICE CONTROL TWO
|
|
||||
0x0013, //DEVICE CONTROL THREE
|
|
||||
0x0014, //DEVICE CONTROL FOUR
|
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
|
||||
0x0016, //SYNCHRONOUS IDLE
|
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
|
||||
0x0018, //CANCEL
|
|
||||
0x0019, //END OF MEDIUM
|
|
||||
0x001a, //SUBSTITUTE
|
|
||||
0x001b, //ESCAPE
|
|
||||
0x001c, //FILE SEPARATOR
|
|
||||
0x001d, //GROUP SEPARATOR
|
|
||||
0x001e, //RECORD SEPARATOR
|
|
||||
0x001f, //UNIT SEPARATOR
|
|
||||
0x0020, //SPACE
|
|
||||
0x0021, //EXCLAMATION MARK
|
|
||||
0x0022, //QUOTATION MARK
|
|
||||
0x0023, //NUMBER SIGN
|
|
||||
0x0024, //DOLLAR SIGN
|
|
||||
0x0025, //PERCENT SIGN
|
|
||||
0x0026, //AMPERSAND
|
|
||||
0x0027, //APOSTROPHE
|
|
||||
0x0028, //LEFT PARENTHESIS
|
|
||||
0x0029, //RIGHT PARENTHESIS
|
|
||||
0x002a, //ASTERISK
|
|
||||
0x002b, //PLUS SIGN
|
|
||||
0x002c, //COMMA
|
|
||||
0x002d, //HYPHEN-MINUS
|
|
||||
0x002e, //FULL STOP
|
|
||||
0x002f, //SOLIDUS
|
|
||||
0x0030, //DIGIT ZERO
|
|
||||
0x0031, //DIGIT ONE
|
|
||||
0x0032, //DIGIT TWO
|
|
||||
0x0033, //DIGIT THREE
|
|
||||
0x0034, //DIGIT FOUR
|
|
||||
0x0035, //DIGIT FIVE
|
|
||||
0x0036, //DIGIT SIX
|
|
||||
0x0037, //DIGIT SEVEN
|
|
||||
0x0038, //DIGIT EIGHT
|
|
||||
0x0039, //DIGIT NINE
|
|
||||
0x003a, //COLON
|
|
||||
0x003b, //SEMICOLON
|
|
||||
0x003c, //LESS-THAN SIGN
|
|
||||
0x003d, //EQUALS SIGN
|
|
||||
0x003e, //GREATER-THAN SIGN
|
|
||||
0x003f, //QUESTION MARK
|
|
||||
0x0040, //COMMERCIAL AT
|
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
|
||||
0x004a, //LATIN CAPITAL LETTER J
|
|
||||
0x004b, //LATIN CAPITAL LETTER K
|
|
||||
0x004c, //LATIN CAPITAL LETTER L
|
|
||||
0x004d, //LATIN CAPITAL LETTER M
|
|
||||
0x004e, //LATIN CAPITAL LETTER N
|
|
||||
0x004f, //LATIN CAPITAL LETTER O
|
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
|
||||
0x005a, //LATIN CAPITAL LETTER Z
|
|
||||
0x005b, //LEFT SQUARE BRACKET
|
|
||||
0x005c, //REVERSE SOLIDUS
|
|
||||
0x005d, //RIGHT SQUARE BRACKET
|
|
||||
0x005e, //CIRCUMFLEX ACCENT
|
|
||||
0x005f, //LOW LINE
|
|
||||
0x0060, //GRAVE ACCENT
|
|
||||
0x0061, //LATIN SMALL LETTER A
|
|
||||
0x0062, //LATIN SMALL LETTER B
|
|
||||
0x0063, //LATIN SMALL LETTER C
|
|
||||
0x0064, //LATIN SMALL LETTER D
|
|
||||
0x0065, //LATIN SMALL LETTER E
|
|
||||
0x0066, //LATIN SMALL LETTER F
|
|
||||
0x0067, //LATIN SMALL LETTER G
|
|
||||
0x0068, //LATIN SMALL LETTER H
|
|
||||
0x0069, //LATIN SMALL LETTER I
|
|
||||
0x006a, //LATIN SMALL LETTER J
|
|
||||
0x006b, //LATIN SMALL LETTER K
|
|
||||
0x006c, //LATIN SMALL LETTER L
|
|
||||
0x006d, //LATIN SMALL LETTER M
|
|
||||
0x006e, //LATIN SMALL LETTER N
|
|
||||
0x006f, //LATIN SMALL LETTER O
|
|
||||
0x0070, //LATIN SMALL LETTER P
|
|
||||
0x0071, //LATIN SMALL LETTER Q
|
|
||||
0x0072, //LATIN SMALL LETTER R
|
|
||||
0x0073, //LATIN SMALL LETTER S
|
|
||||
0x0074, //LATIN SMALL LETTER T
|
|
||||
0x0075, //LATIN SMALL LETTER U
|
|
||||
0x0076, //LATIN SMALL LETTER V
|
|
||||
0x0077, //LATIN SMALL LETTER W
|
|
||||
0x0078, //LATIN SMALL LETTER X
|
|
||||
0x0079, //LATIN SMALL LETTER Y
|
|
||||
0x007a, //LATIN SMALL LETTER Z
|
|
||||
0x007b, //LEFT CURLY BRACKET
|
|
||||
0x007c, //VERTICAL LINE
|
|
||||
0x007d, //RIGHT CURLY BRACKET
|
|
||||
0x007e, //TILDE
|
|
||||
0x007f, //DELETE
|
|
||||
0x00c7, //LATIN CAPITAL LETTER C WITH CEDILLA
|
|
||||
0x00fc, //LATIN SMALL LETTER U WITH DIAERESIS
|
|
||||
0x00e9, //LATIN SMALL LETTER E WITH ACUTE
|
|
||||
0x00e2, //LATIN SMALL LETTER A WITH CIRCUMFLEX
|
|
||||
0x00e4, //LATIN SMALL LETTER A WITH DIAERESIS
|
|
||||
0x00e0, //LATIN SMALL LETTER A WITH GRAVE
|
|
||||
0x00e5, //LATIN SMALL LETTER A WITH RING ABOVE
|
|
||||
0x00e7, //LATIN SMALL LETTER C WITH CEDILLA
|
|
||||
0x00ea, //LATIN SMALL LETTER E WITH CIRCUMFLEX
|
|
||||
0x00eb, //LATIN SMALL LETTER E WITH DIAERESIS
|
|
||||
0x00e8, //LATIN SMALL LETTER E WITH GRAVE
|
|
||||
0x00ef, //LATIN SMALL LETTER I WITH DIAERESIS
|
|
||||
0x00ee, //LATIN SMALL LETTER I WITH CIRCUMFLEX
|
|
||||
0x00ec, //LATIN SMALL LETTER I WITH GRAVE
|
|
||||
0x00c4, //LATIN CAPITAL LETTER A WITH DIAERESIS
|
|
||||
0x00c5, //LATIN CAPITAL LETTER A WITH RING ABOVE
|
|
||||
0x00c9, //LATIN CAPITAL LETTER E WITH ACUTE
|
|
||||
0x00e6, //LATIN SMALL LIGATURE AE
|
|
||||
0x00c6, //LATIN CAPITAL LIGATURE AE
|
|
||||
0x00f4, //LATIN SMALL LETTER O WITH CIRCUMFLEX
|
|
||||
0x00f6, //LATIN SMALL LETTER O WITH DIAERESIS
|
|
||||
0x00f2, //LATIN SMALL LETTER O WITH GRAVE
|
|
||||
0x00fb, //LATIN SMALL LETTER U WITH CIRCUMFLEX
|
|
||||
0x00f9, //LATIN SMALL LETTER U WITH GRAVE
|
|
||||
0x00ff, //LATIN SMALL LETTER Y WITH DIAERESIS
|
|
||||
0x00d6, //LATIN CAPITAL LETTER O WITH DIAERESIS
|
|
||||
0x00dc, //LATIN CAPITAL LETTER U WITH DIAERESIS
|
|
||||
0x00f8, //LATIN SMALL LETTER O WITH STROKE
|
|
||||
0x00a3, //POUND SIGN
|
|
||||
0x00d8, //LATIN CAPITAL LETTER O WITH STROKE
|
|
||||
0x00d7, //MULTIPLICATION SIGN
|
|
||||
0x0192, //LATIN SMALL LETTER F WITH HOOK
|
|
||||
0x00e1, //LATIN SMALL LETTER A WITH ACUTE
|
|
||||
0x00ed, //LATIN SMALL LETTER I WITH ACUTE
|
|
||||
0x00f3, //LATIN SMALL LETTER O WITH ACUTE
|
|
||||
0x00fa, //LATIN SMALL LETTER U WITH ACUTE
|
|
||||
0x00f1, //LATIN SMALL LETTER N WITH TILDE
|
|
||||
0x00d1, //LATIN CAPITAL LETTER N WITH TILDE
|
|
||||
0x00aa, //FEMININE ORDINAL INDICATOR
|
|
||||
0x00ba, //MASCULINE ORDINAL INDICATOR
|
|
||||
0x00bf, //INVERTED QUESTION MARK
|
|
||||
0x00ae, //REGISTERED SIGN
|
|
||||
0x00ac, //NOT SIGN
|
|
||||
0x00bd, //VULGAR FRACTION ONE HALF
|
|
||||
0x00bc, //VULGAR FRACTION ONE QUARTER
|
|
||||
0x00a1, //INVERTED EXCLAMATION MARK
|
|
||||
0x00ab, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x00bb, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||
0x2591, //LIGHT SHADE
|
|
||||
0x2592, //MEDIUM SHADE
|
|
||||
0x2593, //DARK SHADE
|
|
||||
0x2502, //BOX DRAWINGS LIGHT VERTICAL
|
|
||||
0x2524, //BOX DRAWINGS LIGHT VERTICAL AND LEFT
|
|
||||
0x00c1, //LATIN CAPITAL LETTER A WITH ACUTE
|
|
||||
0x00c2, //LATIN CAPITAL LETTER A WITH CIRCUMFLEX
|
|
||||
0x00c0, //LATIN CAPITAL LETTER A WITH GRAVE
|
|
||||
0x00a9, //COPYRIGHT SIGN
|
|
||||
0x2563, //BOX DRAWINGS DOUBLE VERTICAL AND LEFT
|
|
||||
0x2551, //BOX DRAWINGS DOUBLE VERTICAL
|
|
||||
0x2557, //BOX DRAWINGS DOUBLE DOWN AND LEFT
|
|
||||
0x255d, //BOX DRAWINGS DOUBLE UP AND LEFT
|
|
||||
0x00a2, //CENT SIGN
|
|
||||
0x00a5, //YEN SIGN
|
|
||||
0x2510, //BOX DRAWINGS LIGHT DOWN AND LEFT
|
|
||||
0x2514, //BOX DRAWINGS LIGHT UP AND RIGHT
|
|
||||
0x2534, //BOX DRAWINGS LIGHT UP AND HORIZONTAL
|
|
||||
0x252c, //BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
|
|
||||
0x251c, //BOX DRAWINGS LIGHT VERTICAL AND RIGHT
|
|
||||
0x2500, //BOX DRAWINGS LIGHT HORIZONTAL
|
|
||||
0x253c, //BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
|
|
||||
0x00e3, //LATIN SMALL LETTER A WITH TILDE
|
|
||||
0x00c3, //LATIN CAPITAL LETTER A WITH TILDE
|
|
||||
0x255a, //BOX DRAWINGS DOUBLE UP AND RIGHT
|
|
||||
0x2554, //BOX DRAWINGS DOUBLE DOWN AND RIGHT
|
|
||||
0x2569, //BOX DRAWINGS DOUBLE UP AND HORIZONTAL
|
|
||||
0x2566, //BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
|
|
||||
0x2560, //BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
|
|
||||
0x2550, //BOX DRAWINGS DOUBLE HORIZONTAL
|
|
||||
0x256c, //BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
|
|
||||
0x00a4, //CURRENCY SIGN
|
|
||||
0x00f0, //LATIN SMALL LETTER ETH
|
|
||||
0x00d0, //LATIN CAPITAL LETTER ETH
|
|
||||
0x00ca, //LATIN CAPITAL LETTER E WITH CIRCUMFLEX
|
|
||||
0x00cb, //LATIN CAPITAL LETTER E WITH DIAERESIS
|
|
||||
0x00c8, //LATIN CAPITAL LETTER E WITH GRAVE
|
|
||||
0x0131, //LATIN SMALL LETTER DOTLESS I
|
|
||||
0x00cd, //LATIN CAPITAL LETTER I WITH ACUTE
|
|
||||
0x00ce, //LATIN CAPITAL LETTER I WITH CIRCUMFLEX
|
|
||||
0x00cf, //LATIN CAPITAL LETTER I WITH DIAERESIS
|
|
||||
0x2518, //BOX DRAWINGS LIGHT UP AND LEFT
|
|
||||
0x250c, //BOX DRAWINGS LIGHT DOWN AND RIGHT
|
|
||||
0x2588, //FULL BLOCK
|
|
||||
0x2584, //LOWER HALF BLOCK
|
|
||||
0x00a6, //BROKEN BAR
|
|
||||
0x00cc, //LATIN CAPITAL LETTER I WITH GRAVE
|
|
||||
0x2580, //UPPER HALF BLOCK
|
|
||||
0x00d3, //LATIN CAPITAL LETTER O WITH ACUTE
|
|
||||
0x00df, //LATIN SMALL LETTER SHARP S
|
|
||||
0x00d4, //LATIN CAPITAL LETTER O WITH CIRCUMFLEX
|
|
||||
0x00d2, //LATIN CAPITAL LETTER O WITH GRAVE
|
|
||||
0x00f5, //LATIN SMALL LETTER O WITH TILDE
|
|
||||
0x00d5, //LATIN CAPITAL LETTER O WITH TILDE
|
|
||||
0x00b5, //MICRO SIGN
|
|
||||
0x00fe, //LATIN SMALL LETTER THORN
|
|
||||
0x00de, //LATIN CAPITAL LETTER THORN
|
|
||||
0x00da, //LATIN CAPITAL LETTER U WITH ACUTE
|
|
||||
0x00db, //LATIN CAPITAL LETTER U WITH CIRCUMFLEX
|
|
||||
0x00d9, //LATIN CAPITAL LETTER U WITH GRAVE
|
|
||||
0x00fd, //LATIN SMALL LETTER Y WITH ACUTE
|
|
||||
0x00dd, //LATIN CAPITAL LETTER Y WITH ACUTE
|
|
||||
0x00af, //MACRON
|
|
||||
0x00b4, //ACUTE ACCENT
|
|
||||
0x00ad, //SOFT HYPHEN
|
|
||||
0x00b1, //PLUS-MINUS SIGN
|
|
||||
0x2017, //DOUBLE LOW LINE
|
|
||||
0x00be, //VULGAR FRACTION THREE QUARTERS
|
|
||||
0x00b6, //PILCROW SIGN
|
|
||||
0x00a7, //SECTION SIGN
|
|
||||
0x00f7, //DIVISION SIGN
|
|
||||
0x00b8, //CEDILLA
|
|
||||
0x00b0, //DEGREE SIGN
|
|
||||
0x00a8, //DIAERESIS
|
|
||||
0x00b7, //MIDDLE DOT
|
|
||||
0x00b9, //SUPERSCRIPT ONE
|
|
||||
0x00b3, //SUPERSCRIPT THREE
|
|
||||
0x00b2, //SUPERSCRIPT TWO
|
|
||||
0x25a0, //BLACK SQUARE
|
|
||||
0x00a0, //NO-BREAK SPACE
|
|
||||
}, |
|
||||
} |
|
@ -1,262 +0,0 @@ |
|||||
package cp |
|
||||
|
|
||||
var cp874 *charsetMap = &charsetMap{ |
|
||||
sb: [256]rune{ |
|
||||
0x0000, //NULL
|
|
||||
0x0001, //START OF HEADING
|
|
||||
0x0002, //START OF TEXT
|
|
||||
0x0003, //END OF TEXT
|
|
||||
0x0004, //END OF TRANSMISSION
|
|
||||
0x0005, //ENQUIRY
|
|
||||
0x0006, //ACKNOWLEDGE
|
|
||||
0x0007, //BELL
|
|
||||
0x0008, //BACKSPACE
|
|
||||
0x0009, //HORIZONTAL TABULATION
|
|
||||
0x000A, //LINE FEED
|
|
||||
0x000B, //VERTICAL TABULATION
|
|
||||
0x000C, //FORM FEED
|
|
||||
0x000D, //CARRIAGE RETURN
|
|
||||
0x000E, //SHIFT OUT
|
|
||||
0x000F, //SHIFT IN
|
|
||||
0x0010, //DATA LINK ESCAPE
|
|
||||
0x0011, //DEVICE CONTROL ONE
|
|
||||
0x0012, //DEVICE CONTROL TWO
|
|
||||
0x0013, //DEVICE CONTROL THREE
|
|
||||
0x0014, //DEVICE CONTROL FOUR
|
|
||||
0x0015, //NEGATIVE ACKNOWLEDGE
|
|
||||
0x0016, //SYNCHRONOUS IDLE
|
|
||||
0x0017, //END OF TRANSMISSION BLOCK
|
|
||||
0x0018, //CANCEL
|
|
||||
0x0019, //END OF MEDIUM
|
|
||||
0x001A, //SUBSTITUTE
|
|
||||
0x001B, //ESCAPE
|
|
||||
0x001C, //FILE SEPARATOR
|
|
||||
0x001D, //GROUP SEPARATOR
|
|
||||
0x001E, //RECORD SEPARATOR
|
|
||||
0x001F, //UNIT SEPARATOR
|
|
||||
0x0020, //SPACE
|
|
||||
0x0021, //EXCLAMATION MARK
|
|
||||
0x0022, //QUOTATION MARK
|
|
||||
0x0023, //NUMBER SIGN
|
|
||||
0x0024, //DOLLAR SIGN
|
|
||||
0x0025, //PERCENT SIGN
|
|
||||
0x0026, //AMPERSAND
|
|
||||
0x0027, //APOSTROPHE
|
|
||||
0x0028, //LEFT PARENTHESIS
|
|
||||
0x0029, //RIGHT PARENTHESIS
|
|
||||
0x002A, //ASTERISK
|
|
||||
0x002B, //PLUS SIGN
|
|
||||
0x002C, //COMMA
|
|
||||
0x002D, //HYPHEN-MINUS
|
|
||||
0x002E, //FULL STOP
|
|
||||
0x002F, //SOLIDUS
|
|
||||
0x0030, //DIGIT ZERO
|
|
||||
0x0031, //DIGIT ONE
|
|
||||
0x0032, //DIGIT TWO
|
|
||||
0x0033, //DIGIT THREE
|
|
||||
0x0034, //DIGIT FOUR
|
|
||||
0x0035, //DIGIT FIVE
|
|
||||
0x0036, //DIGIT SIX
|
|
||||
0x0037, //DIGIT SEVEN
|
|
||||
0x0038, //DIGIT EIGHT
|
|
||||
0x0039, //DIGIT NINE
|
|
||||
0x003A, //COLON
|
|
||||
0x003B, //SEMICOLON
|
|
||||
0x003C, //LESS-THAN SIGN
|
|
||||
0x003D, //EQUALS SIGN
|
|
||||
0x003E, //GREATER-THAN SIGN
|
|
||||
0x003F, //QUESTION MARK
|
|
||||
0x0040, //COMMERCIAL AT
|
|
||||
0x0041, //LATIN CAPITAL LETTER A
|
|
||||
0x0042, //LATIN CAPITAL LETTER B
|
|
||||
0x0043, //LATIN CAPITAL LETTER C
|
|
||||
0x0044, //LATIN CAPITAL LETTER D
|
|
||||
0x0045, //LATIN CAPITAL LETTER E
|
|
||||
0x0046, //LATIN CAPITAL LETTER F
|
|
||||
0x0047, //LATIN CAPITAL LETTER G
|
|
||||
0x0048, //LATIN CAPITAL LETTER H
|
|
||||
0x0049, //LATIN CAPITAL LETTER I
|
|
||||
0x004A, //LATIN CAPITAL LETTER J
|
|
||||
0x004B, //LATIN CAPITAL LETTER K
|
|
||||
0x004C, //LATIN CAPITAL LETTER L
|
|
||||
0x004D, //LATIN CAPITAL LETTER M
|
|
||||
0x004E, //LATIN CAPITAL LETTER N
|
|
||||
0x004F, //LATIN CAPITAL LETTER O
|
|
||||
0x0050, //LATIN CAPITAL LETTER P
|
|
||||
0x0051, //LATIN CAPITAL LETTER Q
|
|
||||
0x0052, //LATIN CAPITAL LETTER R
|
|
||||
0x0053, //LATIN CAPITAL LETTER S
|
|
||||
0x0054, //LATIN CAPITAL LETTER T
|
|
||||
0x0055, //LATIN CAPITAL LETTER U
|
|
||||
0x0056, //LATIN CAPITAL LETTER V
|
|
||||
0x0057, //LATIN CAPITAL LETTER W
|
|
||||
0x0058, //LATIN CAPITAL LETTER X
|
|
||||
0x0059, //LATIN CAPITAL LETTER Y
|
|
||||
0x005A, //LATIN CAPITAL LETTER Z
|
|
||||
0x005B, //LEFT SQUARE BRACKET
|
|
||||
0x005C, //REVERSE SOLIDUS
|
|
||||
0x005D, //RIGHT SQUARE BRACKET
|
|
||||
0x005E, //CIRCUMFLEX ACCENT
|
|
||||
0x005F, //LOW LINE
|
|
||||
0x0060, //GRAVE ACCENT
|
|
||||
0x0061, //LATIN SMALL LETTER A
|
|
||||
0x0062, //LATIN SMALL LETTER B
|
|
||||
0x0063, //LATIN SMALL LETTER C
|
|
||||
0x0064, //LATIN SMALL LETTER D
|
|
||||
0x0065, //LATIN SMALL LETTER E
|
|
||||
0x0066, //LATIN SMALL LETTER F
|
|
||||
0x0067, //LATIN SMALL LETTER G
|
|
||||
0x0068, //LATIN SMALL LETTER H
|
|
||||
0x0069, //LATIN SMALL LETTER I
|
|
||||
0x006A, //LATIN SMALL LETTER J
|
|
||||
0x006B, //LATIN SMALL LETTER K
|
|
||||
0x006C, //LATIN SMALL LETTER L
|
|
||||
0x006D, //LATIN SMALL LETTER M
|
|
||||
0x006E, //LATIN SMALL LETTER N
|
|
||||
0x006F, //LATIN SMALL LETTER O
|
|
||||
0x0070, //LATIN SMALL LETTER P
|
|
||||
0x0071, //LATIN SMALL LETTER Q
|
|
||||
0x0072, //LATIN SMALL LETTER R
|
|
||||
0x0073, //LATIN SMALL LETTER S
|
|
||||
0x0074, //LATIN SMALL LETTER T
|
|
||||
0x0075, //LATIN SMALL LETTER U
|
|
||||
0x0076, //LATIN SMALL LETTER V
|
|
||||
0x0077, //LATIN SMALL LETTER W
|
|
||||
0x0078, //LATIN SMALL LETTER X
|
|
||||
0x0079, //LATIN SMALL LETTER Y
|
|
||||
0x007A, //LATIN SMALL LETTER Z
|
|
||||
0x007B, //LEFT CURLY BRACKET
|
|
||||
0x007C, //VERTICAL LINE
|
|
||||
0x007D, //RIGHT CURLY BRACKET
|
|
||||
0x007E, //TILDE
|
|
||||
0x007F, //DELETE
|
|
||||
0x20AC, //EURO SIGN
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x2026, //HORIZONTAL ELLIPSIS
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x2018, //LEFT SINGLE QUOTATION MARK
|
|
||||
0x2019, //RIGHT SINGLE QUOTATION MARK
|
|
||||
0x201C, //LEFT DOUBLE QUOTATION MARK
|
|
||||
0x201D, //RIGHT DOUBLE QUOTATION MARK
|
|
||||
0x2022, //BULLET
|
|
||||
0x2013, //EN DASH
|
|
||||
0x2014, //EM DASH
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x00A0, //NO-BREAK SPACE
|
|
||||
0x0E01, //THAI CHARACTER KO KAI
|
|
||||
0x0E02, //THAI CHARACTER KHO KHAI
|
|
||||
0x0E03, //THAI CHARACTER KHO KHUAT
|
|
||||
0x0E04, //THAI CHARACTER KHO KHWAI
|
|
||||
0x0E05, //THAI CHARACTER KHO KHON
|
|
||||
0x0E06, //THAI CHARACTER KHO RAKHANG
|
|
||||
0x0E07, //THAI CHARACTER NGO NGU
|
|
||||
0x0E08, //THAI CHARACTER CHO CHAN
|
|
||||
0x0E09, //THAI CHARACTER CHO CHING
|
|
||||
0x0E0A, //THAI CHARACTER CHO CHANG
|
|
||||
0x0E0B, //THAI CHARACTER SO SO
|
|
||||
0x0E0C, //THAI CHARACTER CHO CHOE
|
|
||||
0x0E0D, //THAI CHARACTER YO YING
|
|
||||
0x0E0E, //THAI CHARACTER DO CHADA
|
|
||||
0x0E0F, //THAI CHARACTER TO PATAK
|
|
||||
0x0E10, //THAI CHARACTER THO THAN
|
|
||||
0x0E11, //THAI CHARACTER THO NANGMONTHO
|
|
||||
0x0E12, //THAI CHARACTER THO PHUTHAO
|
|
||||
0x0E13, //THAI CHARACTER NO NEN
|
|
||||
0x0E14, //THAI CHARACTER DO DEK
|
|
||||
0x0E15, //THAI CHARACTER TO TAO
|
|
||||
0x0E16, //THAI CHARACTER THO THUNG
|
|
||||
0x0E17, //THAI CHARACTER THO THAHAN
|
|
||||
0x0E18, //THAI CHARACTER THO THONG
|
|
||||
0x0E19, //THAI CHARACTER NO NU
|
|
||||
0x0E1A, //THAI CHARACTER BO BAIMAI
|
|
||||
0x0E1B, //THAI CHARACTER PO PLA
|
|
||||
0x0E1C, //THAI CHARACTER PHO PHUNG
|
|
||||
0x0E1D, //THAI CHARACTER FO FA
|
|
||||
0x0E1E, //THAI CHARACTER PHO PHAN
|
|
||||
0x0E1F, //THAI CHARACTER FO FAN
|
|
||||
0x0E20, //THAI CHARACTER PHO SAMPHAO
|
|
||||
0x0E21, //THAI CHARACTER MO MA
|
|
||||
0x0E22, //THAI CHARACTER YO YAK
|
|
||||
0x0E23, //THAI CHARACTER RO RUA
|
|
||||
0x0E24, //THAI CHARACTER RU
|
|
||||
0x0E25, //THAI CHARACTER LO LING
|
|
||||
0x0E26, //THAI CHARACTER LU
|
|
||||
0x0E27, //THAI CHARACTER WO WAEN
|
|
||||
0x0E28, //THAI CHARACTER SO SALA
|
|
||||
0x0E29, //THAI CHARACTER SO RUSI
|
|
||||
0x0E2A, //THAI CHARACTER SO SUA
|
|
||||
0x0E2B, //THAI CHARACTER HO HIP
|
|
||||
0x0E2C, //THAI CHARACTER LO CHULA
|
|
||||
0x0E2D, //THAI CHARACTER O ANG
|
|
||||
0x0E2E, //THAI CHARACTER HO NOKHUK
|
|
||||
0x0E2F, //THAI CHARACTER PAIYANNOI
|
|
||||
0x0E30, //THAI CHARACTER SARA A
|
|
||||
0x0E31, //THAI CHARACTER MAI HAN-AKAT
|
|
||||
0x0E32, //THAI CHARACTER SARA AA
|
|
||||
0x0E33, //THAI CHARACTER SARA AM
|
|
||||
0x0E34, //THAI CHARACTER SARA I
|
|
||||
0x0E35, //THAI CHARACTER SARA II
|
|
||||
0x0E36, //THAI CHARACTER SARA UE
|
|
||||
0x0E37, //THAI CHARACTER SARA UEE
|
|
||||
0x0E38, //THAI CHARACTER SARA U
|
|
||||
0x0E39, //THAI CHARACTER SARA UU
|
|
||||
0x0E3A, //THAI CHARACTER PHINTHU
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0x0E3F, //THAI CURRENCY SYMBOL BAHT
|
|
||||
0x0E40, //THAI CHARACTER SARA E
|
|
||||
0x0E41, //THAI CHARACTER SARA AE
|
|
||||
0x0E42, //THAI CHARACTER SARA O
|
|
||||
0x0E43, //THAI CHARACTER SARA AI MAIMUAN
|
|
||||
0x0E44, //THAI CHARACTER SARA AI MAIMALAI
|
|
||||
0x0E45, //THAI CHARACTER LAKKHANGYAO
|
|
||||
0x0E46, //THAI CHARACTER MAIYAMOK
|
|
||||
0x0E47, //THAI CHARACTER MAITAIKHU
|
|
||||
0x0E48, //THAI CHARACTER MAI EK
|
|
||||
0x0E49, //THAI CHARACTER MAI THO
|
|
||||
0x0E4A, //THAI CHARACTER MAI TRI
|
|
||||
0x0E4B, //THAI CHARACTER MAI CHATTAWA
|
|
||||
0x0E4C, //THAI CHARACTER THANTHAKHAT
|
|
||||
0x0E4D, //THAI CHARACTER NIKHAHIT
|
|
||||
0x0E4E, //THAI CHARACTER YAMAKKAN
|
|
||||
0x0E4F, //THAI CHARACTER FONGMAN
|
|
||||
0x0E50, //THAI DIGIT ZERO
|
|
||||
0x0E51, //THAI DIGIT ONE
|
|
||||
0x0E52, //THAI DIGIT TWO
|
|
||||
0x0E53, //THAI DIGIT THREE
|
|
||||
0x0E54, //THAI DIGIT FOUR
|
|
||||
0x0E55, //THAI DIGIT FIVE
|
|
||||
0x0E56, //THAI DIGIT SIX
|
|
||||
0x0E57, //THAI DIGIT SEVEN
|
|
||||
0x0E58, //THAI DIGIT EIGHT
|
|
||||
0x0E59, //THAI DIGIT NINE
|
|
||||
0x0E5A, //THAI CHARACTER ANGKHANKHU
|
|
||||
0x0E5B, //THAI CHARACTER KHOMUT
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
0xFFFD, //UNDEFINED
|
|
||||
}, |
|
||||
} |
|
7988
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp932.go
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
22055
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp936.go
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
17312
vendor/github.com/denisenkom/go-mssqldb/internal/cp/cp949.go
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save
Reference in new issue