+//
+// CFStringRefs (Carbon only)
+//
+
+#if TARGET_CARBON
+// converts this string into a carbon foundation string with optional pc 2 mac encoding
+void wxMacCFStringHolder::Assign( const wxString &str )
+{
+#if wxUSE_UNICODE
+ m_cfs = CFStringCreateWithCharacters( kCFAllocatorDefault,
+ (const unsigned short*)str.wc_str(), str.Len() );
+#else
+ m_cfs = CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() ,
+ wxApp::s_macDefaultEncodingIsPC ?
+ kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ;
+#endif
+ m_release = true ;
+}
+
+wxString wxMacCFStringHolder::AsString()
+{
+ wxString result ;
+ Size len = CFStringGetLength( m_cfs ) ;
+ wxChar* buf = result.GetWriteBuf( len ) ;
+#if wxUSE_UNICODE
+ CFStringGetCharacters( m_cfs , CFRangeMake( 0 , len ) , (UniChar*) buf ) ;
+#else
+ CFStringGetCString( m_cfs , buf , len+1 , wxApp::s_macDefaultEncodingIsPC ?
+ kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ;
+#endif
+ buf[len] = 0 ;
+ result.UngetWriteBuf() ;
+ return result ;
+}
+
+#if 0
+
+wxString wxMacMakeMacStringFromPC( const wxChar * p )
+{
+ wxString result ;
+ int len = wxStrlen ( p ) ;
+ if ( len > 0 )
+ {
+ wxChar* ptr = result.GetWriteBuf(len) ;
+ wxMacConvertFromPC( p , ptr , len ) ;
+ ptr[len] = 0 ;
+ result.UngetWriteBuf( len ) ;
+ }
+ return result ;
+}
+
+wxString wxMacMakePCStringFromMac( const wxChar * p )
+{
+ wxString result ;
+ int len = wxStrlen ( p ) ;
+ if ( len > 0 )
+ {
+ wxChar* ptr = result.GetWriteBuf(len) ;
+ wxMacConvertToPC( p , ptr , len ) ;
+ ptr[len] = 0 ;
+ result.UngetWriteBuf( len ) ;
+ }
+ return result ;
+}
+
+wxString wxMacMakeStringFromMacString( const wxChar* from , bool mac2pcEncoding )