tomtwinkle / garbledreplacer Goto Github PK
View Code? Open in Web Editor NEWTransformer to convert characters that cannot be converted to another string when converting character codes with golang's transform.Transformer.
License: MIT License
Transformer to convert characters that cannot be converted to another string when converting character codes with golang's transform.Transformer.
License: MIT License
こちら https://tech.andpad.co.jp/entry/2022/05/12/100000 の記事を読ませていただきました。
とても助かりました。ありがとうございます。
こちらのライブラリを使っていて、以下問題?に遭遇したので共有させていただきます🙇
func main() {
const msg = "一二三四🍣五六七八九🍺十拾壱"
longMsg := strings.Repeat(msg, 4000) // 4096バイトを超えるようにする
fp, err := os.Create("SJIS.txt")
if err != nil {
panic(err)
}
defer fp.Close()
sjisWriter := bufio.NewWriter(transform.NewWriter(fp, garbledreplacer.NewTransformer(japanese.ShiftJIS, '?')))
// 以下エラー処理省略
_, err = sjisWriter.WriteString(longMsg)
if err != nil {
log.Fatal(err)
}
_ = sjisWriter.Flush()
}
上記のように、4096バイト以上の文字列をshift-jisに変換するとErrInvalidUTF8のエラーが出ます。
本来なら長い文字列でも問題なく変換できるのが良いと思います。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.