realbasic-nug
[Top] [All Lists]

Re: WritePString weirdness...

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: WritePString weirdness...
From: Joe Strout <joe at inspiringapps dot com>
Date: Sat, 29 Mar 2008 20:46:39 -0600
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <226027DE-9E67-4701-90AD-12E8F3383CF6 at rbclass dot com> <A652AB13-FCF7-4D95-B6B1-5EC6EC3E84DE at inspiringapps dot com> <3E14F3DA-1A0F-47A7-A23A-5561C8EFDFC3 at rbclass dot com> <A0720DC7-6E68-4825-B1E7-06FA772B07E7 at inspiringapps dot com> <A08DAFF0-4131-4C31-BE88-965126CC576F at rbclass dot com> <09004169-C758-401C-BF6E-6FB615336097 at rbclass dot com> <1BD9DBC6-83AA-42FF-912E-010229927261 at sentman dot com> <7FAFCF2F-6532-42EC-B2DD-F1151D4F8627 at inspiringapps dot com> <58BF1847-25A7-4E65-8114-FB91CF483883 at sentman dot com>
On Mar 29, 2008, at 5:30 PM, James Sentman wrote:

> I guess it's mostly because of my recent bad experiences with it ;) Un
> leopard Apple forced all strings in AppleScripts to UTF16 and I use
> RB's default of UTF8, and RB doesn't know that the strings now coming
> from AppleEvents are no longer binary equivalent so for example I
> can't look up objects in a dictionary by name to resolve an apple
> script object request anymore.

OK, I see your point there.  Dictionaries are the one place where  
strings of different encodings are not functionally equivalent.   
Unfortunately, that would be hard to fix... but I could see an  
argument for a "ForceEncoding" flag on them that would automatically  
convert all strings stuffed into (or looked up) a particular  
Dictionary, to help deal with cases like this.

> And I've found cases where some encodings seem to cause random crashes
> when putting things into CFObjects...

I haven't heard of that, but CFObject isn't on RB type, so I guess  
this would fall into the incorrectly-coded-declare category.  Not  
much RB can do about that.

> lots of little things like that where I find
> I have to deal with it when I shouldn't. If you're just using RB
> inside RB then it rarely becoms an issue, but when you talk to other
> things then all of a sudden things dont always work and sorting it out
> is not always obvious.

True enough.

>> Right, but the proper way to avoid that problem is to quite using
>> Read/WritePString.
>
> But... if I just use write/read it still doesn't save that does it?
> It's a binary stream and if you use that you have to deal with
> resetting the encoding.

Well yes, but BinaryStream.Read has an (optional) Encoding parameter  
you can use to specify the encoding right away, unlike ReadPString.

> Is there anything wrong with PStrings except
> that they dont preserve encoding?

Yes, there's the fact that they don't give you a way to specify the  
encoding in the read operation, and that they break if you try to  
store a string more than 255 bytes, and that they imply (though don't  
force) a WorldScript encoding.

Best,
- Joe

--
Joe Strout
Inspiring Applications, Inc.
http://www.InspiringApps.com



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>