Changes

Jump to: navigation, search

ServerJS/Encodings

41 bytes added, 09:02, 10 April 2009
Class: Converter: => Transcoder
: encodingCheckerFunction takes the encoding name as a parameter and returns true-ish if the encoding should be listed. Regexes should also be supported. If the parameter is missing, returns all supported encodings.
=== Class: Converter Transcoder ===
There also should be a class enc.Converter Transcoder for more advanced general transcoding conversion (transcodingbetween ByteStrings or ByteArrays).
; [Constructor] ConverterTranscoder(from, to)
: Where from and to are the encoding names.
; [Method] push(byteStringOrArray[, outputByteArray])
Example:
Converter Transcoder = require('encodings').ConverterTranscoder converter transcoder = new ConverterTranscoder('iso-8859-1', 'utf-32') output = convertertranscoder.push(input) // input is a ByteString, and output too convertertranscoder.close()
Another example:
converter transcoder = new ConverterTranscoder('utf-32', 'utf-8')
output = new ByteArray()
while (input = readSomeByteFromSomewhere()) {
convertertranscoder.push(input, output)
}
convertertranscoder.close()
// output is the complete conversion of all the input chunks concatenated now
(See [[ServerJS/Encodings/OldClass]] for another API.)
62
edits

Navigation menu