Implementations
Purpose
The reference implementation is intended as an easy-to-use impementation of the specification. Its results can be used to verify the results of another implementation. Or the software can just be used in any web application.
The reference implementation is also intended to become a collection of enabling functions, documented for used by developers wishing to work with Unicode higher planes in Javascript.
Integration
Under the terms of the license, the code may be downloaded and modified for use in your application. Alternatively, you may call our hosted copy of the software directly from your web application.
Versions
The current version of the reference implementation is an implementation of the current version of the specification. Software hosted here will be updated. So be warned, linking to the current version could break your application.
Static versions are also available. They adhere to the same naming as the version of the specification that they implement. Once uploaded, the same software version will be consistently hosted at that URL. Therefore it is safe for an application to link to a static version.
Priority
A reference implementation version is supposed to agree with the version of specification that it implements. If this is not the case, an error must be in either one or the other. If you observe such an error we would like to hear from you so that we can correct it.
For the avoidance of doubt, until such a problem has been resolved it is the specification that should be considered the master.
Javascript inclusion
Javascript methods are called from a web page and are executed in a web client, such as a browser.
To implement the dynamic current version of the reference implementation, include it in (the header of) your HTML like this :
<script type="text/javascript" src="http://base16b/lib/js/base16b.js"></script>
To use a static hosted version, the script is included like this :
<script type="text/javascript" src="http://base16b/lib/version/0.1/js/base16b.js"></script>
where 0.1 can be substituted by any published version number.
Public Methods
The Javascript library exposes three public methods:
encode
Takes a an array of booleans (comprising only 0 and 1) and an encoding base in the range 7 to 17. Converts it to a Base16b encoded string .
var encBase = 16;
var encStr = Base64.decode(boolArr, encBase);
decode
Takes a Base16b encoded string and converts it to an array of booleans (comprising only 0 and 1).
var boolArr = Base64.decode(encStr);
trueLength (MultiByteCharStr)
The String.length method in Javascript does not work properly for multi-byte characters. This function fixes the problem. It returns the correct number of characters in a string.
var strLength = Base64.trueLength(MB_String);