Changes

Jump to: navigation, search

ServerJS/Encodings

884 bytes added, 22:22, 9 April 2009
API: fix example, add alternative API proposal
Converter = require('encodings').Converter
converter = new Converter('iso-8859-1', 'utf-32')
converter.pushwrite(input) // input is a ByteString output = converter.getread() // output is a ByteString converter.close() === Alternative: Converter === There is another way the Converter interface could work. ; [Constructor] Converter(from, to): Where from and to are the encoding names.; [Method] push(byteStringOrArray): Convert input from a ByteString or ByteArray. The results are stored in an internal buffer, and also those parts of byteStringOrArray that could not be converted (for multi-byte encodings, in a separate buffer).: Returns (as a ByteString) as much as could be converted.; [Method] close(): Close the stream. Throws an exception if there was a conversion error (specifically, a partial multibyte character).: Returns nothing and takes no parameters. Example:  Converter = require('encodings').Converter converter = new Converter('iso-8859-1', 'utf-32') output = converter.push(input) // input is a ByteString, and output too converter.close()
62
edits

Navigation menu