On Feb 26, 2013, at 9:47 AM, "Gerriet M. Denkmann" <gerr...@mdenkmann.de> wrote:

> My investigations regarding archiving on OS X:
> 
> 1. NSArchiver stores all strings in Utf-8.
>    This is inefficient for strings which contain mainly non-european 
> characters (e.g. Chinese or Thai) as one character will use 3 bytes (Utf-16 
> would use only 2).
>    Corollary: It cannot store strings which contain illegal Unicode chars.

NSString isn't designed to handle illegal Unicode characters either, so this is 
not unexpected. 

> 
> 2. NSKeyedArchiver seems to be ok.

OK in what way? I would hope it writes UTF-8 as well, rather than NSString's 
internal UCS-2 representation.

It's a shame we can't specify an encoding hint to NSString.

>    But it does create unnecessary data. E.g. in the case of an array 
> containing identical objects, like:
>    NSArray *a = @[ @"a", @"a", ...., @"a"];
>    With 1 000 000 items it creates 10,000,395 bytes - my version creates only 
> 1 000 332 bytes 
>    and the output is still readable by NSKeyedUnarchiver.

What are these 57 bytes you saved? Is it worth saving 57 bytes for the burden 
of maintaining your own compatibility with NSKeyedArchiver?

> 
> 3, NSKeyedUnarchiver has several bugs.
>    The string $null is converted to nil. 
>    Very harmful if this string is part of a collection (like array, set or 
> dictionary).
> 
>    If the key in: encodeXXX:forKey: starts with an "$" NSKeyedArchiver 
> correctly mangles this by prefixing
>    another "$". But NSKeyedUnarchiver does not find these mangled keys and 
> returns nil or 0.

I am frustrated that this bug has been known for years and never been fixed.

> 
> I have not reported these bugs, as I am convinced that Apple has no interest 
> in fixing these problems.

This is not a helpful attitude to take.

--Kyle Sluder
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to