X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a8d69700fc39bc00a1a897da71dd062a986255aa..677dc0ed1a3ff68af15f6246d6d0708d5264b07a:/src/mac/corefoundation/cfstring.cpp?ds=sidebyside diff --git a/src/mac/corefoundation/cfstring.cpp b/src/mac/corefoundation/cfstring.cpp index 8cfdec84b8..541cef0c5b 100644 --- a/src/mac/corefoundation/cfstring.cpp +++ b/src/mac/corefoundation/cfstring.cpp @@ -47,56 +47,19 @@ void wxMacConvertNewlines10To13( char * data ) } } +const wxString sCR((wxChar)13); +const wxString sLF((wxChar)10); + void wxMacConvertNewlines13To10( wxString * data ) { - size_t len = data->Length() ; - - if ( len == 0 || wxStrchr(data->c_str(),0x0d)==NULL) - return ; - - wxString temp(*data) ; - wxStringBuffer buf(*data,len ) ; - memcpy( buf , temp.c_str() , (len+1)*sizeof(wxChar) ) ; - - wxMacConvertNewlines13To10( buf ) ; + data->Replace( sCR,sLF); } void wxMacConvertNewlines10To13( wxString * data ) { - size_t len = data->Length() ; - - if ( data->Length() == 0 || wxStrchr(data->c_str(),0x0a)==NULL) - return ; - - wxString temp(*data) ; - wxStringBuffer buf(*data,len ) ; - memcpy( buf , temp.c_str() , (len+1)*sizeof(wxChar) ) ; - wxMacConvertNewlines10To13( buf ) ; + data->Replace( sLF,sCR); } - -#if wxUSE_UNICODE -void wxMacConvertNewlines13To10( wxChar * data ) -{ - wxChar * buf = data ; - while( (buf=wxStrchr(buf,0x0d)) != NULL ) - { - *buf = 0x0a ; - buf++ ; - } -} - -void wxMacConvertNewlines10To13( wxChar * data ) -{ - wxChar * buf = data ; - while( (buf=wxStrchr(buf,0x0a)) != NULL ) - { - *buf = 0x0d ; - buf++ ; - } -} -#endif - wxUint32 wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding) { TextEncodingBase enc = 0 ; @@ -633,7 +596,7 @@ wxFontEncoding wxMacGetFontEncFromSystemEnc(wxUint32 encoding) // // converts this string into a carbon foundation string with optional pc 2 mac encoding -void wxMacCFStringHolder::Assign( const wxString &st , wxFontEncoding encoding ) +void wxMacCFStringHolder::Assign( const wxString &st , wxFontEncoding WXUNUSED_IN_UNICODE(encoding) ) { Release() ; if (st.IsEmpty()) @@ -666,7 +629,7 @@ void wxMacCFStringHolder::Assign( const wxString &st , wxFontEncoding encoding ) m_release = true ; } -wxString wxMacCFStringHolder::AsString(wxFontEncoding encoding) +wxString wxMacCFStringHolder::AsString(wxFontEncoding WXUNUSED_IN_UNICODE(encoding)) { if ( m_cfs == NULL ) return wxEmptyString ; @@ -703,9 +666,9 @@ wxString wxMacCFStringHolder::AsString(wxFontEncoding encoding) #endif buf[noChars] = 0 ; - wxMacConvertNewlines10To13( buf ) ; wxString result(buf) ; delete[] buf ; + wxMacConvertNewlines10To13( &result); return result ; }