1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/corefoundation/cfstring.cpp
3 // Purpose: wxCFStringHolder and other string functions
4 // Author: Stefan Csomor
6 // Created: 2004-10-29 (from code in src/osx/carbon/utils.cpp)
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 // Usage: Darwin (base library)
11 /////////////////////////////////////////////////////////////////////////////
13 #include "wx/wxprec.h"
16 #include "wx/string.h"
23 #include "wx/osx/core/cfstring.h"
25 #include <CoreFoundation/CoreFoundation.h>
27 void wxMacConvertNewlines13To10( char * data
)
30 while( (buf
=strchr(buf
,0x0d)) != NULL
)
37 void wxMacConvertNewlines10To13( char * data
)
40 while( (buf
=strchr(buf
,0x0a)) != NULL
)
47 const wxString
sCR((wxChar
)13);
48 const wxString
sLF((wxChar
)10);
50 void wxMacConvertNewlines13To10( wxString
* data
)
52 data
->Replace( sCR
,sLF
);
55 void wxMacConvertNewlines10To13( wxString
* data
)
57 data
->Replace( sLF
,sCR
);
60 wxUint32
wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding
)
62 CFStringEncoding enc
= 0 ;
63 if ( encoding
== wxFONTENCODING_DEFAULT
)
66 encoding
= wxFont::GetDefaultEncoding() ;
68 encoding
= wxFONTENCODING_SYSTEM
; // to be set below
72 if ( encoding
== wxFONTENCODING_SYSTEM
)
74 enc
= CFStringGetSystemEncoding();
79 case wxFONTENCODING_ISO8859_1
:
80 enc
= kCFStringEncodingISOLatin1
;
82 case wxFONTENCODING_ISO8859_2
:
83 enc
= kCFStringEncodingISOLatin2
;
85 case wxFONTENCODING_ISO8859_3
:
86 enc
= kCFStringEncodingISOLatin3
;
88 case wxFONTENCODING_ISO8859_4
:
89 enc
= kCFStringEncodingISOLatin4
;
91 case wxFONTENCODING_ISO8859_5
:
92 enc
= kCFStringEncodingISOLatinCyrillic
;
94 case wxFONTENCODING_ISO8859_6
:
95 enc
= kCFStringEncodingISOLatinArabic
;
97 case wxFONTENCODING_ISO8859_7
:
98 enc
= kCFStringEncodingISOLatinGreek
;
100 case wxFONTENCODING_ISO8859_8
:
101 enc
= kCFStringEncodingISOLatinHebrew
;
103 case wxFONTENCODING_ISO8859_9
:
104 enc
= kCFStringEncodingISOLatin5
;
106 case wxFONTENCODING_ISO8859_10
:
107 enc
= kCFStringEncodingISOLatin6
;
109 case wxFONTENCODING_ISO8859_13
:
110 enc
= kCFStringEncodingISOLatin7
;
112 case wxFONTENCODING_ISO8859_14
:
113 enc
= kCFStringEncodingISOLatin8
;
115 case wxFONTENCODING_ISO8859_15
:
116 enc
= kCFStringEncodingISOLatin9
;
119 case wxFONTENCODING_KOI8
:
120 enc
= kCFStringEncodingKOI8_R
;
122 case wxFONTENCODING_ALTERNATIVE
: // MS-DOS CP866
123 enc
= kCFStringEncodingDOSRussian
;
126 case wxFONTENCODING_BULGARIAN :
130 case wxFONTENCODING_CP437
:
131 enc
=kCFStringEncodingDOSLatinUS
;
133 case wxFONTENCODING_CP850
:
134 enc
= kCFStringEncodingDOSLatin1
;
136 case wxFONTENCODING_CP852
:
137 enc
= kCFStringEncodingDOSLatin2
;
139 case wxFONTENCODING_CP855
:
140 enc
= kCFStringEncodingDOSCyrillic
;
142 case wxFONTENCODING_CP866
:
143 enc
=kCFStringEncodingDOSRussian
;
145 case wxFONTENCODING_CP874
:
146 enc
= kCFStringEncodingDOSThai
;
148 case wxFONTENCODING_CP932
:
149 enc
= kCFStringEncodingDOSJapanese
;
151 case wxFONTENCODING_CP936
:
152 enc
= kCFStringEncodingDOSChineseSimplif
;
154 case wxFONTENCODING_CP949
:
155 enc
= kCFStringEncodingDOSKorean
;
157 case wxFONTENCODING_CP950
:
158 enc
= kCFStringEncodingDOSChineseTrad
;
161 case wxFONTENCODING_CP1250
:
162 enc
= kCFStringEncodingWindowsLatin2
;
164 case wxFONTENCODING_CP1251
:
165 enc
=kCFStringEncodingWindowsCyrillic
;
167 case wxFONTENCODING_CP1252
:
168 enc
=kCFStringEncodingWindowsLatin1
;
170 case wxFONTENCODING_CP1253
:
171 enc
= kCFStringEncodingWindowsGreek
;
173 case wxFONTENCODING_CP1254
:
174 enc
= kCFStringEncodingWindowsLatin5
;
176 case wxFONTENCODING_CP1255
:
177 enc
=kCFStringEncodingWindowsHebrew
;
179 case wxFONTENCODING_CP1256
:
180 enc
=kCFStringEncodingWindowsArabic
;
182 case wxFONTENCODING_CP1257
:
183 enc
= kCFStringEncodingWindowsBalticRim
;
186 case wxFONTENCODING_UTF7
:
187 enc
= CreateTextEncoding(kCFStringEncodingUnicodeDefault
,0,kUnicodeUTF7Format
) ;
190 case wxFONTENCODING_UTF8
:
191 enc
= kCFStringEncodingUTF8
;
193 case wxFONTENCODING_EUC_JP
:
194 enc
= kCFStringEncodingEUC_JP
;
196 case wxFONTENCODING_UTF16BE
:
197 enc
= kCFStringEncodingUTF16BE
;
199 case wxFONTENCODING_UTF16LE
:
200 enc
= kCFStringEncodingUTF16LE
;
202 case wxFONTENCODING_UTF32BE
:
203 enc
= kCFStringEncodingUTF32BE
;
205 case wxFONTENCODING_UTF32LE
:
206 enc
= kCFStringEncodingUTF32LE
;
209 case wxFONTENCODING_MACROMAN
:
210 enc
= kCFStringEncodingMacRoman
;
212 case wxFONTENCODING_MACJAPANESE
:
213 enc
= kCFStringEncodingMacJapanese
;
215 case wxFONTENCODING_MACCHINESETRAD
:
216 enc
= kCFStringEncodingMacChineseTrad
;
218 case wxFONTENCODING_MACKOREAN
:
219 enc
= kCFStringEncodingMacKorean
;
221 case wxFONTENCODING_MACARABIC
:
222 enc
= kCFStringEncodingMacArabic
;
224 case wxFONTENCODING_MACHEBREW
:
225 enc
= kCFStringEncodingMacHebrew
;
227 case wxFONTENCODING_MACGREEK
:
228 enc
= kCFStringEncodingMacGreek
;
230 case wxFONTENCODING_MACCYRILLIC
:
231 enc
= kCFStringEncodingMacCyrillic
;
233 case wxFONTENCODING_MACDEVANAGARI
:
234 enc
= kCFStringEncodingMacDevanagari
;
236 case wxFONTENCODING_MACGURMUKHI
:
237 enc
= kCFStringEncodingMacGurmukhi
;
239 case wxFONTENCODING_MACGUJARATI
:
240 enc
= kCFStringEncodingMacGujarati
;
242 case wxFONTENCODING_MACORIYA
:
243 enc
= kCFStringEncodingMacOriya
;
245 case wxFONTENCODING_MACBENGALI
:
246 enc
= kCFStringEncodingMacBengali
;
248 case wxFONTENCODING_MACTAMIL
:
249 enc
= kCFStringEncodingMacTamil
;
251 case wxFONTENCODING_MACTELUGU
:
252 enc
= kCFStringEncodingMacTelugu
;
254 case wxFONTENCODING_MACKANNADA
:
255 enc
= kCFStringEncodingMacKannada
;
257 case wxFONTENCODING_MACMALAJALAM
:
258 enc
= kCFStringEncodingMacMalayalam
;
260 case wxFONTENCODING_MACSINHALESE
:
261 enc
= kCFStringEncodingMacSinhalese
;
263 case wxFONTENCODING_MACBURMESE
:
264 enc
= kCFStringEncodingMacBurmese
;
266 case wxFONTENCODING_MACKHMER
:
267 enc
= kCFStringEncodingMacKhmer
;
269 case wxFONTENCODING_MACTHAI
:
270 enc
= kCFStringEncodingMacThai
;
272 case wxFONTENCODING_MACLAOTIAN
:
273 enc
= kCFStringEncodingMacLaotian
;
275 case wxFONTENCODING_MACGEORGIAN
:
276 enc
= kCFStringEncodingMacGeorgian
;
278 case wxFONTENCODING_MACARMENIAN
:
279 enc
= kCFStringEncodingMacArmenian
;
281 case wxFONTENCODING_MACCHINESESIMP
:
282 enc
= kCFStringEncodingMacChineseSimp
;
284 case wxFONTENCODING_MACTIBETAN
:
285 enc
= kCFStringEncodingMacTibetan
;
287 case wxFONTENCODING_MACMONGOLIAN
:
288 enc
= kCFStringEncodingMacMongolian
;
290 case wxFONTENCODING_MACETHIOPIC
:
291 enc
= kCFStringEncodingMacEthiopic
;
293 case wxFONTENCODING_MACCENTRALEUR
:
294 enc
= kCFStringEncodingMacCentralEurRoman
;
296 case wxFONTENCODING_MACVIATNAMESE
:
297 enc
= kCFStringEncodingMacVietnamese
;
299 case wxFONTENCODING_MACARABICEXT
:
300 enc
= kCFStringEncodingMacExtArabic
;
302 case wxFONTENCODING_MACSYMBOL
:
303 enc
= kCFStringEncodingMacSymbol
;
305 case wxFONTENCODING_MACDINGBATS
:
306 enc
= kCFStringEncodingMacDingbats
;
308 case wxFONTENCODING_MACTURKISH
:
309 enc
= kCFStringEncodingMacTurkish
;
311 case wxFONTENCODING_MACCROATIAN
:
312 enc
= kCFStringEncodingMacCroatian
;
314 case wxFONTENCODING_MACICELANDIC
:
315 enc
= kCFStringEncodingMacIcelandic
;
317 case wxFONTENCODING_MACROMANIAN
:
318 enc
= kCFStringEncodingMacRomanian
;
320 case wxFONTENCODING_MACCELTIC
:
321 enc
= kCFStringEncodingMacCeltic
;
323 case wxFONTENCODING_MACGAELIC
:
324 enc
= kCFStringEncodingMacGaelic
;
326 case wxFONTENCODING_MACKEYBOARD
:
327 enc
= 41; /* kTextEncodingMacKeyboardGlyphs ; */
329 default : // to make gcc happy
335 wxFontEncoding
wxMacGetFontEncFromSystemEnc(wxUint32 encoding
)
337 wxFontEncoding enc
= wxFONTENCODING_DEFAULT
;
341 case kCFStringEncodingISOLatin1
:
342 enc
= wxFONTENCODING_ISO8859_1
;
344 case kCFStringEncodingISOLatin2
:
345 enc
= wxFONTENCODING_ISO8859_2
;
347 case kCFStringEncodingISOLatin3
:
348 enc
= wxFONTENCODING_ISO8859_3
;
350 case kCFStringEncodingISOLatin4
:
351 enc
= wxFONTENCODING_ISO8859_4
;
353 case kCFStringEncodingISOLatinCyrillic
:
354 enc
= wxFONTENCODING_ISO8859_5
;
356 case kCFStringEncodingISOLatinArabic
:
357 enc
= wxFONTENCODING_ISO8859_6
;
359 case kCFStringEncodingISOLatinGreek
:
360 enc
= wxFONTENCODING_ISO8859_7
;
362 case kCFStringEncodingISOLatinHebrew
:
363 enc
= wxFONTENCODING_ISO8859_8
;
365 case kCFStringEncodingISOLatin5
:
366 enc
= wxFONTENCODING_ISO8859_9
;
368 case kCFStringEncodingISOLatin6
:
369 enc
= wxFONTENCODING_ISO8859_10
;
371 case kCFStringEncodingISOLatin7
:
372 enc
= wxFONTENCODING_ISO8859_13
;
374 case kCFStringEncodingISOLatin8
:
375 enc
= wxFONTENCODING_ISO8859_14
;
377 case kCFStringEncodingISOLatin9
:
378 enc
=wxFONTENCODING_ISO8859_15
;
381 case kCFStringEncodingKOI8_R
:
382 enc
= wxFONTENCODING_KOI8
;
386 enc = wxFONTENCODING_BULGARIAN;
389 case kCFStringEncodingDOSLatinUS
:
390 enc
= wxFONTENCODING_CP437
;
392 case kCFStringEncodingDOSLatin1
:
393 enc
= wxFONTENCODING_CP850
;
395 case kCFStringEncodingDOSLatin2
:
396 enc
=wxFONTENCODING_CP852
;
398 case kCFStringEncodingDOSCyrillic
:
399 enc
= wxFONTENCODING_CP855
;
401 case kCFStringEncodingDOSRussian
:
402 enc
= wxFONTENCODING_CP866
;
404 case kCFStringEncodingDOSThai
:
405 enc
=wxFONTENCODING_CP874
;
407 case kCFStringEncodingDOSJapanese
:
408 enc
= wxFONTENCODING_CP932
;
410 case kCFStringEncodingDOSChineseSimplif
:
411 enc
= wxFONTENCODING_CP936
;
413 case kCFStringEncodingDOSKorean
:
414 enc
= wxFONTENCODING_CP949
;
416 case kCFStringEncodingDOSChineseTrad
:
417 enc
= wxFONTENCODING_CP950
;
420 case kCFStringEncodingWindowsLatin2
:
421 enc
= wxFONTENCODING_CP1250
;
423 case kCFStringEncodingWindowsCyrillic
:
424 enc
= wxFONTENCODING_CP1251
;
426 case kCFStringEncodingWindowsLatin1
:
427 enc
= wxFONTENCODING_CP1252
;
429 case kCFStringEncodingWindowsGreek
:
430 enc
= wxFONTENCODING_CP1253
;
432 case kCFStringEncodingWindowsLatin5
:
433 enc
= wxFONTENCODING_CP1254
;
435 case kCFStringEncodingWindowsHebrew
:
436 enc
= wxFONTENCODING_CP1255
;
438 case kCFStringEncodingWindowsArabic
:
439 enc
= wxFONTENCODING_CP1256
;
441 case kCFStringEncodingWindowsBalticRim
:
442 enc
=wxFONTENCODING_CP1257
;
444 case kCFStringEncodingEUC_JP
:
445 enc
= wxFONTENCODING_EUC_JP
;
448 case kCFStringEncodingUTF8
:
449 enc
= wxFONTENCODING_UTF8
;
451 case kCFStringEncodingUTF16BE
:
452 enc
= wxFONTENCODING_UTF16BE
;
454 case kCFStringEncodingUTF16LE
:
455 enc
= wxFONTENCODING_UTF16LE
;
457 case kCFStringEncodingUTF32BE
:
458 enc
= wxFONTENCODING_UTF32BE
;
460 case kCFStringEncodingUTF32LE
:
461 enc
= wxFONTENCODING_UTF32LE
;
465 case wxFONTENCODING_UTF7
:
466 enc
= CreateTextEncoding(kCFStringEncodingUnicodeDefault
,0,kUnicodeUTF7Format
) ;
469 case kCFStringEncodingMacRoman
:
470 enc
= wxFONTENCODING_MACROMAN
;
472 case kCFStringEncodingMacJapanese
:
473 enc
= wxFONTENCODING_MACJAPANESE
;
475 case kCFStringEncodingMacChineseTrad
:
476 enc
= wxFONTENCODING_MACCHINESETRAD
;
478 case kCFStringEncodingMacKorean
:
479 enc
= wxFONTENCODING_MACKOREAN
;
481 case kCFStringEncodingMacArabic
:
482 enc
=wxFONTENCODING_MACARABIC
;
484 case kCFStringEncodingMacHebrew
:
485 enc
= wxFONTENCODING_MACHEBREW
;
487 case kCFStringEncodingMacGreek
:
488 enc
= wxFONTENCODING_MACGREEK
;
490 case kCFStringEncodingMacCyrillic
:
491 enc
= wxFONTENCODING_MACCYRILLIC
;
493 case kCFStringEncodingMacDevanagari
:
494 enc
= wxFONTENCODING_MACDEVANAGARI
;
496 case kCFStringEncodingMacGurmukhi
:
497 enc
= wxFONTENCODING_MACGURMUKHI
;
499 case kCFStringEncodingMacGujarati
:
500 enc
= wxFONTENCODING_MACGUJARATI
;
502 case kCFStringEncodingMacOriya
:
503 enc
=wxFONTENCODING_MACORIYA
;
505 case kCFStringEncodingMacBengali
:
506 enc
=wxFONTENCODING_MACBENGALI
;
508 case kCFStringEncodingMacTamil
:
509 enc
= wxFONTENCODING_MACTAMIL
;
511 case kCFStringEncodingMacTelugu
:
512 enc
= wxFONTENCODING_MACTELUGU
;
514 case kCFStringEncodingMacKannada
:
515 enc
= wxFONTENCODING_MACKANNADA
;
517 case kCFStringEncodingMacMalayalam
:
518 enc
= wxFONTENCODING_MACMALAJALAM
;
520 case kCFStringEncodingMacSinhalese
:
521 enc
= wxFONTENCODING_MACSINHALESE
;
523 case kCFStringEncodingMacBurmese
:
524 enc
= wxFONTENCODING_MACBURMESE
;
526 case kCFStringEncodingMacKhmer
:
527 enc
= wxFONTENCODING_MACKHMER
;
529 case kCFStringEncodingMacThai
:
530 enc
= wxFONTENCODING_MACTHAI
;
532 case kCFStringEncodingMacLaotian
:
533 enc
= wxFONTENCODING_MACLAOTIAN
;
535 case kCFStringEncodingMacGeorgian
:
536 enc
= wxFONTENCODING_MACGEORGIAN
;
538 case kCFStringEncodingMacArmenian
:
539 enc
= wxFONTENCODING_MACARMENIAN
;
541 case kCFStringEncodingMacChineseSimp
:
542 enc
= wxFONTENCODING_MACCHINESESIMP
;
544 case kCFStringEncodingMacTibetan
:
545 enc
= wxFONTENCODING_MACTIBETAN
;
547 case kCFStringEncodingMacMongolian
:
548 enc
= wxFONTENCODING_MACMONGOLIAN
;
550 case kCFStringEncodingMacEthiopic
:
551 enc
= wxFONTENCODING_MACETHIOPIC
;
553 case kCFStringEncodingMacCentralEurRoman
:
554 enc
= wxFONTENCODING_MACCENTRALEUR
;
556 case kCFStringEncodingMacVietnamese
:
557 enc
= wxFONTENCODING_MACVIATNAMESE
;
559 case kCFStringEncodingMacExtArabic
:
560 enc
= wxFONTENCODING_MACARABICEXT
;
562 case kCFStringEncodingMacSymbol
:
563 enc
= wxFONTENCODING_MACSYMBOL
;
565 case kCFStringEncodingMacDingbats
:
566 enc
= wxFONTENCODING_MACDINGBATS
;
568 case kCFStringEncodingMacTurkish
:
569 enc
= wxFONTENCODING_MACTURKISH
;
571 case kCFStringEncodingMacCroatian
:
572 enc
= wxFONTENCODING_MACCROATIAN
;
574 case kCFStringEncodingMacIcelandic
:
575 enc
= wxFONTENCODING_MACICELANDIC
;
577 case kCFStringEncodingMacRomanian
:
578 enc
= wxFONTENCODING_MACROMANIAN
;
580 case kCFStringEncodingMacCeltic
:
581 enc
= wxFONTENCODING_MACCELTIC
;
583 case kCFStringEncodingMacGaelic
:
584 enc
= wxFONTENCODING_MACGAELIC
;
586 case 41 /* kTextEncodingMacKeyboardGlyphs */ :
587 enc
= wxFONTENCODING_MACKEYBOARD
;
598 // converts this string into a core foundation string with optional pc 2 mac encoding
600 wxCFStringRef::wxCFStringRef( const wxString
&st
, wxFontEncoding
WXUNUSED_IN_UNICODE(encoding
) )
604 reset( wxCFRetain( CFSTR("") ) );
609 wxMacConvertNewlines13To10( &str
) ;
611 #if SIZEOF_WCHAR_T == 2
612 reset( CFStringCreateWithCharacters( kCFAllocatorDefault
,
613 (UniChar
*)str
.wc_str() , str
.Len() ) );
615 wxMBConvUTF16 converter
;
616 size_t unicharbytes
= converter
.FromWChar( NULL
, 0 , str
.wc_str() , str
.Length() ) ;
617 wxASSERT( unicharbytes
!= wxCONV_FAILED
);
618 if ( unicharbytes
== wxCONV_FAILED
)
620 // create an empty string
621 reset( wxCFRetain( CFSTR("") ) );
625 // unicharbytes: number of bytes needed for UTF-16 encoded string (without terminating null)
626 // unichars: number of UTF-16 characters (without terminating null)
627 size_t unichars
= unicharbytes
/ sizeof(UniChar
) ;
628 UniChar
*unibuf
= new UniChar
[ unichars
] ;
629 converter
.FromWChar( (char*)unibuf
, unicharbytes
, str
.wc_str() , str
.Length() ) ;
630 reset( CFStringCreateWithCharacters( kCFAllocatorDefault
, unibuf
, unichars
) ) ;
634 #else // not wxUSE_UNICODE
635 reset( CFStringCreateWithCString( kCFAllocatorSystemDefault
, str
.c_str() ,
636 wxMacGetSystemEncFromFontEnc( encoding
) ) );
641 wxString
wxCFStringRef::AsString(wxFontEncoding
WXUNUSED_IN_UNICODE(encoding
))
644 return wxEmptyString
;
646 Size cflen
= CFStringGetLength( get() ) ;
651 #if SIZEOF_WCHAR_T == 2
652 buf
= new wxChar
[ cflen
+ 1 ] ;
653 CFStringGetCharacters( get() , CFRangeMake( 0 , cflen
) , (UniChar
*) buf
) ;
656 UniChar
* unibuf
= new UniChar
[ cflen
+ 1 ] ;
657 CFStringGetCharacters( get() , CFRangeMake( 0 , cflen
) , (UniChar
*) unibuf
) ;
659 wxMBConvUTF16 converter
;
660 noChars
= converter
.MB2WC( NULL
, (const char*)unibuf
, 0 ) ;
661 wxASSERT_MSG( noChars
!= wxCONV_FAILED
, _T("Unable to count the number of characters in this string!") );
662 buf
= new wxChar
[ noChars
+ 1 ] ;
663 noChars
= converter
.MB2WC( buf
, (const char*)unibuf
, noChars
+ 1 ) ;
664 wxASSERT_MSG( noChars
!= wxCONV_FAILED
, _T("Conversion of string failed!") );
669 CFStringGetBytes( get() , CFRangeMake(0, cflen
) , wxMacGetSystemEncFromFontEnc( encoding
) ,
670 '?' , false , NULL
, 0 , &cStrLen
) ;
671 buf
= new wxChar
[ cStrLen
+ 1 ] ;
672 CFStringGetBytes( get() , CFRangeMake(0, cflen
) , wxMacGetSystemEncFromFontEnc( encoding
) ,
673 '?' , false , (unsigned char*) buf
, cStrLen
, &cStrLen
) ;
678 wxString
result(buf
) ;
680 wxMacConvertNewlines10To13( &result
);
685 // wxMacUniCharBuffer
688 wxMacUniCharBuffer::wxMacUniCharBuffer( const wxString
&str
)
690 m_chars
= str
.length() ;
693 #if SIZEOF_WCHAR_T == 4
694 wxMBConvUTF16 converter
;
696 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
697 m_ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
698 converter
.WC2MB( (char*) m_ubuf
, str
.wc_str(), unicharlen
+ 2 ) ;
700 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
701 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
702 m_ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
703 converter
.WC2MB( (char*) m_ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
705 m_chars
= unicharlen
/ 2 ;
706 #else // SIZEOF_WCHAR_T is then 2
708 m_ubuf
= malloc( m_chars
* 2 + 2 ) ;
709 memcpy( m_ubuf
, (UniChar
*) str
.wc_str() , m_chars
* 2 + 2 ) ;
711 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
712 m_chars
= wxWcslen( wchar
.data() ) ;
713 m_ubuf
= malloc( m_chars
* 2 + 2 ) ;
714 memcpy( m_ubuf
, (UniChar
*) wchar
.data() , m_chars
* 2 + 2 ) ;
719 wxMacUniCharBuffer::~wxMacUniCharBuffer()
724 UniCharPtr
wxMacUniCharBuffer::GetBuffer()
729 UniCharCount
wxMacUniCharBuffer::GetChars()