1 Star 0 Fork 0

topxeq / mahonia

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
fallback.go 691 Bytes
一键复制 编辑 原始数据 按行查看 历史
TopXeQ 提交于 2019-08-28 14:06 . a 0.1
package mahonia
// FallbackDecoder combines a series of Decoders into one.
// If the first Decoder returns a status of INVALID_CHAR, the others are tried as well.
//
// Note: if the text to be decoded ends with a sequence of bytes that is not a valid character in the first charset,
// but it could be the beginning of a valid character, the FallbackDecoder will give a status of NO_ROOM instead of
// falling back to the other Decoders.
func FallbackDecoder(decoders ...Decoder) Decoder {
return func(p []byte) (c rune, size int, status Status) {
for _, d := range decoders {
c, size, status = d(p)
if status != INVALID_CHAR {
return
}
}
return 0, 1, INVALID_CHAR
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/topxeq/mahonia.git
git@gitee.com:topxeq/mahonia.git
topxeq
mahonia
mahonia
master

搜索帮助