MCPcopy Create free account
hub / github.com/andris9/encoding / convertIconvLite

Function convertIconvLite

lib/encoding.js:57–65  ·  view source on GitHub ↗

* Convert encoding of astring with iconv-lite * * @param {String|Buffer} str String to be converted * @param {String} to Encoding to be converted to * @param {String} [from='UTF-8'] Encoding to be converted from * @return {Buffer} Encoded string

(str, to, from)

Source from the content-addressed store, hash-verified

55 * @return {Buffer} Encoded string
56 */
57function convertIconvLite(str, to, from) {
58 if (to === 'UTF-8') {
59 return iconvLite.decode(str, from);
60 } else if (from === 'UTF-8') {
61 return iconvLite.encode(str, to);
62 } else {
63 return iconvLite.encode(iconvLite.decode(str, from), to);
64 }
65}
66
67/**
68 * Converts charset name if needed

Callers 1

convertFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected