The module defines a set "encoders" which are able to encode the text into a given encoding. More encoders can be added to the module as necessary.
Function encode(text, encoding)
Takes 'text' in UTF-8 encoding, encodes into 'encoding' and into %-encoding, returns the resulting string.
<!DOCTYPE html>
<html>
<head>
<script>
function baseconvert() {
var base0 = parseInt( document.querySelector("#base0").innerText );
var base1 = parseInt( document.querySelector("#base1").innerText );
var dText0 = document.querySelector("#text0");
var dText1 = document.querySelector("#text1");
var ns = dText0.value.split("\n"); // numbers
dText1.innerHTML = "";
for (var i=0; i < ns.length; i++) {
if (i)
dText1.append( "\n" );
if ( ns.search(/^+$/gi) != -1 )
dText1.append( parseInt(ns,base0).toString(base1) ); // XX > 10 > ZZ
}
dText0.style = "32px"; // variable .text height
dText1.style = "32px";
dText0.style = dText0.scrollHeight + "px";
dText1.style = dText1.scrollHeight + "px";
}
document.addEventListener("DOMContentLoaded", function() {
baseconvert();
document.querySelector("#text0").addEventListener("input", baseconvert);
});
</script>
<style>
body {background: lightgray; display: grid; grid-template-columns: auto auto; gap: 8px;}
#desc {grid-column: 1 / -1;}
#desc, #base0, #base1 {justify-self: center; width: auto;}
#text0, #text1 {font-family: monospace, monospace; resize: none;}
</style>
</head>
<body>
<div id="desc">Convert from left to right</div>
<div id="base0" contenteditable>16</div>
<div id="base1" contenteditable>10</div>
<textarea id="text0">BADCAFE</textarea>
<textarea id="text1" readonly></textarea>
</body>
</html>
{{R:IEC2}}
(Catalan IEC dictionary) required input in ISO 8859-1 encoding:
{{#invoke:encodings|encode|abundància|ISO 8859-1}}