Skip to content

Fix #17: NewReader can't process data bigger than 8K #28

Open
MoZhonghua wants to merge 3 commits into
djimenez:masterfrom
MoZhonghua:fix8k
Open

Fix #17: NewReader can't process data bigger than 8K #28
MoZhonghua wants to merge 3 commits into
djimenez:masterfrom
MoZhonghua:fix8k

Conversation

@MoZhonghua
Copy link
Copy Markdown

I force push to my master branch occasionally and the old pull request closed automatically...

MoZhonghua added 3 commits June 18, 2016 17:02
This shoud also fix issue djimenez#25: When the amount of data will be truncated

iconv() will return EINVAL when An incomplete multibyte sequence is
encountered in the input, and the input byte sequence terminates after
it. So if the input is larger than the internal buffer of Reader and
the end of the buffer conatins partial multi-byte chars, then Reader
will failed with EINVAL.

So when iconv() return EINVAL, we checks whether there are more data to
process, if so, we continue without report an error to user.
@alphayan
Copy link
Copy Markdown

@MoZhonghua Think you,this is my code ,I use you package,it's just have 8k.Can you give me a example code.

	res, err := http.Get("http://www.apesk.com/16pf/")
	if err != nil {
		fmt.Println(err)
		return
	}
	defer res.Body.Close()
	utfBody, err := iconv.NewReader(res.Body, "gbk", "utf-8")
	if err != nil {
		fmt.Println(err)
		return
	}
	data, _ := ioutil.ReadAll(utfBody)
	fmt.Println(string(data))

@MoZhonghua
Copy link
Copy Markdown
Author

@alphayan

I switch to use "github.com/axgle/mahonia", but don't remeber why.

Please don't use github as forum, if you have other questions, send email to me directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants