您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CFStringGetCharacters函数代码示例

51自学网 2021-06-01 19:59:20
  C++
这篇教程C++ CFStringGetCharacters函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中CFStringGetCharacters函数的典型用法代码示例。如果您正苦于以下问题:C++ CFStringGetCharacters函数的具体用法?C++ CFStringGetCharacters怎么用?C++ CFStringGetCharacters使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了CFStringGetCharacters函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: CFStringCompareWithOptionsAndLocale

CFComparisonResultCFStringCompareWithOptionsAndLocale (CFStringRef str1,  CFStringRef str2, CFRange rangeToCompare,  CFStringCompareFlags compareOptions, CFLocaleRef locale){  CFComparisonResult ret;  UniChar *string1;  UniChar *string2;  CFIndex length1;  CFIndex length2;  CFAllocatorRef alloc;  UCollator *ucol;    alloc = CFAllocatorGetDefault ();    length1 = rangeToCompare.length;  string1 = CFAllocatorAllocate (alloc, (length1) * sizeof(UniChar), 0);  CFStringGetCharacters (str1, rangeToCompare, string1);    length2 = CFStringGetLength (str2);  string2 = CFAllocatorAllocate (alloc, (length2) * sizeof(UniChar), 0);  CFStringGetCharacters (str2, CFRangeMake(0, length2), string2);    ucol = CFStringICUCollatorOpen (compareOptions, locale);  ret = ucol_strcoll (ucol, string2, length2, string1, length1);  CFStringICUCollatorClose (ucol);    CFAllocatorDeallocate (alloc, string1);  CFAllocatorDeallocate (alloc, string2);  return ret;}
开发者ID:erichocean,项目名称:myos.android.frameworks,代码行数:31,


示例2: CFLocaleCreateComponentsFromLocaleIdentifier

CF_PRIVATE UCalendar *__CFCalendarCreateUCalendar(CFStringRef calendarID, CFStringRef localeID, CFTimeZoneRef tz) {    if (calendarID) {	CFDictionaryRef components = CFLocaleCreateComponentsFromLocaleIdentifier(kCFAllocatorSystemDefault, localeID);	CFMutableDictionaryRef mcomponents = CFDictionaryCreateMutableCopy(kCFAllocatorSystemDefault, 0, components);	CFDictionarySetValue(mcomponents, kCFLocaleCalendarIdentifier, calendarID);	localeID = CFLocaleCreateLocaleIdentifierFromComponents(kCFAllocatorSystemDefault, mcomponents);	CFRelease(mcomponents);	CFRelease(components);    }    char buffer[BUFFER_SIZE];    const char *cstr = CFStringGetCStringPtr(localeID, kCFStringEncodingASCII);    if (NULL == cstr) {	if (CFStringGetCString(localeID, buffer, BUFFER_SIZE, kCFStringEncodingASCII)) cstr = buffer;    }    if (NULL == cstr) {	if (calendarID) CFRelease(localeID);	return NULL;    }        UChar ubuffer[BUFFER_SIZE];    CFStringRef tznam = CFTimeZoneGetName(tz);    CFIndex cnt = CFStringGetLength(tznam);    if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;    CFStringGetCharacters(tznam, CFRangeMake(0, cnt), (UniChar *)ubuffer);    UErrorCode status = U_ZERO_ERROR;    UCalendar *cal = ucal_open(ubuffer, cnt, cstr, UCAL_DEFAULT, &status);    if (calendarID) CFRelease(localeID);    return cal;}
开发者ID:0oneo,项目名称:CF-855.11,代码行数:31,


示例3: debugstr_cf

/************************************************************************** *              debugstr_cf */const char* debugstr_cf(CFTypeRef t){    CFStringRef s;    const char* ret;    if (!t) return "(null)";    if (CFGetTypeID(t) == CFStringGetTypeID())        s = t;    else        s = CFCopyDescription(t);    ret = CFStringGetCStringPtr(s, kCFStringEncodingUTF8);    if (ret) ret = debugstr_a(ret);    if (!ret)    {        const UniChar* u = CFStringGetCharactersPtr(s);        if (u)            ret = debugstr_wn((const WCHAR*)u, CFStringGetLength(s));    }    if (!ret)    {        UniChar buf[200];        int len = min(CFStringGetLength(s), sizeof(buf)/sizeof(buf[0]));        CFStringGetCharacters(s, CFRangeMake(0, len), buf);        ret = debugstr_wn(buf, len);    }    if (s != t) CFRelease(s);    return ret;}
开发者ID:karolherbst,项目名称:wine,代码行数:32,


示例4: getJString

static jstring getJString(JNIEnv *env, CFStringRef cs) {    if (cs == NULL) return NULL;    CFRange range = CFRangeMake(0, CFStringGetLength(cs));    UniChar *chars = alloca(range.length);    CFStringGetCharacters(cs, range, chars);    return (*env)->NewString(env, (jchar *) chars, (jsize) range.length);}
开发者ID:fciubotaru,项目名称:z-pec,代码行数:7,


示例5: MultiByteToWideChar

void ARRAY_TEXT::convertFromUTF8(const CUTF8String* fromString, CUTF16String* toString)	{#ifdef _WIN32	int len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)fromString->c_str(), fromString->length(), NULL, 0);		if(len){		std::vector<uint8_t> buf((len + 1) * sizeof(PA_Unichar));		if(MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)fromString->c_str(), fromString->length(), (LPWSTR)&buf[0], len)){			*toString = CUTF16String((const PA_Unichar *)&buf[0]);		}    }else{			*toString = CUTF16String((const PA_Unichar *)L"");	}           #else           CFStringRef str = CFStringCreateWithBytes(kCFAllocatorDefault, fromString->c_str(), fromString->length(), kCFStringEncodingUTF8, true);           if(str){               int len = CFStringGetLength(str)+1;               std::vector<uint8_t> buf(len * sizeof(PA_Unichar));               CFStringGetCharacters(str, CFRangeMake(0, len), (UniChar *)&buf[0]);               *toString = CUTF16String((const PA_Unichar *)&buf[0]);               CFRelease(str);           }#endif	}
开发者ID:jpupier,项目名称:4d-plugin-oauth,代码行数:25,


示例6: callback

static void callback(        ConstFSEventStreamRef streamRef,        void *clientCallBackInfo,        size_t numEvents,        void *eventPathsVoid,        const FSEventStreamEventFlags eventFlags[],        const FSEventStreamEventId eventIds[]){    qDebug() << "FolderWatcherPrivate::callback by OS X";    QStringList paths;    CFArrayRef eventPaths = (CFArrayRef)eventPathsVoid;    for (int i = 0; i < numEvents; ++i) {        CFStringRef path = reinterpret_cast<CFStringRef>(CFArrayGetValueAtIndex(eventPaths, i));        QString qstring;        CFIndex pathLength = CFStringGetLength(path);        qstring.resize(pathLength);        CFStringGetCharacters(path, CFRangeMake(0, pathLength), reinterpret_cast<UniChar *>(qstring.data()));        paths.append(qstring);    }    reinterpret_cast<FolderWatcherPrivate*>(clientCallBackInfo)->doNotifyParent(paths);}
开发者ID:24killen,项目名称:client,代码行数:25,


示例7: FindSNESFolder

static OSStatus FindSNESFolder (FSRef *folderRef, char *folderPath, const char *folderName){	OSStatus	err;	CFURLRef	burl, purl;	CFStringRef	fstr;	FSRef		pref;	UniChar		buffer[PATH_MAX + 1];	Boolean		r;	fstr = CFStringCreateWithCString(kCFAllocatorDefault, folderName, CFStringGetSystemEncoding());	CFStringGetCharacters(fstr, CFRangeMake(0, CFStringGetLength(fstr)), buffer);	burl = CFBundleCopyBundleURL(CFBundleGetMainBundle());	purl = CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorDefault, burl);	r    = CFURLGetFSRef(purl, &pref);	err = FSMakeFSRefUnicode(&pref, CFStringGetLength(fstr), buffer, kTextEncodingUnicodeDefault, folderRef);	if (err == dirNFErr || err == fnfErr)	{		err = FSCreateDirectoryUnicode(&pref, CFStringGetLength(fstr), buffer, kFSCatInfoNone, NULL, folderRef, NULL, NULL);		if (err == noErr)			AddFolderIcon(folderRef, folderName);	}	if (err == noErr)		err = FSRefMakePath(folderRef, (unsigned char *) folderPath, PATH_MAX);	CFRelease(purl);	CFRelease(burl);	CFRelease(fstr);	return (err);}
开发者ID:7sevenx7,项目名称:snes9x,代码行数:33,


示例8: createJavaString

jstring createJavaString(JNIEnv *env, CFStringRef stringRef){    CFIndex length = CFStringGetLength(stringRef);    UniChar buffer[length];    CFStringGetCharacters(stringRef, CFRangeMake(0, length), buffer);    return (*env)->NewString(env, (jchar *)buffer, length);}
开发者ID:whatever4711,项目名称:jfx-media-android,代码行数:7,


示例9: GetEncTable

static const wxUint16* GetEncTable(wxFontEncoding enc){#ifdef __WXMAC__    if( enc >= wxFONTENCODING_MACMIN && enc <= wxFONTENCODING_MACMAX )    {        int i = enc-wxFONTENCODING_MACMIN ;        if ( gMacEncodingsInited[i] == false )        {            // create            CFStringEncoding cfencoding = wxMacGetSystemEncFromFontEnc( enc ) ;            if( !CFStringIsEncodingAvailable( cfencoding ) )                return NULL;            memset( gMacEncodings[i] , 0 , 128 * 2 );            char s[2] = { 0 , 0 };            CFRange firstchar = CFRangeMake( 0, 1 );            for( unsigned char c = 255 ; c >= 128 ; --c )            {                s[0] = c ;                wxCFStringRef cfref( CFStringCreateWithCStringNoCopy( NULL, s, cfencoding , kCFAllocatorNull ) );                CFStringGetCharacters( cfref, firstchar, (UniChar*)  &gMacEncodings[i][c-128] );            }            gMacEncodingsInited[i]=true;        }        return gMacEncodings[i] ;    }#endif    for (int i = 0; encodings_list[i].table != NULL; i++)    {        if (encodings_list[i].encoding == enc)            return encodings_list[i].table;    }    return NULL;}
开发者ID:BloodRedd,项目名称:gamekit,代码行数:35,


示例10: __CFLocaleICUCurrencyName

static bool __CFLocaleICUCurrencyName(const char *locale, const char *value, UCurrNameStyle style, CFStringRef *out) {    size_t valLen = strlen(value);    if (valLen != 3) // not a valid ISO code        return false;    UChar curr[4];    UBool isChoice = FALSE;    int32_t size = 0;    UErrorCode icuStatus = U_ZERO_ERROR;    u_charsToUChars(value, curr, (int32_t)valLen);    curr[valLen] = '/0';    const UChar *name;    name = ucurr_getName(curr, locale, style, &isChoice, &size, &icuStatus);    if (U_FAILURE(icuStatus) || icuStatus == U_USING_DEFAULT_WARNING)        return false;    UChar result[kMaxICUNameSize];    if (isChoice)    {        UChar pattern[kMaxICUNameSize];        CFStringRef patternRef = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("{0,choice,%S}"), name);        CFIndex pattlen = CFStringGetLength(patternRef);        CFStringGetCharacters(patternRef, CFRangeMake(0, pattlen), (UniChar *)pattern);        CFRelease(patternRef);        pattern[pattlen] = '/0';        // null terminate the pattern        // Format the message assuming a large amount of the currency        size = u_formatMessage("en_US", pattern, pattlen, result, kMaxICUNameSize, &icuStatus, 10.0);        if (U_FAILURE(icuStatus))            return false;        name = result;            }    *out = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, (UniChar *)name, size);    return (*out != NULL);}
开发者ID:AbhinavBansal,项目名称:opencflite,代码行数:33,


示例11: GetVisualName

//-------------------------------------------------------------------------------------------------//	GetVisualName//-------------------------------------------------------------------------------------------------//void GetVisualName( ITUniStr255 name ){	CFIndex length = CFStringGetLength( kTVisualPluginName );    	name[0] = (UniChar)length;	CFStringGetCharacters( kTVisualPluginName, CFRangeMake( 0, length ), &name[1] );}
开发者ID:Erkan-Yilmaz,项目名称:lastfm-desktop,代码行数:11,


示例12: UpdateATSUIStuffString

// Sets up the text based on the specified CFString//void UpdateATSUIStuffString(CFStringRef string){    free(gText);    gLength = CFStringGetLength(string);    gText = (UniChar *)malloc(gLength * sizeof(UniChar));    CFStringGetCharacters(string, CFRangeMake(0, gLength), gText);}
开发者ID:arnelh,项目名称:Examples,代码行数:9,


示例13: assertEqualsAsCharactersPtr

static void assertEqualsAsCharactersPtr(JSValueRef value, const char* expectedValue){    JSStringRef valueAsString = JSValueToStringCopy(context, value, NULL);    size_t jsLength = JSStringGetLength(valueAsString);    const JSChar* jsBuffer = JSStringGetCharactersPtr(valueAsString);    CFStringRef expectedValueAsCFString = CFStringCreateWithCString(kCFAllocatorDefault,                                                                     expectedValue,                                                                    kCFStringEncodingUTF8);        CFIndex cfLength = CFStringGetLength(expectedValueAsCFString);    UniChar* cfBuffer = (UniChar*)malloc(cfLength * sizeof(UniChar));    CFStringGetCharacters(expectedValueAsCFString, CFRangeMake(0, cfLength), cfBuffer);    CFRelease(expectedValueAsCFString);    if (memcmp(jsBuffer, cfBuffer, cfLength * sizeof(UniChar)) != 0) {        fprintf(stderr, "assertEqualsAsCharactersPtr failed: jsBuffer != cfBuffer/n");        failed = 1;    }        if (jsLength != (size_t)cfLength) {        fprintf(stderr, "assertEqualsAsCharactersPtr failed: jsLength(%ld) != cfLength(%ld)/n", jsLength, cfLength);        failed = 1;    }    free(cfBuffer);    JSStringRelease(valueAsString);}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:28,


示例14: MoveFile

/*********************************************************************	 MoveFile*		 lpFromFileName: old file path*		 lpToFileName: new file path********************************************************************/BOOL MoveFile(const char * lpFromFileName, const char * lpToFileName){	OSErr theErr;	FSRef fromFileRef;	FSRef toFileRef;	FSRef parentFolderRef;		// Get the path to the old file	theErr = FSPathMakeRef((const UInt8 *)lpFromFileName, &fromFileRef, NULL);	if (theErr != noErr)	{		SetLastError(theErr);		return false;	}		// Get the path to the new folder for the file	char folderName[strlen(lpToFileName)];	CFStringRef folderPathCFString = CFStringCreateWithCString(NULL, lpToFileName, kCFStringEncodingUTF8);	CFURLRef fileURL = CFURLCreateWithFileSystemPath(NULL, folderPathCFString, kCFURLPOSIXPathStyle, FALSE);	CFURLRef folderURL = CFURLCreateCopyDeletingLastPathComponent(NULL, fileURL);	CFURLGetFileSystemRepresentation(folderURL, TRUE, (UInt8 *)folderName, strlen(lpToFileName));	theErr = FSPathMakeRef((UInt8 *)folderName, &parentFolderRef, NULL);	CFRelease(fileURL);	CFRelease(folderURL);	CFRelease(folderPathCFString);		// Move the old file	theErr = FSMoveObject(&fromFileRef, &parentFolderRef, &toFileRef);	if (theErr != noErr)	{		SetLastError(theErr);		return false;	}		// Get a CFString for the new file name	CFStringRef newFileNameCFString = CFStringCreateWithCString(NULL, lpToFileName, kCFStringEncodingUTF8);	fileURL = CFURLCreateWithFileSystemPath(NULL, newFileNameCFString, kCFURLPOSIXPathStyle, FALSE);	CFRelease(newFileNameCFString);	newFileNameCFString = CFURLCopyLastPathComponent(fileURL);	CFRelease(fileURL);		// Convert CFString to Unicode and rename the file	UniChar unicodeFileName[256];	CFStringGetCharacters(newFileNameCFString, CFRangeMake(0, CFStringGetLength(newFileNameCFString)), 						  unicodeFileName);	theErr = FSRenameUnicode(&toFileRef, CFStringGetLength(newFileNameCFString), unicodeFileName, 							 kTextEncodingUnknown, NULL);	if (theErr != noErr)	{		SetLastError(theErr);		CFRelease(newFileNameCFString);		return false;	}		CFRelease(newFileNameCFString);		SetLastError(theErr);	return true;}
开发者ID:luqasn,项目名称:ghost4mac,代码行数:64,


示例15: q_toString

static QString q_toString(const CFStringRef &str){    CFIndex length = CFStringGetLength(str);    QVarLengthArray<UniChar> buffer(length);    CFRange range = { 0, length };    CFStringGetCharacters(str, range, buffer.data());    return QString(reinterpret_cast<const QChar *>(buffer.data()), length);}
开发者ID:gustavosbarreto,项目名称:libqsolid,代码行数:9,


示例16: convert_CFString_to_QString

QString convert_CFString_to_QString(CFStringRef str) {	CFIndex length = CFStringGetLength(str);	const UniChar *chars = CFStringGetCharactersPtr(str);	if (chars)		return QString(reinterpret_cast<const QChar *>(chars), length);	QVarLengthArray<UniChar> buffer(length);	CFStringGetCharacters(str, CFRangeMake(0, length), buffer.data());	return QString(reinterpret_cast<const QChar *>(buffer.constData()), length);}
开发者ID:vasi,项目名称:kdelibs,代码行数:10,


示例17: GetPathForIconFile

// Given an application bundle reference and the name of an icon file// which is a resource in that bundle, look up the full (posix style)// path to that icon. Returns the path, or an empty wxString on failurewxString GetPathForIconFile( CFBundleRef bundle, CFStringRef iconFile ){    // If either parameter is NULL there is no hope of success    if( !bundle || !iconFile )        return wxEmptyString;    // Create a range object representing the whole string    CFRange wholeString;    wholeString.location = 0;    wholeString.length = CFStringGetLength( iconFile );    // Index of the period in the file name for iconFile    UniCharCount periodIndex;    // In order to locate the period delimiting the extension,    // iconFile must be represented as UniChar[]    {        // Allocate a buffer and copy in the iconFile string        UniChar* buffer = new UniChar[ wholeString.length ];        CFStringGetCharacters( iconFile, wholeString, buffer );        // Locate the period character        OSStatus status = LSGetExtensionInfo( wholeString.length, buffer, &periodIndex );        // Deallocate the buffer        delete [] buffer;        // If the period could not be located it will not be possible to get the URL        if( status != noErr || periodIndex == kLSInvalidExtensionIndex )            return wxEmptyString;    }    // Range representing the name part of iconFile    CFRange iconNameRange;    iconNameRange.location = 0;    iconNameRange.length = periodIndex - 1;    // Range representing the extension part of iconFile    CFRange iconExtRange;    iconExtRange.location = periodIndex;    iconExtRange.length = wholeString.length - periodIndex;    // Get the name and extension strings    wxCFStringRef iconName = CFStringCreateWithSubstring( kCFAllocatorDefault, iconFile, iconNameRange );    wxCFStringRef iconExt = CFStringCreateWithSubstring( kCFAllocatorDefault, iconFile, iconExtRange );    // Now it is possible to query the URL for the icon as a resource    wxCFRef< CFURLRef > iconUrl = wxCFRef< CFURLRef >( CFBundleCopyResourceURL( bundle, iconName, iconExt, NULL ) );    if( !iconUrl.get() )        return wxEmptyString;    // All being well, return the icon path    return wxCFStringRef( CFURLCopyFileSystemPath( iconUrl, kCFURLPOSIXPathStyle ) ).AsString();}
开发者ID:chromylei,项目名称:third_party,代码行数:58,


示例18: CFStringGetLength

wxString wxMacCFStringHolder::AsString(wxFontEncoding encoding){    if ( m_cfs == NULL )        return wxEmptyString ;    Size cflen = CFStringGetLength( m_cfs )  ;    size_t noChars ;    wxChar* buf = NULL ;#if wxUSE_UNICODE#if SIZEOF_WCHAR_T == 2    buf = new wxChar[ cflen + 1 ] ;    CFStringGetCharacters( m_cfs , CFRangeMake( 0 , cflen ) , (UniChar*) buf ) ;    noChars = cflen ;#else    UniChar* unibuf = new UniChar[ cflen + 1 ] ;    CFStringGetCharacters( m_cfs , CFRangeMake( 0 , cflen ) , (UniChar*) unibuf ) ;    unibuf[cflen] = 0 ;    wxMBConvUTF16 converter ;    noChars = converter.MB2WC( NULL , (const char*)unibuf , 0 ) ;    wxASSERT_MSG( noChars != wxCONV_FAILED, _T("Unable to count the number of characters in this string!") );    buf = new wxChar[ noChars + 1 ] ;    noChars = converter.MB2WC( buf , (const char*)unibuf , noChars + 1 ) ;    wxASSERT_MSG( noChars != wxCONV_FAILED, _T("Conversion of string failed!") );    delete[] unibuf ;#endif#else    CFIndex cStrLen ;    CFStringGetBytes( m_cfs , CFRangeMake(0, cflen) , wxMacGetSystemEncFromFontEnc( encoding ) ,        '?' , false , NULL , 0 , &cStrLen ) ;    buf = new wxChar[ cStrLen + 1 ] ;    CFStringGetBytes( m_cfs , CFRangeMake(0, cflen) , wxMacGetSystemEncFromFontEnc( encoding ) ,        '?' , false , (unsigned char*) buf , cStrLen , &cStrLen) ;    noChars = cStrLen ;#endif    buf[noChars] = 0 ;    wxMacConvertNewlines10To13( buf ) ;    wxString result(buf) ;    delete[] buf ;    return result ;}
开发者ID:EdgarTx,项目名称:wx,代码行数:42,


示例19: SetUpATSUIStuff

// Creates the ATSUI data//void SetUpATSUIStuff(void){        CFStringRef	string = CFSTR("Hello World!");    verify_noerr( ATSUCreateStyle(&gStyle) );    UpdateATSUIStyle();        gLength = CFStringGetLength(string);    gText = (UniChar *)malloc(gLength * sizeof(UniChar));    CFStringGetCharacters(string, CFRangeMake(0, gLength), gText);}
开发者ID:arnelh,项目名称:Examples,代码行数:13,


示例20: MyValidationProc

/******************************************************* MyValidationProc(theControl)** Purpose:  called when a key filter can't be: after cut, paste, etc** Inputs:   theControl          - the control to validate** Returns:  none*/static pascal void MyValidationProc(ControlRef theControl)	{	OSStatus status;	CFStringRef theCFString = NULL;	UniChar *buffer = NULL;	// Getting the text content of the control	status = GetControlData(theControl, kControlEntireControl, kControlEditTextCFStringTag, sizeof(theCFString), &theCFString, NULL);	require_noerr(status, ExitValidation);	require(theCFString != NULL, ExitValidation);		CFIndex i, j, len = CFStringGetLength(theCFString);	if (len == 0) goto ExitValidation; // there's nothing to validate		// Grabbing the characters as Unicode chars	buffer = (UniChar *)malloc(len * sizeof(UniChar));	require(buffer != NULL, ExitValidation);		// Checking to see if we have only digits	CFStringGetCharacters(theCFString, CFRangeMake(0, len), buffer);	Boolean ok = true;	for (i = 0; (i < len) && ok; i++)		ok = (buffer[i] >= '0') && (buffer[i] <= '9');		if (!ok)		{		// if not, we remove the offending characters		// we also make sure that we restore the insertion point to the correct location.		ControlEditTextSelectionRec textSelection;		status = GetControlData(theControl, kControlEntireControl, kControlEditTextSelectionTag, sizeof(textSelection), &textSelection, NULL);		require_noerr(status, ExitValidation);		for (i = 0, j = 0; i < len; i++)			if ((buffer[i] >= '0') && (buffer[i] <= '9')) buffer[j++] = buffer[i];		CFRelease(theCFString);		theCFString = CFStringCreateWithCharacters(NULL, buffer, j);		require(theCFString != NULL, ExitValidation);				status = SetControlData(theControl, kControlEntireControl, kControlEditTextCFStringTag, sizeof(theCFString), &theCFString);		require_noerr(status, ExitValidation);				textSelection.selEnd -= (len - j); textSelection.selStart = textSelection.selEnd;		status = SetControlData(theControl, kControlEntireControl, kControlEditTextSelectionTag, sizeof(textSelection), &textSelection);		require_noerr(status, ExitValidation);		}ExitValidation:	if (buffer != NULL) free(buffer);	if (theCFString != NULL) CFRelease(theCFString);		return;	}   // MyValidationProc
开发者ID:fruitsamples,项目名称:Custom_HIView_Tutorial,代码行数:64,


示例21: CFStringGetCharacters

void ConsoleMessage::execute(){    if (theSession) {        jsize len = ::CFStringGetLength(mMessage);        jchar* buffer = new jchar[len];        CFRange range = { 0, len };        CFStringGetCharacters(mMessage, range, buffer);        System_out_print(theSession->getCurrentEnv(), buffer, len);        delete[] buffer;    }}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:11,


示例22: CopyUTF8toUTF16NFC

static void CopyUTF8toUTF16NFC(const nsACString& aSrc, nsAString& aResult){    static PRBool sChecked = PR_FALSE;    static UnicodeNormalizer sUnicodeNormalizer = NULL;    // CFStringNormalize was not introduced until Mac OS 10.2    if (!sChecked) {        CFBundleRef carbonBundle =            CFBundleGetBundleWithIdentifier(CFSTR("com.apple.Carbon"));        if (carbonBundle)            sUnicodeNormalizer = (UnicodeNormalizer)                ::CFBundleGetFunctionPointerForName(carbonBundle,                                                    CFSTR("CFStringNormalize"));        sChecked = PR_TRUE;    }    if (!sUnicodeNormalizer) {  // OS X 10.1 or earlier        CopyUTF8toUTF16(aSrc, aResult);        return;      }    const nsAFlatCString &inFlatSrc = PromiseFlatCString(aSrc);    // The number of 16bit code units in a UTF-16 string will never be    // larger than the number of bytes in the corresponding UTF-8 string.    CFMutableStringRef inStr =        ::CFStringCreateMutable(NULL, inFlatSrc.Length());    if (!inStr) {        CopyUTF8toUTF16(aSrc, aResult);        return;      }         ::CFStringAppendCString(inStr, inFlatSrc.get(), kCFStringEncodingUTF8);     sUnicodeNormalizer(inStr, kCFStringNormalizationFormC);    CFIndex length = CFStringGetLength(inStr);    const UniChar* chars = CFStringGetCharactersPtr(inStr);    if (chars)         aResult.Assign(chars, length);    else {        nsAutoTArray<UniChar, 512> buffer;        if (buffer.SetLength(length)) {            CFStringGetCharacters(inStr, CFRangeMake(0, length), buffer.Elements());            aResult.Assign(buffer.Elements(), length);        }        else             CopyUTF8toUTF16(aSrc, aResult);    }    CFRelease(inStr);}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:53,


示例23: dir_Create

int dir_Create(char *pathString, int pathStringLength) {	/* Create a new directory with the given path. By default, this	   directory is created in the current directory. Use	   a full path name such as "MyDisk:Working:New Folder" to	   create folders elsewhere. */    char cFileName[1001];    if (pathStringLength >= 1000) {        return false;    }    /* copy the file name into a null-terminated C string */    sqFilenameFromString((char *) cFileName, (int) pathString, pathStringLength);    #if defined(__MWERKS__)	{        CFStringRef 	filePath,lastFilePath;        CFURLRef 	    sillyThing,sillyThing2;        FSRef	        parentFSRef;        UniChar         buffer[1024];        long            tokenLength;		int err;                filePath   = CFStringCreateWithBytes(kCFAllocatorDefault,(UInt8 *)cFileName,strlen(cFileName),gCurrentVMEncoding,false);        if (filePath == nil)             return false;        sillyThing = CFURLCreateWithFileSystemPath (kCFAllocatorDefault,filePath,kCFURLHFSPathStyle,true);        CFRelease(filePath);        lastFilePath = CFURLCopyLastPathComponent(sillyThing);        tokenLength = CFStringGetLength(lastFilePath);        if (tokenLength > 1024)            return false;        CFStringGetCharacters(lastFilePath,CFRangeMake(0,tokenLength),buffer);        CFRelease(lastFilePath);        sillyThing2 = CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorDefault,sillyThing);        err = CFURLGetFSRef(sillyThing2,&parentFSRef);        CFRelease(sillyThing);        CFRelease(sillyThing2);        if (err == 0) {            return false;          }		err = FSCreateDirectoryUnicode(&parentFSRef,tokenLength,buffer,kFSCatInfoNone,NULL,NULL,NULL,NULL);		    	return (err == noErr ? 1 : 0);    }#else    return mkdir(cFileName, 0777) == 0;#endif}
开发者ID:JeanBaptisteArnaud,项目名称:RaspLocalDebug,代码行数:53,


示例24: CFStringCreateWithBytes

rktio_char16_t *rktio_recase_utf16(rktio_t *rktio, rktio_bool_t to_up, rktio_char16_t *s1, intptr_t l1, intptr_t *olen){#ifdef MACOS_UNICODE_SUPPORT  CFMutableStringRef mstr;  CFStringRef str;  CFRange rng;  rktio_char16_t *result;  intptr_t len;  str = CFStringCreateWithBytes(NULL, (unsigned char *)s1, (l1 * sizeof(rktio_char16_t)), kCFStringEncodingUnicode, FALSE);  mstr = CFStringCreateMutableCopy(NULL, 0, str);  CFRelease(str);  if (to_up)    CFStringUppercase(mstr, NULL);  else    CFStringLowercase(mstr, NULL);  len = CFStringGetLength(mstr);  result = malloc((len + 1) * sizeof(rktio_char16_t));  rng = CFRangeMake(0, len);  CFStringGetCharacters(mstr, rng, (UniChar *)result);  CFRelease(mstr);  result[len] = 0;  if (olen)    *olen = len;  return result;#elif defined(RKTIO_SYSTEM_WINDOWS)  rktio_char16_t *result;    result = malloc((l1 + 1) * sizeof(rktio_char16_t));  memcpy(result, s1, l1 * sizeof(rktio_char16_t));  result[l1] = 0;    if (to_up)    CharUpperBuffW((wchar_t *)result, l1);  else    CharLowerBuffW((wchar_t *)result, l1);  if (olen)    *olen = l1;  return result;#else  return NULL;#endif}
开发者ID:AlexKnauth,项目名称:racket,代码行数:52,


示例25: utf8_decodestr

extern int utf8_decodestr(const u_int8_t * utf8p, size_t utf8len, u_int16_t *ucsp, size_t *ucslen,        size_t buflen, u_int16_t altslash, int flags){    int         err;    CFStringRef str;    CFIndex     utf16Count;        assert(utf8p != NULL);    assert(ucsp != NULL);    assert(ucslen != NULL);    assert(altslash == 0);    assert(flags == UTF_PRECOMPOSED);    err = 0;    str = CFStringCreateWithBytes(NULL, utf8p, utf8len, kCFStringEncodingUTF8, false);    if (str == NULL) {        err = EINVAL;    }        if (err == 0) {        CFMutableStringRef  tmpStr;                tmpStr = CFStringCreateMutableCopy(NULL, 0, str);        if (tmpStr != NULL) {            CFStringNormalize(tmpStr, kCFStringNormalizationFormC);                        // Swap tmpStr into str.                        CFRelease(str);            str = tmpStr;        }    }        if (err == 0) {        utf16Count = CFStringGetLength(str);                if (utf16Count > (buflen / 2)) {            utf16Count = (buflen / 2);            err = ENAMETOOLONG;        }                CFStringGetCharacters(str, CFRangeMake(0, utf16Count), ucsp);                *ucslen = utf16Count * sizeof(uint16_t);    }        if (str != NULL) {        CFRelease(str);    }    return err;}
开发者ID:fruitsamples,项目名称:MFSLives,代码行数:52,


示例26: CFStringToQString

QString CFStringToQString(CFStringRef str) {    if (!str)        return QString();    CFIndex length = CFStringGetLength(str);    if (length == 0)        return QString();    QString string(length, Qt::Uninitialized);    CFStringGetCharacters(str, CFRangeMake(0, length), reinterpret_cast<UniChar *>        (const_cast<QChar *>(string.unicode())));    return string;}
开发者ID:Adna1206,项目名称:mixxx,代码行数:13,


示例27: QCFStringToQString

QString QCFStringToQString(CFStringRef str){    if(!str)        return QString();    CFIndex length = CFStringGetLength(str);    const UniChar *chars = CFStringGetCharactersPtr(str);    if (chars)        return QString(reinterpret_cast<const QChar *>(chars), length);    QVector<UniChar> buffer(length);    CFStringGetCharacters(str, CFRangeMake(0, length), buffer.data());    return QString(reinterpret_cast<const QChar *>(buffer.constData()), length);}
开发者ID:CowPanda,项目名称:TeamTalk5,代码行数:13,


示例28: cfstring2qstring

// this is a Qt implementation I foundQString cfstring2qstring(CFStringRef str){    if(!str)        return QString();        CFIndex length = CFStringGetLength(str);    if(const UniChar *chars = CFStringGetCharactersPtr(str))        return QString((QChar *)chars, length);    UniChar *buffer = (UniChar*)malloc(length * sizeof(UniChar));    CFStringGetCharacters(str, CFRangeMake(0, length), buffer);    QString ret((QChar *)buffer, length);    free(buffer);    return ret;}
开发者ID:weiligang512,项目名称:apue-test,代码行数:15,


示例29: stringGettingAtCharactersExample

void stringGettingAtCharactersExample(void) {    CFStringRef str;    const UniChar *chars;    show(CFSTR("------------------Character Manipulations---------------"));    // Create some test CFString    str = CFStringCreateWithCString(NULL, "Hello World", kCFStringEncodingASCII);    show(CFSTR("Original String : %@"), str);    // The fastest way to get the contents; this might return NULL though    // depending on the system, the release, etc, so don't depend on it     // (unless you used CFStringCreateMutableWithExternalCharactersNoCopy())    chars = CFStringGetCharactersPtr(str);    // If that fails, you can try copying the UniChars out    // either into some stack buffer or some allocated piece of memory...    // Using the former is fine, but you need to know the size; the latter    // always works but requires allocating some memory; not too efficient.    if (chars == NULL) {        CFIndex length = CFStringGetLength(str);        UniChar *buffer = (UniChar*)malloc(length * sizeof(UniChar));        CFStringGetCharacters(str, CFRangeMake(0, length), buffer);        // Process the chars...        free(buffer);    }    else        show(CFSTR("Characters      : %@"), str);    // You can use CFStringGetCharacterAtIndex() to get at the characters one at a time,    // but doing a lot of characters this way might get slow...    // An option is to use "inline buffer" functionality which mixes the convenience of    // one-at-a-time char access with efficiency of bulk access    {        CFStringInlineBuffer inlineBuffer;        CFIndex length = CFStringGetLength(str);        CFIndex cnt;        CFStringInitInlineBuffer(str, &inlineBuffer, CFRangeMake(0, length));        for (cnt = 0; cnt < length; cnt++) {            UniChar ch = CFStringGetCharacterFromInlineBuffer(&inlineBuffer, cnt);            // Process character...	         (void)ch;   // Dummy processing to prevent compiler warning...        }    }    }
开发者ID:edconnor,项目名称:TestCairo,代码行数:50,



注:本文中的CFStringGetCharacters函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ CFStringGetLength函数代码示例
C++ CFStringGetCStringPtr函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。