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 12:36:09 -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>
On Mar 29, 2008, at 11:10 AM, James Sentman wrote:

> I"m sure Joe is correct when he suggests you're hitting a text
> encoding issue. I understand and even acknowledge the necessity of
> text encoding, but despise is not too strong a word for how I feel
> towards the implementation we're using.

Why's that?  In most cases you don't have to worry about it in RB;  
the defaults do sensible things and everything just works, except of  
course when interacting with some external data source that's not  
Unicode-savvy.  On the whole, I think it's pretty elegant.

> However, once you read it in from ReadPString it doesn't
> know that anymore as the encodings aren't saved along with the binary
> data.

As they shouldn't be, since the point of WritePString and ReadPString  
is to interact with old MacOS9 systems, which didn't store encoding  
data nor use Unicode, but generally assumed that all strings were in  
the default WorldScript encoding.

> So, regardless of how you write the string, you may have to redefine
> the encoding when you read it back in.

No, if you use a TextInputStream, the encoding will be (correctly)  
defined as UTF-8 by default.

> To solve it across the board I believe that you can set the encoding
> that is the default for the binary stream? And even if you do that I"m
> not sure that readPString will honor that because as Joe says it's an
> old call that was never text encoding savvy.

Right, but the proper way to avoid that problem is to quite using  
Read/WritePString.

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>