本文整理匯總了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);
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
示例8: CFStringGetMaximumSizeOfFileSystemRepresentation
CFIndex
CFStringGetMaximumSizeOfFileSystemRepresentation (CFStringRef string)
{
CFIndex length = CFStringGetLength (string);
return
CFStringGetMaximumSizeForEncoding (length, CFStringGetSystemEncoding ());
}
示例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);
}
示例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;
}
示例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
}
示例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;
}
}
示例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);
}
示例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
}
示例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);
}