Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.
Daniel Wirtz edited this page Jun 25, 2014 · 35 revisions

Welcome to the utfx wiki!

Using array and string arguments

  • Getting all UTF8 code points in a standard JavaScript string:

    var string = ...;
    var codepoints = []; utfx.UTF16toUTF8(string, codepoints);
  • Decoding an array of UTF8 bytes to UTF8 code points:

    var bytes = [...];
    var codepoints = []; utfx.decodeUTF8(bytes, codepoints);
  • Encoding a standard JavaScript string as UTF8 bytes:

    var string = ...;
    var bytes = []; utfx.UTF16toUTF8Bytes(string, bytes);
  • Decoding an array of UTF8 bytes to a standard JavaScript string:

    var bytes = [...];
    var string = utfx.UTF8BytesToUTF16(bytes);

Using source and destination functions

  • Converting an arbitrary input source of UTF16 characters to an arbitrary output destination of UTF8 code points:

    var string = ..., i = 0;
    utfx.UTF16toUTF8(function() {
        return i < string.length ? string.charCodeAt(i++) : null;
    }, function(cp) {
        ...
    });
  • Encoding an arbitrary input source of UTF8 code points to an arbitrary output destination of UTF8 bytes:

    var codepoints = [...], i = 0;
    utfx.encodeUTF8(function() {
        return i < codepoints.length ? codepoints[i++] : null;
    }, function(b) {
        ...
    });


* [FAQ](./#faq) * [Examples](./#examples)
Clone this wiki locally