Fix converting long Text to JS string

In (at least) iOS Safari, converting a long Text (over 65536 chars) to a JS string fails due to `apply`ing a large array as function arguments to `String.fromCharCode`; see https://bugs.webkit.org/show_bug.cgi?id=80797.
This breaks the array up into chunks that fit under this limit, concatenating the strings as it goes.
A quick search says there might be a few more `String.fromCharCode.apply` calls nearby with the same issue, but this patch successfully fixed the conversion for me.