1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/corefoundation/cfstring.cpp
3 // Purpose: wxCFStringHolder and other string functions
4 // Author: Stefan Csomor
6 // Created: 2004-10-29 (from code in src/mac/carbon/utils.cpp)
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
15 #include "wx/string.h"
22 #include "wx/mac/corefoundation/cfstring.h"
25 #include <CoreServices/CoreServices.h>
27 #include <TextCommon.h>
30 void wxMacConvertNewlines13To10( char * data
)
33 while( (buf
=strchr(buf
,0x0d)) != NULL
)
40 void wxMacConvertNewlines10To13( char * data
)
43 while( (buf
=strchr(buf
,0x0a)) != NULL
)
50 void wxMacConvertNewlines13To10( wxString
* data
)
52 size_t len
= data
->Length() ;
54 if ( len
== 0 || wxStrchr(data
->c_str(),0x0d)==NULL
)
57 wxString
temp(*data
) ;
58 wxStringBuffer
buf(*data
,len
) ;
59 memcpy( buf
, temp
.c_str() , (len
+1)*sizeof(wxChar
) ) ;
61 wxMacConvertNewlines13To10( buf
) ;
64 void wxMacConvertNewlines10To13( wxString
* data
)
66 size_t len
= data
->Length() ;
68 if ( data
->Length() == 0 || wxStrchr(data
->c_str(),0x0a)==NULL
)
71 wxString
temp(*data
) ;
72 wxStringBuffer
buf(*data
,len
) ;
73 memcpy( buf
, temp
.c_str() , (len
+1)*sizeof(wxChar
) ) ;
74 wxMacConvertNewlines10To13( buf
) ;
79 void wxMacConvertNewlines13To10( wxChar
* data
)
82 while( (buf
=wxStrchr(buf
,0x0d)) != NULL
)
89 void wxMacConvertNewlines10To13( wxChar
* data
)
92 while( (buf
=wxStrchr(buf
,0x0a)) != NULL
)
100 wxUint32
wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding
)
102 TextEncodingBase enc
= 0 ;
103 if ( encoding
== wxFONTENCODING_DEFAULT
)
106 encoding
= wxFont::GetDefaultEncoding() ;
108 encoding
= wxFONTENCODING_SYSTEM
; // to be set below
112 if ( encoding
== wxFONTENCODING_SYSTEM
)
114 enc
= CFStringGetSystemEncoding();
119 case wxFONTENCODING_ISO8859_1
:
120 enc
= kTextEncodingISOLatin1
;
122 case wxFONTENCODING_ISO8859_2
:
123 enc
= kTextEncodingISOLatin2
;
125 case wxFONTENCODING_ISO8859_3
:
126 enc
= kTextEncodingISOLatin3
;
128 case wxFONTENCODING_ISO8859_4
:
129 enc
= kTextEncodingISOLatin4
;
131 case wxFONTENCODING_ISO8859_5
:
132 enc
= kTextEncodingISOLatinCyrillic
;
134 case wxFONTENCODING_ISO8859_6
:
135 enc
= kTextEncodingISOLatinArabic
;
137 case wxFONTENCODING_ISO8859_7
:
138 enc
= kTextEncodingISOLatinGreek
;
140 case wxFONTENCODING_ISO8859_8
:
141 enc
= kTextEncodingISOLatinHebrew
;
143 case wxFONTENCODING_ISO8859_9
:
144 enc
= kTextEncodingISOLatin5
;
146 case wxFONTENCODING_ISO8859_10
:
147 enc
= kTextEncodingISOLatin6
;
149 case wxFONTENCODING_ISO8859_13
:
150 enc
= kTextEncodingISOLatin7
;
152 case wxFONTENCODING_ISO8859_14
:
153 enc
= kTextEncodingISOLatin8
;
155 case wxFONTENCODING_ISO8859_15
:
156 enc
= kTextEncodingISOLatin9
;
159 case wxFONTENCODING_KOI8
:
160 enc
= kTextEncodingKOI8_R
;
162 case wxFONTENCODING_ALTERNATIVE
: // MS-DOS CP866
163 enc
= kTextEncodingDOSRussian
;
166 case wxFONTENCODING_BULGARIAN :
170 case wxFONTENCODING_CP437
:
171 enc
=kTextEncodingDOSLatinUS
;
173 case wxFONTENCODING_CP850
:
174 enc
= kTextEncodingDOSLatin1
;
176 case wxFONTENCODING_CP852
:
177 enc
= kTextEncodingDOSLatin2
;
179 case wxFONTENCODING_CP855
:
180 enc
= kTextEncodingDOSCyrillic
;
182 case wxFONTENCODING_CP866
:
183 enc
=kTextEncodingDOSRussian
;
185 case wxFONTENCODING_CP874
:
186 enc
= kTextEncodingDOSThai
;
188 case wxFONTENCODING_CP932
:
189 enc
= kTextEncodingDOSJapanese
;
191 case wxFONTENCODING_CP936
:
192 enc
= kTextEncodingDOSChineseSimplif
;
194 case wxFONTENCODING_CP949
:
195 enc
= kTextEncodingDOSKorean
;
197 case wxFONTENCODING_CP950
:
198 enc
= kTextEncodingDOSChineseTrad
;
201 case wxFONTENCODING_CP1250
:
202 enc
= kTextEncodingWindowsLatin2
;
204 case wxFONTENCODING_CP1251
:
205 enc
=kTextEncodingWindowsCyrillic
;
207 case wxFONTENCODING_CP1252
:
208 enc
=kTextEncodingWindowsLatin1
;
210 case wxFONTENCODING_CP1253
:
211 enc
= kTextEncodingWindowsGreek
;
213 case wxFONTENCODING_CP1254
:
214 enc
= kTextEncodingWindowsLatin5
;
216 case wxFONTENCODING_CP1255
:
217 enc
=kTextEncodingWindowsHebrew
;
219 case wxFONTENCODING_CP1256
:
220 enc
=kTextEncodingWindowsArabic
;
222 case wxFONTENCODING_CP1257
:
223 enc
= kTextEncodingWindowsBalticRim
;
226 case wxFONTENCODING_UTF7
:
227 enc
= CreateTextEncoding(kTextEncodingUnicodeDefault
,0,kUnicodeUTF7Format
) ;
229 case wxFONTENCODING_UTF8
:
230 enc
= CreateTextEncoding(kTextEncodingUnicodeDefault
,0,kUnicodeUTF8Format
) ;
232 case wxFONTENCODING_EUC_JP
:
233 enc
= kTextEncodingEUC_JP
;
235 case wxFONTENCODING_UTF16BE
:
236 enc
= CreateTextEncoding(kTextEncodingUnicodeDefault
,0,kUnicode16BitFormat
) ;
238 case wxFONTENCODING_UTF16LE
:
239 enc
= CreateTextEncoding(kTextEncodingUnicodeDefault
,0,kUnicode16BitFormat
) ;
241 case wxFONTENCODING_UTF32BE
:
242 enc
= CreateTextEncoding(kTextEncodingUnicodeDefault
,0,kUnicode32BitFormat
) ;
244 case wxFONTENCODING_UTF32LE
:
245 enc
= CreateTextEncoding(kTextEncodingUnicodeDefault
,0,kUnicode32BitFormat
) ;
248 case wxFONTENCODING_MACROMAN
:
249 enc
= kTextEncodingMacRoman
;
251 case wxFONTENCODING_MACJAPANESE
:
252 enc
= kTextEncodingMacJapanese
;
254 case wxFONTENCODING_MACCHINESETRAD
:
255 enc
= kTextEncodingMacChineseTrad
;
257 case wxFONTENCODING_MACKOREAN
:
258 enc
= kTextEncodingMacKorean
;
260 case wxFONTENCODING_MACARABIC
:
261 enc
= kTextEncodingMacArabic
;
263 case wxFONTENCODING_MACHEBREW
:
264 enc
= kTextEncodingMacHebrew
;
266 case wxFONTENCODING_MACGREEK
:
267 enc
= kTextEncodingMacGreek
;
269 case wxFONTENCODING_MACCYRILLIC
:
270 enc
= kTextEncodingMacCyrillic
;
272 case wxFONTENCODING_MACDEVANAGARI
:
273 enc
= kTextEncodingMacDevanagari
;
275 case wxFONTENCODING_MACGURMUKHI
:
276 enc
= kTextEncodingMacGurmukhi
;
278 case wxFONTENCODING_MACGUJARATI
:
279 enc
= kTextEncodingMacGujarati
;
281 case wxFONTENCODING_MACORIYA
:
282 enc
= kTextEncodingMacOriya
;
284 case wxFONTENCODING_MACBENGALI
:
285 enc
= kTextEncodingMacBengali
;
287 case wxFONTENCODING_MACTAMIL
:
288 enc
= kTextEncodingMacTamil
;
290 case wxFONTENCODING_MACTELUGU
:
291 enc
= kTextEncodingMacTelugu
;
293 case wxFONTENCODING_MACKANNADA
:
294 enc
= kTextEncodingMacKannada
;
296 case wxFONTENCODING_MACMALAJALAM
:
297 enc
= kTextEncodingMacMalayalam
;
299 case wxFONTENCODING_MACSINHALESE
:
300 enc
= kTextEncodingMacSinhalese
;
302 case wxFONTENCODING_MACBURMESE
:
303 enc
= kTextEncodingMacBurmese
;
305 case wxFONTENCODING_MACKHMER
:
306 enc
= kTextEncodingMacKhmer
;
308 case wxFONTENCODING_MACTHAI
:
309 enc
= kTextEncodingMacThai
;
311 case wxFONTENCODING_MACLAOTIAN
:
312 enc
= kTextEncodingMacLaotian
;
314 case wxFONTENCODING_MACGEORGIAN
:
315 enc
= kTextEncodingMacGeorgian
;
317 case wxFONTENCODING_MACARMENIAN
:
318 enc
= kTextEncodingMacArmenian
;
320 case wxFONTENCODING_MACCHINESESIMP
:
321 enc
= kTextEncodingMacChineseSimp
;
323 case wxFONTENCODING_MACTIBETAN
:
324 enc
= kTextEncodingMacTibetan
;
326 case wxFONTENCODING_MACMONGOLIAN
:
327 enc
= kTextEncodingMacMongolian
;
329 case wxFONTENCODING_MACETHIOPIC
:
330 enc
= kTextEncodingMacEthiopic
;
332 case wxFONTENCODING_MACCENTRALEUR
:
333 enc
= kTextEncodingMacCentralEurRoman
;
335 case wxFONTENCODING_MACVIATNAMESE
:
336 enc
= kTextEncodingMacVietnamese
;
338 case wxFONTENCODING_MACARABICEXT
:
339 enc
= kTextEncodingMacExtArabic
;
341 case wxFONTENCODING_MACSYMBOL
:
342 enc
= kTextEncodingMacSymbol
;
344 case wxFONTENCODING_MACDINGBATS
:
345 enc
= kTextEncodingMacDingbats
;
347 case wxFONTENCODING_MACTURKISH
:
348 enc
= kTextEncodingMacTurkish
;
350 case wxFONTENCODING_MACCROATIAN
:
351 enc
= kTextEncodingMacCroatian
;
353 case wxFONTENCODING_MACICELANDIC
:
354 enc
= kTextEncodingMacIcelandic
;
356 case wxFONTENCODING_MACROMANIAN
:
357 enc
= kTextEncodingMacRomanian
;
359 case wxFONTENCODING_MACCELTIC
:
360 enc
= kTextEncodingMacCeltic
;
362 case wxFONTENCODING_MACGAELIC
:
363 enc
= kTextEncodingMacGaelic
;
365 case wxFONTENCODING_MACKEYBOARD
:
366 enc
= kTextEncodingMacKeyboardGlyphs
;
368 default : // to make gcc happy
374 wxFontEncoding
wxMacGetFontEncFromSystemEnc(wxUint32 encoding
)
376 wxFontEncoding enc
= wxFONTENCODING_DEFAULT
;
380 case kTextEncodingISOLatin1
:
381 enc
= wxFONTENCODING_ISO8859_1
;
383 case kTextEncodingISOLatin2
:
384 enc
= wxFONTENCODING_ISO8859_2
;
386 case kTextEncodingISOLatin3
:
387 enc
= wxFONTENCODING_ISO8859_3
;
389 case kTextEncodingISOLatin4
:
390 enc
= wxFONTENCODING_ISO8859_4
;
392 case kTextEncodingISOLatinCyrillic
:
393 enc
= wxFONTENCODING_ISO8859_5
;
395 case kTextEncodingISOLatinArabic
:
396 enc
= wxFONTENCODING_ISO8859_6
;
398 case kTextEncodingISOLatinGreek
:
399 enc
= wxFONTENCODING_ISO8859_7
;
401 case kTextEncodingISOLatinHebrew
:
402 enc
= wxFONTENCODING_ISO8859_8
;
404 case kTextEncodingISOLatin5
:
405 enc
= wxFONTENCODING_ISO8859_9
;
407 case kTextEncodingISOLatin6
:
408 enc
= wxFONTENCODING_ISO8859_10
;
410 case kTextEncodingISOLatin7
:
411 enc
= wxFONTENCODING_ISO8859_13
;
413 case kTextEncodingISOLatin8
:
414 enc
= wxFONTENCODING_ISO8859_14
;
416 case kTextEncodingISOLatin9
:
417 enc
=wxFONTENCODING_ISO8859_15
;
420 case kTextEncodingKOI8_R
:
421 enc
= wxFONTENCODING_KOI8
;
425 enc = wxFONTENCODING_BULGARIAN;
428 case kTextEncodingDOSLatinUS
:
429 enc
= wxFONTENCODING_CP437
;
431 case kTextEncodingDOSLatin1
:
432 enc
= wxFONTENCODING_CP850
;
434 case kTextEncodingDOSLatin2
:
435 enc
=wxFONTENCODING_CP852
;
437 case kTextEncodingDOSCyrillic
:
438 enc
= wxFONTENCODING_CP855
;
440 case kTextEncodingDOSRussian
:
441 enc
= wxFONTENCODING_CP866
;
443 case kTextEncodingDOSThai
:
444 enc
=wxFONTENCODING_CP874
;
446 case kTextEncodingDOSJapanese
:
447 enc
= wxFONTENCODING_CP932
;
449 case kTextEncodingDOSChineseSimplif
:
450 enc
= wxFONTENCODING_CP936
;
452 case kTextEncodingDOSKorean
:
453 enc
= wxFONTENCODING_CP949
;
455 case kTextEncodingDOSChineseTrad
:
456 enc
= wxFONTENCODING_CP950
;
459 case kTextEncodingWindowsLatin2
:
460 enc
= wxFONTENCODING_CP1250
;
462 case kTextEncodingWindowsCyrillic
:
463 enc
= wxFONTENCODING_CP1251
;
465 case kTextEncodingWindowsLatin1
:
466 enc
= wxFONTENCODING_CP1252
;
468 case kTextEncodingWindowsGreek
:
469 enc
= wxFONTENCODING_CP1253
;
471 case kTextEncodingWindowsLatin5
:
472 enc
= wxFONTENCODING_CP1254
;
474 case kTextEncodingWindowsHebrew
:
475 enc
= wxFONTENCODING_CP1255
;
477 case kTextEncodingWindowsArabic
:
478 enc
= wxFONTENCODING_CP1256
;
480 case kTextEncodingWindowsBalticRim
:
481 enc
=wxFONTENCODING_CP1257
;
483 case kTextEncodingEUC_JP
:
484 enc
= wxFONTENCODING_EUC_JP
;
487 case wxFONTENCODING_UTF7
:
488 enc
= CreateTextEncoding(kTextEncodingUnicodeDefault
,0,kUnicodeUTF7Format
) ;
490 case wxFONTENCODING_UTF8
:
491 enc
= CreateTextEncoding(kTextEncodingUnicodeDefault
,0,kUnicodeUTF8Format
) ;
493 case wxFONTENCODING_UTF16BE
:
494 enc
= CreateTextEncoding(kTextEncodingUnicodeDefault
,0,kUnicode16BitFormat
) ;
496 case wxFONTENCODING_UTF16LE
:
497 enc
= CreateTextEncoding(kTextEncodingUnicodeDefault
,0,kUnicode16BitFormat
) ;
499 case wxFONTENCODING_UTF32BE
:
500 enc
= CreateTextEncoding(kTextEncodingUnicodeDefault
,0,kUnicode32BitFormat
) ;
502 case wxFONTENCODING_UTF32LE
:
503 enc
= CreateTextEncoding(kTextEncodingUnicodeDefault
,0,kUnicode32BitFormat
) ;
506 case kTextEncodingMacRoman
:
507 enc
= wxFONTENCODING_MACROMAN
;
509 case kTextEncodingMacJapanese
:
510 enc
= wxFONTENCODING_MACJAPANESE
;
512 case kTextEncodingMacChineseTrad
:
513 enc
= wxFONTENCODING_MACCHINESETRAD
;
515 case kTextEncodingMacKorean
:
516 enc
= wxFONTENCODING_MACKOREAN
;
518 case kTextEncodingMacArabic
:
519 enc
=wxFONTENCODING_MACARABIC
;
521 case kTextEncodingMacHebrew
:
522 enc
= wxFONTENCODING_MACHEBREW
;
524 case kTextEncodingMacGreek
:
525 enc
= wxFONTENCODING_MACGREEK
;
527 case kTextEncodingMacCyrillic
:
528 enc
= wxFONTENCODING_MACCYRILLIC
;
530 case kTextEncodingMacDevanagari
:
531 enc
= wxFONTENCODING_MACDEVANAGARI
;
533 case kTextEncodingMacGurmukhi
:
534 enc
= wxFONTENCODING_MACGURMUKHI
;
536 case kTextEncodingMacGujarati
:
537 enc
= wxFONTENCODING_MACGUJARATI
;
539 case kTextEncodingMacOriya
:
540 enc
=wxFONTENCODING_MACORIYA
;
542 case kTextEncodingMacBengali
:
543 enc
=wxFONTENCODING_MACBENGALI
;
545 case kTextEncodingMacTamil
:
546 enc
= wxFONTENCODING_MACTAMIL
;
548 case kTextEncodingMacTelugu
:
549 enc
= wxFONTENCODING_MACTELUGU
;
551 case kTextEncodingMacKannada
:
552 enc
= wxFONTENCODING_MACKANNADA
;
554 case kTextEncodingMacMalayalam
:
555 enc
= wxFONTENCODING_MACMALAJALAM
;
557 case kTextEncodingMacSinhalese
:
558 enc
= wxFONTENCODING_MACSINHALESE
;
560 case kTextEncodingMacBurmese
:
561 enc
= wxFONTENCODING_MACBURMESE
;
563 case kTextEncodingMacKhmer
:
564 enc
= wxFONTENCODING_MACKHMER
;
566 case kTextEncodingMacThai
:
567 enc
= wxFONTENCODING_MACTHAI
;
569 case kTextEncodingMacLaotian
:
570 enc
= wxFONTENCODING_MACLAOTIAN
;
572 case kTextEncodingMacGeorgian
:
573 enc
= wxFONTENCODING_MACGEORGIAN
;
575 case kTextEncodingMacArmenian
:
576 enc
= wxFONTENCODING_MACARMENIAN
;
578 case kTextEncodingMacChineseSimp
:
579 enc
= wxFONTENCODING_MACCHINESESIMP
;
581 case kTextEncodingMacTibetan
:
582 enc
= wxFONTENCODING_MACTIBETAN
;
584 case kTextEncodingMacMongolian
:
585 enc
= wxFONTENCODING_MACMONGOLIAN
;
587 case kTextEncodingMacEthiopic
:
588 enc
= wxFONTENCODING_MACETHIOPIC
;
590 case kTextEncodingMacCentralEurRoman
:
591 enc
= wxFONTENCODING_MACCENTRALEUR
;
593 case kTextEncodingMacVietnamese
:
594 enc
= wxFONTENCODING_MACVIATNAMESE
;
596 case kTextEncodingMacExtArabic
:
597 enc
= wxFONTENCODING_MACARABICEXT
;
599 case kTextEncodingMacSymbol
:
600 enc
= wxFONTENCODING_MACSYMBOL
;
602 case kTextEncodingMacDingbats
:
603 enc
= wxFONTENCODING_MACDINGBATS
;
605 case kTextEncodingMacTurkish
:
606 enc
= wxFONTENCODING_MACTURKISH
;
608 case kTextEncodingMacCroatian
:
609 enc
= wxFONTENCODING_MACCROATIAN
;
611 case kTextEncodingMacIcelandic
:
612 enc
= wxFONTENCODING_MACICELANDIC
;
614 case kTextEncodingMacRomanian
:
615 enc
= wxFONTENCODING_MACROMANIAN
;
617 case kTextEncodingMacCeltic
:
618 enc
= wxFONTENCODING_MACCELTIC
;
620 case kTextEncodingMacGaelic
:
621 enc
= wxFONTENCODING_MACGAELIC
;
623 case kTextEncodingMacKeyboardGlyphs
:
624 enc
= wxFONTENCODING_MACKEYBOARD
;
632 // CFStringRefs (Carbon only)
635 // converts this string into a carbon foundation string with optional pc 2 mac encoding
636 void wxMacCFStringHolder::Assign( const wxString
&st
, wxFontEncoding encoding
)
647 wxMacConvertNewlines13To10( &str
) ;
649 #if SIZEOF_WCHAR_T == 2
650 m_cfs
= CFStringCreateWithCharacters( kCFAllocatorDefault
,
651 (UniChar
*)str
.wc_str() , str
.Len() );
653 wxMBConvUTF16 converter
;
654 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
655 UniChar
*unibuf
= new UniChar
[ unicharlen
/ sizeof(UniChar
) + 1 ] ;
656 converter
.WC2MB( (char*)unibuf
, str
.wc_str() , unicharlen
) ;
657 m_cfs
= CFStringCreateWithCharacters( kCFAllocatorDefault
,
658 unibuf
, unicharlen
/ sizeof(UniChar
) ) ;
661 #else // not wxUSE_UNICODE
662 m_cfs
= CFStringCreateWithCString( kCFAllocatorSystemDefault
, str
.c_str() ,
663 wxMacGetSystemEncFromFontEnc( encoding
) ) ;
669 wxString
wxMacCFStringHolder::AsString(wxFontEncoding encoding
)
672 return wxEmptyString
;
674 Size cflen
= CFStringGetLength( m_cfs
) ;
679 #if SIZEOF_WCHAR_T == 2
680 buf
= new wxChar
[ cflen
+ 1 ] ;
681 CFStringGetCharacters( m_cfs
, CFRangeMake( 0 , cflen
) , (UniChar
*) buf
) ;
684 UniChar
* unibuf
= new UniChar
[ cflen
+ 1 ] ;
685 CFStringGetCharacters( m_cfs
, CFRangeMake( 0 , cflen
) , (UniChar
*) unibuf
) ;
687 wxMBConvUTF16 converter
;
688 noChars
= converter
.MB2WC( NULL
, (const char*)unibuf
, 0 ) ;
689 wxASSERT_MSG( noChars
!= wxCONV_FAILED
, _T("Unable to count the number of characters in this string!") );
690 buf
= new wxChar
[ noChars
+ 1 ] ;
691 noChars
= converter
.MB2WC( buf
, (const char*)unibuf
, noChars
+ 1 ) ;
692 wxASSERT_MSG( noChars
!= wxCONV_FAILED
, _T("Conversion of string failed!") );
697 CFStringGetBytes( m_cfs
, CFRangeMake(0, cflen
) , wxMacGetSystemEncFromFontEnc( encoding
) ,
698 '?' , false , NULL
, 0 , &cStrLen
) ;
699 buf
= new wxChar
[ cStrLen
+ 1 ] ;
700 CFStringGetBytes( m_cfs
, CFRangeMake(0, cflen
) , wxMacGetSystemEncFromFontEnc( encoding
) ,
701 '?' , false , (unsigned char*) buf
, cStrLen
, &cStrLen
) ;
706 wxMacConvertNewlines10To13( buf
) ;
707 wxString
result(buf
) ;
713 wxMacUniCharBuffer::wxMacUniCharBuffer( const wxString
&str
)
715 m_chars
= str
.length() ;
718 #if SIZEOF_WCHAR_T == 4
719 wxMBConvUTF16 converter
;
721 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
722 m_ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
723 converter
.WC2MB( (char*) m_ubuf
, str
.wc_str(), unicharlen
+ 2 ) ;
725 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
726 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
727 m_ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
728 converter
.WC2MB( (char*) m_ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
730 m_chars
= unicharlen
/ 2 ;
731 #else // SIZEOF_WCHAR_T is then 2
733 m_ubuf
= malloc( m_chars
* 2 + 2 ) ;
734 memcpy( m_ubuf
, (UniChar
*) str
.wc_str() , m_chars
* 2 + 2 ) ;
736 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
737 m_chars
= wxWcslen( wchar
.data() ) ;
738 m_ubuf
= malloc( m_chars
* 2 + 2 ) ;
739 memcpy( m_ubuf
, (UniChar
*) wchar
.data() , m_chars
* 2 + 2 ) ;
744 wxMacUniCharBuffer::~wxMacUniCharBuffer()
749 UniCharArrayPtr
wxMacUniCharBuffer::GetBuffer()
754 UniCharCount
wxMacUniCharBuffer::GetChars()