From: Jann R. <roe...@et...> - 2009-07-12 16:46:00
|
Ok, this was my fault. I forgot to call close on the encoder. Sorry about that. Jann Jann Röder schrieb: > Hello, > I am using the gobo base64 encoder to encode the managed_pointer output > generated by the SED serializer. And now I found a strange bug. In some > cases encoding and decoding of a storable works and in others it > doesn't. The decoded string is one byte too short. In the example below > the encoding and decoding of the array <<"hello", "world">> doesn't > work, while the array <<"">> can be decoded just fine. > > This is the example code that reproduces the problem: > > test_base_64_serialization_report is > -- Test the base64 encoder > local > l_ptr, l_ptr2: MANAGED_POINTER > l_array: ARRAY[STRING] > l_facilities: SED_STORABLE_FACILITIES > l_rw: SED_MEMORY_READER_WRITER > l_i: INTEGER > l_str, l_out_str: STRING > l_blob_string: UC_UTF8_STRING > l_encoder: UT_BASE64_ENCODING_OUTPUT_STREAM > l_input_stream: KL_STRING_INPUT_STREAM > l_decoder: UT_BASE64_DECODING_INPUT_STREAM > do > create l_facilities > create l_rw.make > > l_array := << "hello", "world" >> > --l_array := <<"">> > > l_facilities.independent_store (l_array, l_rw, True) > l_ptr := l_rw.data > > -- Encode > create l_blob_string.make (1000) > create l_encoder.make (l_blob_string, False, False) > from > l_i := 0 > until > l_i >= l_ptr.count > loop > l_encoder.put_character (l_ptr.read_character (l_i)) > l_i := l_i + 1 > end > l_str := l_blob_string.to_utf8 > > -- Decode > create l_input_stream.make (l_str) > create l_decoder.make (l_input_stream) > from > create l_out_str.make (l_str.count) > until > l_decoder.end_of_input > loop > l_decoder.read_string (l_str.count) > l_out_str.append (l_decoder.last_string) > end > create l_ptr2.make_from_pointer (l_out_str.area.base_address, > l_out_str.count) > check > l_ptr ~ l_ptr2 > end > end > > Thanks, > Jann > > ------------------------------------------------------------------------------ > Enter the BlackBerry Developer Challenge > This is your chance to win up to $100,000 in prizes! For a limited time, > vendors submitting new applications to BlackBerry App World(TM) will have > the opportunity to enter the BlackBerry Developer Challenge. See full prize > details at: http://p.sf.net/sfu/Challenge > _______________________________________________ > gobo-eiffel-develop mailing list > gob...@li... > https://lists.sourceforge.net/lists/listinfo/gobo-eiffel-develop |