From 30d61191bec44b7c4e49ae42d4093fe9a86ad74b Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Mon, 12 May 2003 19:11:16 +0000 Subject: [PATCH] added CFStringRef methods git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20605 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/utils.cpp | 24 ++++++++++++++++++++++++ src/mac/utils.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index 2cb2825106..ad685519dd 100644 --- a/src/mac/carbon/utils.cpp +++ b/src/mac/carbon/utils.cpp @@ -503,3 +503,27 @@ wxString wxGetOsDescription() #endif } +#if TARGET_CARBON +// converts this string into a carbon foundation string with optional pc 2 mac encoding +void wxMacCFStringHolder::Assign( const wxString &str ) +{ + m_cfs = CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() , + wxApp::s_macDefaultEncodingIsPC ? + kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ; + m_release = true ; +} + +wxString wxMacCFStringHolder::AsString() +{ + wxString result ; + Size len = CFStringGetLength( m_cfs ) ; + wxChar* buf = result.GetWriteBuf( len ) ; + + CFStringGetCString( m_cfs , buf , len+1 , wxApp::s_macDefaultEncodingIsPC ? + kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ; + + buf[len] = 0 ; + result.UngetWriteBuf() ; + return result ; +} +#endif diff --git a/src/mac/utils.cpp b/src/mac/utils.cpp index 2cb2825106..ad685519dd 100644 --- a/src/mac/utils.cpp +++ b/src/mac/utils.cpp @@ -503,3 +503,27 @@ wxString wxGetOsDescription() #endif } +#if TARGET_CARBON +// converts this string into a carbon foundation string with optional pc 2 mac encoding +void wxMacCFStringHolder::Assign( const wxString &str ) +{ + m_cfs = CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() , + wxApp::s_macDefaultEncodingIsPC ? + kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ; + m_release = true ; +} + +wxString wxMacCFStringHolder::AsString() +{ + wxString result ; + Size len = CFStringGetLength( m_cfs ) ; + wxChar* buf = result.GetWriteBuf( len ) ; + + CFStringGetCString( m_cfs , buf , len+1 , wxApp::s_macDefaultEncodingIsPC ? + kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ; + + buf[len] = 0 ; + result.UngetWriteBuf() ; + return result ; +} +#endif