这篇教程C++ CFStringGetBytes函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CFStringGetBytes函数的典型用法代码示例。如果您正苦于以下问题:C++ CFStringGetBytes函数的具体用法?C++ CFStringGetBytes怎么用?C++ CFStringGetBytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CFStringGetBytes函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ConvertStringToEncodingchar* ConvertStringToEncoding(CFStringRef string, CFStringEncoding encoding, int identifier){ char* output = NULL; if (_pbxgdb_plugin_functions) { // we want to convert the whole string CFRange range; range.location = 0; range.length = CFStringGetLength(string); // find out how big our utf-8 buffer needs to be CFIndex length_needed; CFStringGetBytes(string, range, encoding, '?', false, NULL, 0, &length_needed); // make the output buffer // just in case the convert call fails completely, we zero terminate it output = (char*)(_pbxgdb_plugin_functions->allocate(identifier, length_needed + 1)); if (output) { output[0] = 0; // try to get the actual string - we terminate it for safety CFStringGetBytes(string, range, encoding, '?', false, (UInt8*) output, length_needed, &length_needed); output[length_needed] = 0; } } if (output) DEBUG_PRINT("converted: %s/n", output); return output ? output : kNullPluginError; }
开发者ID:samdeane,项目名称:xcode-unicode-formatter,代码行数:32,
示例2: _SC_cfstring_to_cstringchar *_SC_cfstring_to_cstring(CFStringRef cfstr, char *buf, CFIndex bufLen, CFStringEncoding encoding){ CFIndex converted; CFIndex last = 0; CFIndex len; if (cfstr == NULL) { cfstr = CFSTR(""); } len = CFStringGetLength(cfstr); /* how much buffer space will we really need? */ converted = CFStringGetBytes(cfstr, CFRangeMake(0, len), encoding, 0, FALSE, NULL, 0, &last); if (converted < len) { /* if full string could not be converted */ if (buf != NULL) { buf[0] = '/0'; } return NULL; } if (buf != NULL) { if (bufLen < (last + 1)) { /* if the size of the provided buffer is too small */ buf[0] = '/0'; return NULL; } } else { /* allocate a buffer */ bufLen = last + 1; buf = CFAllocatorAllocate(NULL, bufLen, 0); if (buf == NULL) { return NULL; } } (void)CFStringGetBytes(cfstr, CFRangeMake(0, len), encoding, 0, FALSE, (UInt8 *)buf, bufLen, &last); buf[last] = '/0'; return buf;}
开发者ID:010001111,项目名称:darling,代码行数:56,
示例3: CFStringCreateWithCharactersNoCopyconst char *Tcl_UniCharToUtfDString(Tcl_UniChar *characters, size_t length, Tcl_DString *ds){ CFStringRef str = CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault,characters, length, kCFAllocatorNull); CFRange range = {0,length}; // all the characters CFIndex bufLen = 0; CFStringGetBytes(str, range, kCFStringEncodingUTF8, true, false, NULL, 0, &bufLen); *ds = (malloc(bufLen)); CFStringGetBytes(str, range, kCFStringEncodingUTF8, true, false, *ds, bufLen, &bufLen); CFRelease(str); return (const char *)*ds;}
开发者ID:CodaFi,项目名称:IDEKit,代码行数:11,
示例4: CFQStringCopyCStringextern pascal OSStatus CFQStringCopyCString(CFStringRef str, CFStringEncoding encoding, char **cStrPtr) // See comment in header.{ OSStatus err; CFIndex cStrLen; CFRange range; assert( str != NULL); assert( cStrPtr != NULL); assert(*cStrPtr == NULL); err = noErr; range = CFRangeMake(0, CFStringGetLength(str)); (void) CFStringGetBytes(str, range, encoding, 0, false, NULL, 0, &cStrLen); // Can't convert to CFQAllocate because the caller is required // to free the string using "free", and there's no guarantee that // CFQAllocate and "free" are compatible (for example, if you're // compiling CFM and running on Mac OS X, "free" is from an MSL pool // while CFQAllocate allocates from System framework). // // Anyway, this isn't a problem because the size is always at // least one byte, so malloc won't misbehave. *cStrPtr = (char *) malloc( ((size_t) cStrLen) + 1); if (*cStrPtr == NULL) { err = memFullErr; } if (err == noErr) { #if MORE_DEBUG (*cStrPtr)[cStrLen] = ' C++ CFStringGetCString函数代码示例 C++ CFStringCreateWithFormat函数代码示例
|