当前位置: 首页>>代码示例>>C++>>正文


C++ CFStringGetSystemEncoding函数代码示例

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


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

示例1: AppearanceAlert

void AppearanceAlert (AlertType type, int stringID1, int stringID2)
{
	OSStatus		err;
	DialogRef		dialog;
	DialogItemIndex	outItemHit;
	CFStringRef		key1, key2, mes1, mes2;
	char			label1[32], label2[32];

	sprintf(label1, "AlertMes_%02d", stringID1);
	sprintf(label2, "AlertMes_%02d", stringID2);

	key1 = CFStringCreateWithCString(kCFAllocatorDefault, label1, CFStringGetSystemEncoding());
	key2 = CFStringCreateWithCString(kCFAllocatorDefault, label2, CFStringGetSystemEncoding());

	if (key1) mes1 = CFCopyLocalizedString(key1, "mes1");	else mes1 = NULL;
	if (key2) mes2 = CFCopyLocalizedString(key2, "mes2");	else mes2 = NULL;

	PlayAlertSound();

	err = CreateStandardAlert(type, mes1, mes2, NULL, &dialog);
	err = RunStandardAlert(dialog, NULL, &outItemHit);

	if (key1) CFRelease(key1);
	if (key2) CFRelease(key2);
	if (mes1) CFRelease(mes1);
	if (mes2) CFRelease(mes2);
}
开发者ID:OV2,项目名称:snes9x-libsnes,代码行数:27,代码来源:mac-dialog.cpp

示例2: GetStrPreference

void GetStrPreference (const char *name, char *out, const char *defaut, const int bufferSize)
{
    if ((out==NULL) || (name==NULL)) return;

    if (defaut != NULL)
    {
        strncpy(out,defaut,bufferSize-1);
        out[bufferSize-1]=0;
    }
    else out[0]=0;

    CFStringRef nom = CFStringCreateWithCString (NULL,name,CFStringGetSystemEncoding());

    if (nom != NULL)
    {
        CFStringRef value = (CFStringRef)CFPreferencesCopyAppValue(nom,kCFPreferencesCurrentApplication);

        if (value != NULL)
        {
            if (CFGetTypeID(value) == CFStringGetTypeID ())
            {
                if ((!CFStringGetCString (value, out, bufferSize, CFStringGetSystemEncoding())) && (defaut != NULL))
                    strcpy(out,defaut);
            }
            CFRelease(value);
        }
        CFRelease(nom);
    }
}
开发者ID:gp2xdev,项目名称:gp2x-flobopuyo,代码行数:29,代码来源:preferences.c

示例3: genUsb

QueryData genUsb() {
  QueryData results;

    CFMutableDictionaryRef matchingDict;
    io_iterator_t iter;
    kern_return_t kr;
    io_service_t device;
    char vendor[256];
    char product[256];

    matchingDict = IOServiceMatching(kIOUSBDeviceClassName);
    if (matchingDict == NULL)
    { return results; }

    kr = IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDict, &iter);
    if (kr != KERN_SUCCESS)
    {  return results; }

    while ((device = IOIteratorNext(iter)))
    {
        Row r

        //Get the vendor of the device;
        CFMutableDictionaryRef vendor_dict = NULL;
        IORegistryEntryCreateCFProperties(device, &vendor_dict, kCFAllocatorDefault, kNilOptions);
        CFTypeRef vendor_obj = CFDictionaryGetValue(vendor_dict, CFSTR("USB Vendor Name"));
        if(vendor_obj) {
           CFStringRef cf_vendor  =  CFStringCreateCopy(kCFAllocatorDefault, (CFStringRef)vendor_obj);
           CFStringGetCString(cf_vendor, vendor, 256, CFStringGetSystemEncoding());
           r["manufacturer"] = vendor;
        }

        //Get the product name of the device
        CFMutableDictionaryRef product_dict = NULL;
        IORegistryEntryCreateCFProperties(device, &product_dict, kCFAllocatorDefault, kNilOptions);
        CFTypeRef product_obj = CFDictionaryGetValue(product_dict, CFSTR("USB Product Name"));
        if(product_obj) {
           CFStringRef cf_product  =  CFStringCreateCopy(kCFAllocatorDefault, (CFStringRef)product_obj);
           CFStringGetCString(cf_product, product, 256, CFStringGetSystemEncoding());
           r["product"] = product;
        }

         //Lets make sure we don't have an empty product & manufacturer
        if(r["product"] != "" || r["manufacturer"] != "") {
          results.push_back(r);
        }

        IOObjectRelease(device);
    }

  IOObjectRelease(iter);
  return results;
}
开发者ID:UmiDevSec,项目名称:osquery,代码行数:53,代码来源:usb.cpp

示例4: SetStrPreference

void SetStrPreference (const char *name, const char *value)
{
    CFStringRef nom = CFStringCreateWithCString (NULL,name,CFStringGetSystemEncoding());
    if (nom != NULL)
    {
        CFStringRef val = CFStringCreateWithCString (NULL,value,CFStringGetSystemEncoding());
        if (val != NULL)
        {
            CFPreferencesSetAppValue (nom,val,kCFPreferencesCurrentApplication);
            (void)CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
            CFRelease(val);
        }
        CFRelease(nom);
    }
}
开发者ID:gp2xdev,项目名称:gp2x-flobopuyo,代码行数:15,代码来源:preferences.c

示例5: printCFString

static void printCFString(CFStringRef string)
{
    CFIndex	len;
    char *	buffer;

    len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(string),
	    CFStringGetSystemEncoding()) + sizeof('\0');
    buffer = malloc(len);
    if (buffer && CFStringGetCString(string, buffer, len,
                                  CFStringGetSystemEncoding()) )
	printf(buffer);

    if (buffer)
	free(buffer);
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:15,代码来源:iodisplayregistry.c

示例6: CFStringGetSystemEncoding

/* lifted from portmidi */
static char *get_ep_name(MIDIEndpointRef ep)
{
	MIDIEntityRef entity;
	MIDIDeviceRef device;
	CFStringRef endpointName = NULL, deviceName = NULL, fullName = NULL;
	CFStringEncoding defaultEncoding;
	char* newName;

	/* get the default string encoding */
	defaultEncoding = CFStringGetSystemEncoding();

	/* get the entity and device info */
	MIDIEndpointGetEntity(ep, &entity);
	MIDIEntityGetDevice(entity, &device);

	/* create the nicely formated name */
	MIDIObjectGetStringProperty(ep, kMIDIPropertyName, &endpointName);
	MIDIObjectGetStringProperty(device, kMIDIPropertyName, &deviceName);
	if (deviceName != NULL) {
		fullName = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@: %@"),
						deviceName, endpointName);
	} else {
		fullName = endpointName;
	}

	/* copy the string into our buffer */
	newName = (char*)mem_alloc(CFStringGetLength(fullName) + 1);
	CFStringGetCString(fullName, newName, CFStringGetLength(fullName) + 1,
			defaultEncoding);

	/* clean up */
	if (fullName && !deviceName) CFRelease(fullName);

	return newName;
}
开发者ID:asbjornu,项目名称:schismtracker,代码行数:36,代码来源:midi-macosx.c

示例7: main

int
main(void)
{
    kern_return_t          kr;
    io_iterator_t          io_hw_sensors;
    io_service_t           io_hw_sensor;
    CFMutableDictionaryRef sensor_properties;
    CFStringEncoding       systemEncoding = CFStringGetSystemEncoding();
   
    kr = IOServiceGetMatchingServices(kIOMasterPortDefault,
             IOServiceNameMatching("IOHWSensor"), &io_hw_sensors);
   
    while ((io_hw_sensor = IOIteratorNext(io_hw_sensors))) {
        kr = IORegistryEntryCreateCFProperties(io_hw_sensor, &sensor_properties,
                 kCFAllocatorDefault, kNilOptions);
        if (kr == KERN_SUCCESS)
            printTemperatureSensor(sensor_properties, systemEncoding);
   
        CFRelease(sensor_properties);
        IOObjectRelease(io_hw_sensor);
    }
   
    IOObjectRelease(io_hw_sensors);
   
    exit(kr);
}
开发者ID:Leask,项目名称:Mac-OS-X-Internals,代码行数:26,代码来源:lstemperature.c

示例8: CFStringGetMaximumSizeOfFileSystemRepresentation

CFIndex
CFStringGetMaximumSizeOfFileSystemRepresentation (CFStringRef string)
{
  CFIndex length = CFStringGetLength (string);
  return
    CFStringGetMaximumSizeForEncoding (length, CFStringGetSystemEncoding ());
}
开发者ID:1053948334,项目名称:myos.frameworks,代码行数:7,代码来源:CFStringEncoding.c

示例9: bluetoothDiscoverySDPCompleteCallback

void bluetoothDiscoverySDPCompleteCallback(void *userRefCon, IOBluetoothDeviceRef foundDevRef, IOReturn status)
{
	ConnectivityBluetooth *conn = (ConnectivityBluetooth *) userRefCon;
	IOBluetoothSDPUUIDRef uuid;
	unsigned char uuid_bytes[] = HAGGLE_BLUETOOTH_SDP_UUID;
	
	uuid = IOBluetoothSDPUUIDCreateWithBytes(uuid_bytes, sizeof(uuid_bytes));

	if (uuid == NULL) {
		CM_DBG("Failed to create UUID (%ld)\n", sizeof(uuid_bytes));
	}
	
	CFStringRef nameRef = IOBluetoothDeviceGetName(foundDevRef);

	const char *name = nameRef ? CFStringGetCStringPtr(nameRef, CFStringGetSystemEncoding()) : "PeerBluetoothInterface";
	//IOBluetoothObjectRetain(foundDevRef);
	//memcpy(macaddr, btAddr, BT_ALEN);
	
	const BluetoothDeviceAddress *btAddr = IOBluetoothDeviceGetAddress(foundDevRef);
	BluetoothAddress addr((unsigned char *)btAddr);
	
	BluetoothInterface iface((unsigned char *)btAddr, name, &addr, IFFLAG_UP);
	
	if (IOBluetoothDeviceGetServiceRecordForUUID(foundDevRef, uuid) != NULL) {
		CM_DBG("%s: Found Haggle device %s\n", conn->getName(), addr.getStr());
		
		conn->report_interface(&iface, conn->rootInterface, new ConnectivityInterfacePolicyTTL(2));
	} else {
		CM_DBG("%s: Found non-Haggle device [%s]\n", conn->getName(), addr.getStr());
	}

	IOBluetoothDeviceCloseConnection(foundDevRef);
	IOBluetoothObjectRelease(foundDevRef);
	IOBluetoothObjectRelease(uuid);
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:35,代码来源:ConnectivityBluetoothMacOSX.cpp

示例10: ios_open_from_bundle

static FILE* ios_open_from_bundle(const char path[], const char* perm) {
    // Get a reference to the main bundle
    CFBundleRef mainBundle = CFBundleGetMainBundle();

    // Get a reference to the file's URL
    CFStringRef pathRef = CFStringCreateWithCString(NULL, path, kCFStringEncodingUTF8);
    CFURLRef imageURL = CFBundleCopyResourceURL(mainBundle, pathRef, NULL, NULL);
    CFRelease(pathRef);
    if (!imageURL) {
        return nullptr;
    }

    // Convert the URL reference into a string reference
    CFStringRef imagePath = CFURLCopyFileSystemPath(imageURL, kCFURLPOSIXPathStyle);
    CFRelease(imageURL);

    // Get the system encoding method
    CFStringEncoding encodingMethod = CFStringGetSystemEncoding();

    // Convert the string reference into a C string
    const char *finalPath = CFStringGetCStringPtr(imagePath, encodingMethod);
    FILE* fileHandle = fopen(finalPath, perm);
    CFRelease(imagePath);
    return fileHandle;
}
开发者ID:alphan102,项目名称:gecko-dev,代码行数:25,代码来源:SkOSFile_stdio.cpp

示例11: qt_mac_to_pascal_string

void qt_mac_to_pascal_string(const QString &s, Str255 str, TextEncoding encoding, int len)
{
    if(len == -1)
        len = s.length();
#if 0
    UnicodeMapping mapping;
    mapping.unicodeEncoding = CreateTextEncoding(kTextEncodingUnicodeDefault,
                                                 kTextEncodingDefaultVariant,
                                                 kUnicode16BitFormat);
    mapping.otherEncoding = (encoding ? encoding : );
    mapping.mappingVersion = kUnicodeUseLatestMapping;

    UnicodeToTextInfo info;
    OSStatus err = CreateUnicodeToTextInfo(&mapping, &info);
    if(err != noErr) {
        qDebug("Qt: internal: Unable to create pascal string '%s'::%d [%ld]",
               s.left(len).latin1(), (int)encoding, err);
        return;
    }
    const int unilen = len * 2;
    const UniChar *unibuf = (UniChar *)s.unicode();
    ConvertFromUnicodeToPString(info, unilen, unibuf, str);
    DisposeUnicodeToTextInfo(&info);
#else
    Q_UNUSED(encoding);
    CFStringGetPascalString(QCFString(s), str, 256, CFStringGetSystemEncoding());
#endif
}
开发者ID:maxxant,项目名称:qt,代码行数:28,代码来源:qcore_mac.cpp

示例12: main

int main (int argc, const char * argv[]) {
    
	if (argv[1] != NULL)
	{
		CFDataRef data;
		CFStringRef searchterm = CFStringCreateWithCString(NULL, argv[1],
														   kCFStringEncodingMacRoman);
		CFRange searchRange = CFRangeMake(0, CFStringGetLength(searchterm));
		CFStringRef dictResult = DCSCopyTextDefinition(NULL, searchterm, searchRange);
		CFRelease(searchterm);

		if (dictResult != NULL) {
			data = CFStringCreateExternalRepresentation(NULL, dictResult, CFStringGetSystemEncoding(), '?');
			CFRelease(dictResult);

		}
		if (data != NULL) {
			printf ("%.*s\n\n", (int)CFDataGetLength(data), CFDataGetBytePtr(data));
			CFRelease(data);
		}
		else {
			printf("Could not find word in Dictionary.app.\n");
		}

		return 0;
	}
	else {
		printf("Usage: dictlookup \"word\"\n");
		return 1;
	}

}
开发者ID:davidhaselb,项目名称:dictlookup,代码行数:32,代码来源:main.c

示例13: listClients

static void listClients()
{
    IOHIDEventSystemClientRef eventSystem = IOHIDEventSystemClientCreateWithType(kCFAllocatorDefault, kIOHIDEventSystemClientTypeAdmin, NULL);
    CFIndex     types;
    
    require(eventSystem, exit);
    
    for ( types=kIOHIDEventSystemClientTypeAdmin; types<=kIOHIDEventSystemClientTypeRateControlled; types++ ) {
        CFArrayRef  clients = _IOHIDEventSystemClientCopyClientDescriptions(eventSystem, (IOHIDEventSystemClientType)types);
        CFIndex     index;
        
        if ( !clients )
            continue;
        
        for ( index=0; index<CFArrayGetCount(clients); index++ ) {
            CFStringRef clientDebugDesc = (CFStringRef)CFArrayGetValueAtIndex(clients, index);
            printf("%s\n", CFStringGetCStringPtr(clientDebugDesc, CFStringGetSystemEncoding()));
        }
        
        CFRelease(clients);
    }
    
exit:
    if (eventSystem)
        CFRelease(eventSystem);
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:26,代码来源:IOHIDEventSystemMonitor.c

示例14: strdup

char *Bgethomedir(void)
{
#ifdef _WIN32
	TCHAR appdata[MAX_PATH];

	if (SUCCEEDED(SHGetSpecialFolderPathA(NULL, appdata, CSIDL_APPDATA, FALSE)))
		return strdup(appdata);
	return NULL;
#elif defined __APPLE__
	FSRef ref;
	CFStringRef str;
	CFURLRef base;
	char *s;

	if (FSFindFolder(kUserDomain, kVolumeRootFolderType, kDontCreateFolder, &ref) < 0) return NULL;
	base = CFURLCreateFromFSRef(NULL, &ref);
	if (!base) return NULL;
	str = CFURLCopyFileSystemPath(base, kCFURLPOSIXPathStyle);
	CFRelease(base);
	if (!str) return NULL;
	s = (char*)CFStringGetCStringPtr(str,CFStringGetSystemEncoding());
	if (s) s = strdup(s);
	CFRelease(str);
	return s;
#else
	char *e = getenv("HOME");
	if (!e) return NULL;
	return strdup(e);
#endif
}
开发者ID:Plagman,项目名称:jfbuild,代码行数:30,代码来源:compat.c

示例15: DeinitMultiCart

void DeinitMultiCart (void)
{
	CFStringRef	keyRef;
	char		key[32];

	for (int i = 0; i < 2; i++)
	{
		sprintf(key, "MultiCartPath_%02d", i);
		keyRef = CFStringCreateWithCString(kCFAllocatorDefault, key, CFStringGetSystemEncoding());
		if (keyRef)
		{
			if (multiCartPath[i])
			{
				CFPreferencesSetAppValue(keyRef, multiCartPath[i], kCFPreferencesCurrentApplication);
				CFRelease(multiCartPath[i]);
			}
			else
				CFPreferencesSetAppValue(keyRef, NULL, kCFPreferencesCurrentApplication);

			CFRelease(keyRef);
		}
	}

	CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
}
开发者ID:7sevenx7,项目名称:snes9x,代码行数:25,代码来源:mac-multicart.cpp


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