Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

MoZhonghua
Copy link

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

@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
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