Changes

Jump to: navigation, search

ServerJS/Encodings

234 bytes added, 12:23, 6 June 2009
Class: Transcoder: split push into push and pushAccumulate
; [Method] push(byteStringOrArray[, outputByteArray])
: Convert input from a ByteString or ByteArray. Those parts of byteStringOrArray that could not be converted (for multi-byte encodings) are stored in a buffer. If outputByteArray is passed, the results are ''appended'' to outputByteArray.
: If outputByteArray was passed, returns outputByteArray, otherwise returns <u>nothing and the output is converted bytes as a ByteString</u>.: <u>The result will also contain bytes accumulated in prior calls to pushAccumulate.</u>; <u>[Method] pushAccumulate(byteStringOrArray)</u>: <u>Convert input from a ByteString or ByteArray into an internal bufferthat will be read out the next time push or close is called.</u>
; [Method] close([outputByteArray])
: Close the stream. Throws an exception if there was a conversion error (specifically, a partial multibyte character).
: <u>Writes the remaining output bytes (including those that were accumulated because push was called without an outputByteArrayin pushAccumulate) into the here given outputByteArray (appended) or a new ByteString. If outputByteArray is given, it is returned, otherwise the ByteString is returned.</u>
'''TODO''': Which exception to throw on error?
Transcoder = require('encodings').Transcoder
transcoder = new Transcoder('iso-8859-1', 'utf-32')
transcoder.pushpushAccumulate(input) // input is a ByteString
output = transcoder.close() // and output is a ByteString too
62
edits

Navigation menu