Jul 12, 2010 at 9:50 PM
Edited Jul 12, 2010 at 9:54 PM
There seems to be an issue with the GetString method with greek strings over 128 bytes long.
The following object:
"SerializableNotes": "ΕΝΤΟΛΗ ΧΧΧ ΧΧΧΧΧΧΧΧΧ ΤΑ ΠΡΩΤΑΣΦΑΛΙΣΤΗΡΙΑ ΠΟΥ ΔΕΝ ΕΧΟΥΝ ΥΠΟΛΟΙΠΟ ΝΑ ΤΑ ΣΤΕΛΝΟΥΜΕ ΑΠΕΥΘΕΙΑΣ ΣΤΟΥΣ ΠΕΛΑΤΕΣ"
when serialized in bson will always throw an exception when I try to deserialize it. While the serialization works as expected (190 bytes length + 1) when deserializing the length
is not calculated correctly and as a result it takes the trailing x0 (null char) into the buffer. I was not able to pin-point the problem but my naive solution was to change the GetString
implementation into :
private string GetString(int length)
if (length == 0)
byte buf = new byte[length];
_reader.BaseStream.Read(buf, 0, length);
return new string(Encoding.UTF8.GetChars(buf));
which seems to work (at least according to both the supplied and my project's unit tests).
Any ideas ?