src/StringWriter.js
function __encode_utf8(text) {

        // Fill buffer with UTF-8
        for (var i=0; i<text.length; i++) {
            var codepoint = text.charCodeAt(i);
            __append_utf8(codepoint);
        }

        // Flush buffer
        if (length > 0) {
            var out_buffer = buffer.subarray(0, length);
            length = 0;
            return out_buffer;
        }

    }
function __encode_utf8(text) {

        // Fill buffer with UTF-8
        for (var i=0; i<text.length; i++) {
            var codepoint = text.charCodeAt(i);
            __append_utf8(codepoint);
        }

        // Flush buffer
        if (length > 0) {
            var out_buffer = buffer.subarray(0, length);
            length = 0;
            return out_buffer;
        }

    }
function __encode_utf8 ( text ) { // Fill buffer with UTF-8 for ( var i = 0 ; i < text . length ; i ++ ) { var codepoint = text . charCodeAt ( i ) ; __append_utf8 ( codepoint ) ; } // Flush buffer if ( length > 0 ) { var out_buffer = buffer . subarray ( 0 , length ) ; length = 0 ; return out_buffer ; } }
Encodes the given string as UTF-8, returning an ArrayBuffer containing
the resulting bytes.

@private
@param {String} text The string to encode as UTF-8.
@return {Uint8Array} The encoded UTF-8 data.
Encodes the given string as UTF - 8 returning an ArrayBuffer containing the resulting bytes .