Changes

Jump to: navigation, search

ServerJS/Encodings

906 bytes added, 12:42, 6 June 2009
add implementation recommendations
For Streams, we need encodings support. There also should be a low-level API available for this.
 
= Specification =
== Encoding Names ==
: 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 in pushAccumulate) into the here given outputByteArray (appended) or a new ByteString. If outputByteArray is given, it is returned, otherwise the ByteString is returned.</u>
: <u>Also adds initial shift state sequences if required by the encoding.</u>
'''TODO''': Which exception to throw on error?
(See [[ServerJS/Encodings/OldClass]] for another API.)
 
= Implementation Recommendations =
 
First of all, it is recommended to implement convertToString, convertFromString and convert with Transcoder.
 
Secondly, you should make sure that initial shift state support is properly implemented. When you're using iconv, you need to call iconv(cd, 0, 0, &ob, &ol) in Transcoder.close(). An example of what an initial shift state is: In the Japanese ISO-2022-JP encoding, the default state are ASCII bytes. However, the state can be switched to Japanese with an escape sequence. To make sure that at the end of the text, the state is ASCII again, iconv will emit another escape sequence to switch back again. This is important if you want to concatenate ISO-2022-JP texts, and an implementation of Transcoder that doesn't properly emit these sequences is <b>broken</b>.
= Relevant Discussions =
62
edits

Navigation menu