When custom text properties get written the type gets written first and then the text. The text is however transformed into unicode (in certain cases) after the type is written, causing the property to be corrupted.
Created attachment 12578 [details] Patch
Yup, this is something I found out yesterday, too. I'll check in an equivalent patch in the evening (local time, i.e. GMT+2).