diff options
author | techknowlogick <techknowlogick@gitea.io> | 2022-01-14 18:16:05 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-14 18:16:05 -0500 |
commit | 84145e45c50130922fae9055535ab5ea0378e1d4 (patch) | |
tree | fce077a5ae462840bb876ace79aca42abab29ed7 /vendor/github.com/gogs/chardet/utf8.go | |
parent | 2b16ca7c773de278ba01f122dc6f9f43d7534c52 (diff) | |
download | gitea-84145e45c50130922fae9055535ab5ea0378e1d4.tar.gz gitea-84145e45c50130922fae9055535ab5ea0378e1d4.zip |
Remove golang vendored directory (#18277)
* rm go vendor
* fix drone yaml
* add to gitignore
Diffstat (limited to 'vendor/github.com/gogs/chardet/utf8.go')
-rw-r--r-- | vendor/github.com/gogs/chardet/utf8.go | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/vendor/github.com/gogs/chardet/utf8.go b/vendor/github.com/gogs/chardet/utf8.go deleted file mode 100644 index ae036ad9bc..0000000000 --- a/vendor/github.com/gogs/chardet/utf8.go +++ /dev/null @@ -1,71 +0,0 @@ -package chardet - -import ( - "bytes" -) - -var utf8Bom = []byte{0xEF, 0xBB, 0xBF} - -type recognizerUtf8 struct { -} - -func newRecognizer_utf8() *recognizerUtf8 { - return &recognizerUtf8{} -} - -func (*recognizerUtf8) Match(input *recognizerInput) (output recognizerOutput) { - output = recognizerOutput{ - Charset: "UTF-8", - } - hasBom := bytes.HasPrefix(input.raw, utf8Bom) - inputLen := len(input.raw) - var numValid, numInvalid uint32 - var trailBytes uint8 - for i := 0; i < inputLen; i++ { - c := input.raw[i] - if c&0x80 == 0 { - continue - } - if c&0xE0 == 0xC0 { - trailBytes = 1 - } else if c&0xF0 == 0xE0 { - trailBytes = 2 - } else if c&0xF8 == 0xF0 { - trailBytes = 3 - } else { - numInvalid++ - if numInvalid > 5 { - break - } - trailBytes = 0 - } - - for i++; i < inputLen; i++ { - c = input.raw[i] - if c&0xC0 != 0x80 { - numInvalid++ - break - } - if trailBytes--; trailBytes == 0 { - numValid++ - break - } - } - } - - if hasBom && numInvalid == 0 { - output.Confidence = 100 - } else if hasBom && numValid > numInvalid*10 { - output.Confidence = 80 - } else if numValid > 3 && numInvalid == 0 { - output.Confidence = 100 - } else if numValid > 0 && numInvalid == 0 { - output.Confidence = 80 - } else if numValid == 0 && numInvalid == 0 { - // Plain ASCII - output.Confidence = 10 - } else if numValid > numInvalid*10 { - output.Confidence = 25 - } - return -} |