realbasic-plugins
[Top] [All Lists]

Re: CFStrings on Win32

To: REALbasic Plugins <realbasic-plugins at lists dot realsoftware dot com>
Subject: Re: CFStrings on Win32
From: Dave Addey <listmail1 at dsl dot pipex dot com>
Date: Thu, 26 Jan 2006 18:37:02 +0000
Delivered-to: realbasic-plugins at lists dot realsoftware dot com
Thread-index: AcYijmHpoDrAMo6BEdqMlQAKldpEygAFHOsJAAEqeKc=
Thread-topic: CFStrings on Win32
Hi Chris,

Thanks for the advice!  Unfortunately, it doesn't seem to make a difference
which encoding I use.  The default encoding of the string (if I don't
explicitly set it to anything else) is UTF8, but Windows Latin 1 has the
same problem.

Here's how I get the string...

Firstly, it's defined as part of a parameters struct:

typedef struct
{
    // -------- Input parameters
    UInt32      NumberOfMoviesNeeded;
    UInt32      NumberOfTracksPerMovieNeeded;
    REALstring  Location;

    // other stuff...

} SongLoaderData, *SongLoaderDataRef;


The values of the string are set using a custom get and set method:


static REALstring LocationGetter (REALobject instance, long param)
{
    ClassData (RB_SongLoader, instance, RB_SongLoaderData, me);
    SongLoaderDataRef myParameters = (SongLoaderDataRef)me->myParametersRef;
    return myParameters->Location;
}

static void LocationSetter (REALobject instance, long param, REALstring
value)
{
    ClassData (RB_SongLoader, instance, RB_SongLoaderData, me);
    SongLoaderDataRef myParameters = (SongLoaderDataRef)me->myParametersRef;
    myParameters->Location = value;
    REALLockString(myParameters->Location);
}


I've include these as it seems that it's the result of REALCString is screwy
- on Windows, it returns a whole bunch of characters, rather than the URL I
would expect.  So I wondered if I'm doing something wrong in my access of
the strings.

The kind of thing I'm storing in the string is:

file://localhost:/C:/Documents%20and%20Settings/Dave/My%20Documents/My%20Mus
ic/iTunes/iTunes%20Music/Mark%20Eitzel/Songs%20Of%20Love%20Live/Firefly.m4a

I just seem to be getting junk back out of REALCString on windows.  As I
say, it works fine on MachO.  Any other things I can try for
experimentation?  Any other way for me to extract the string contents from
the REALstring?

Dave.

> From: Chris Little <cslittle at mac dot com>
> Reply-To: REALbasic Plugins <realbasic-plugins at lists dot realsoftware dot 
> com>
> Date: Thu, 26 Jan 2006 13:03:39 -0500
> To: REALbasic Plugins <realbasic-plugins at lists dot realsoftware dot com>
> Conversation: CFStrings on Win32
> Subject: Re: CFStrings on Win32
> 
> on 1/26/06 10:37 AM, Dave Addey at listmail1 at dsl dot pipex dot com wrote:
> 
>> Hi all,
>> 
>> I¹ve got my Win32 QuickTime-using plugin compiling now, pretty much.  But,
>> one thing is causing me problems.  I need to convert a REALstring into a
>> CFString ­ on Windows.  And I can¹t find a way to do so.
>> 
>> ³But surely there isn¹t such a thing as CFString on Windows?², you cry.
>> Well, if you have the QuickTime Windows SDK installed, it contains a whole
>> bunch of Win32 wrappers for common mac types such as all the CFObjects, and
>> also lots of CoreAudio types.  It uses these wrappers to provide a common
>> API on Mac and Windows.  So, it expects the (wrapper) CFStrings, CFURLs and
>> so on on Win32 too.
>> 
>> I tried this (where inParameters->Location is a REALstring):
>> 
>>         const char *LocationCString = REALCString(inParameters->Location);
>>         if (LocationCString == NULL)
>>         {
>>             return -1;
>>         }
>>  
>>         CFStringRef LocationCFString = CFStringCreateWithCString(NULL,
>> LocationCString, REALGetStringEncoding(inParameters->Location));
>>         if (LocationCFString == NULL)
>>         {
>>             return -1;
>>         }
>> 
>> This second call always returns NULL.
>> 
>> I tried passing the output from REALCString to the Windows debugging
>> function OutputDebugString:
>> 
>>         OutputDebugString(LocationCString);
>> 
>> ...and I got a whole bunch of high-ASCII mixed characters, not what I was
>> expecting at all.  On a MachO compile, the string is returned as expected
>> and the CFString is created okay.
>> 
>> Any ideas?  Are CStrings different on Windows somehow?  Help much
>> appreciated, as I¹m at a loose end without a way to get a CFString.
>> 
> 
> It may be an encoding issue.  Have you tried simple string using
> kCFStringEncodingWindowsLatin1 for the encoding?  What is the encoding of
> the string?
> 
> Chris
> 
> 
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> 
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>


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

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


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