mahonia icon indicating copy to clipboard operation
mahonia copied to clipboard

Init decoder first and use later cause different behavior

Open zhuguoliang opened this issue 6 years ago • 2 comments

image

if I do enc := ma.NewEncoder("gb18030") first and then print with enc.ConvertString(file1.Name) I would get Chinese garbled.

But if I just do ma.NewDecoder("gb18030").ConvertString(file1.Name) it works

zhuguoliang avatar Aug 14 '18 02:08 zhuguoliang

mybe your zip filename is encoded by gb18030,and your Terminal is utf-8 encoding

axgle avatar Oct 09 '18 10:10 axgle

image

if I do enc := ma.NewEncoder("gb18030") first and then print with enc.ConvertString(file1.Name) I would get Chinese garbled.

But if I just do ma.NewDecoder("gb18030").ConvertString(file1.Name) it works

既然你要 Decoder , 那么为什么 用 Encoder 来做对比呢????

上面 decer:=ma.NewDecoder("gb18030") 即可, 下面就可以直接使用.

低级错误.

ayanmw avatar Jun 29 '21 08:06 ayanmw