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


C++ ConvertFromUnicode函数代码示例

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


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

示例1: cliprdr_server_receive_temporary_directory

/**
 * Function description
 *
 * @return 0 on success, otherwise a Win32 error code
 */
static UINT cliprdr_server_receive_temporary_directory(CliprdrServerContext* context, wStream* s, CLIPRDR_HEADER* header)
{
	int length;
	WCHAR* wszTempDir;
	CLIPRDR_TEMP_DIRECTORY tempDirectory;
	CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
	size_t slength;
	UINT error = CHANNEL_RC_OK;

	if ((slength = Stream_GetRemainingLength(s)) < 520)
	{
		WLog_ERR(TAG, "Stream_GetRemainingLength returned %d but should at least be 520", slength);
		return CHANNEL_RC_NO_MEMORY;
	}

	wszTempDir = (WCHAR*) Stream_Pointer(s);

	if (wszTempDir[260] != 0)
	{
		WLog_ERR(TAG, "wszTempDir[260] was not 0");
		return ERROR_INVALID_DATA;
	}

	free(cliprdr->temporaryDirectory);
	cliprdr->temporaryDirectory = NULL;

	ConvertFromUnicode(CP_UTF8, 0, wszTempDir, -1,
			&(cliprdr->temporaryDirectory), 0, NULL, NULL);

	length = strlen(cliprdr->temporaryDirectory);

	if (length > 519)
		length = 519;

	CopyMemory(tempDirectory.szTempDir, cliprdr->temporaryDirectory, length);
	tempDirectory.szTempDir[length] = '\0';

	WLog_DBG(TAG, "CliprdrTemporaryDirectory: %s", cliprdr->temporaryDirectory);

	IFCALLRET(context->TempDirectory, error, context, &tempDirectory);
	if (error)
		WLog_ERR(TAG, "TempDirectory failed with error %lu!", error);

	return error;
}
开发者ID:BUGgs,项目名称:FreeRDP,代码行数:50,代码来源:cliprdr_main.c

示例2: remdesk_recv_ctl_remote_control_desktop_pdu

static int remdesk_recv_ctl_remote_control_desktop_pdu(RemdeskServerContext* context, wStream* s, REMDESK_CHANNEL_HEADER* header)
{
	int status;
	int cchStringW;
	WCHAR* pStringW;
	UINT32 msgLength;
	int cbRaConnectionStringW = 0;
	WCHAR* raConnectionStringW = NULL;
	REMDESK_CTL_REMOTE_CONTROL_DESKTOP_PDU pdu;

	msgLength = header->DataLength - 4;

	pStringW = (WCHAR*) Stream_Pointer(s);
	raConnectionStringW = pStringW;
	cchStringW = 0;

	while ((msgLength > 0) && pStringW[cchStringW])
	{
		msgLength -= 2;
		cchStringW++;
	}

	if (pStringW[cchStringW] || !cchStringW)
		return -1;

	cchStringW++;
	cbRaConnectionStringW = cchStringW * 2;

	pdu.raConnectionString = NULL;

	status = ConvertFromUnicode(CP_UTF8, 0, raConnectionStringW,
			cbRaConnectionStringW / 2, &pdu.raConnectionString, 0, NULL, NULL);

	if (status <= 0)
		return -1;

	printf("RaConnectionString: %s\n",
			pdu.raConnectionString);

	free(pdu.raConnectionString);

	remdesk_send_ctl_result_pdu(context, 0);

	return 1;
}
开发者ID:alexeilebedev,项目名称:FreeRDP,代码行数:45,代码来源:remdesk_main.c

示例3: CreateEventW

HANDLE CreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState,
                    LPCWSTR lpName)
{
	HANDLE handle;
	char* name = NULL;

	if (lpName)
	{
		int rc = ConvertFromUnicode(CP_UTF8, 0, lpName, -1, &name, 0, NULL, NULL);

		if (rc < 0)
			return NULL;
	}

	handle = CreateEventA(lpEventAttributes, bManualReset, bInitialState, name);
	free(name);
	return handle;
}
开发者ID:FreeRDP,项目名称:FreeRDP,代码行数:18,代码来源:event.c

示例4: cliprdr_process_short_format_names

void cliprdr_process_short_format_names(cliprdrPlugin* cliprdr, wStream* s, UINT32 length, UINT16 flags)
{
	int i;
	BOOL ascii;
	int num_formats;
	CLIPRDR_FORMAT_NAME* format_name;

	num_formats = length / 36;

	if (num_formats <= 0)
	{
		cliprdr->format_names = NULL;
		cliprdr->num_format_names = 0;
		return;
	}

	if (num_formats * 36 != length)
		DEBUG_WARN("dataLen %d not divided by 36!", length);

	ascii = (flags & CB_ASCII_NAMES) ? TRUE : FALSE;

	cliprdr->format_names = (CLIPRDR_FORMAT_NAME*) malloc(sizeof(CLIPRDR_FORMAT_NAME) * num_formats);
	cliprdr->num_format_names = num_formats;

	for (i = 0; i < num_formats; i++)
	{
		format_name = &cliprdr->format_names[i];

		Stream_Read_UINT32(s, format_name->id);

		if (ascii)
		{
			format_name->name = _strdup((char*) s->pointer);
			format_name->length = strlen(format_name->name);
		}
		else
		{
			format_name->name = NULL;
			format_name->length = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) s->pointer, 32 / 2, &format_name->name, 0, NULL, NULL);
		}

		Stream_Seek(s, 32);
	}
}
开发者ID:AhmadKabakibi,项目名称:FreeRDP,代码行数:44,代码来源:cliprdr_format.c

示例5: clipboard_synthesize_cf_text

static void* clipboard_synthesize_cf_text(wClipboard* clipboard, UINT32 formatId, const void* data,
        UINT32* pSize)
{
	int size;
	char* pDstData = NULL;

	if (formatId == CF_UNICODETEXT)
	{
		size_t wsize;
		char* str = NULL;

		if (*pSize > INT32_MAX)
			return NULL;

		wsize = _wcsnlen(data, (*pSize) / 2);
		size = ConvertFromUnicode(CP_UTF8, 0, (LPCWSTR) data,
		                          wsize, (CHAR**) &str, 0, NULL, NULL);

		if (!str)
			return NULL;

		pDstData = ConvertLineEndingToCRLF((const char*) str, &size);
		free(str);
		*pSize = size;
		return pDstData;
	}
	else if ((formatId == CF_TEXT) || (formatId == CF_OEMTEXT) ||
	         (formatId == ClipboardGetFormatId(clipboard, "UTF8_STRING")) ||
	         (formatId == ClipboardGetFormatId(clipboard, "text/plain")) ||
	         (formatId == ClipboardGetFormatId(clipboard, "TEXT")) ||
	         (formatId == ClipboardGetFormatId(clipboard, "STRING")))
	{
		size = (INT64) * pSize;
		pDstData = ConvertLineEndingToCRLF((const char*) data, &size);

		if (!pDstData)
			return NULL;

		*pSize = size;
		return pDstData;
	}

	return NULL;
}
开发者ID:FreeRDP,项目名称:FreeRDP,代码行数:44,代码来源:synthetic.c

示例6: parallel_process_irp_create

static void parallel_process_irp_create(PARALLEL_DEVICE* parallel, IRP* irp)
{
	char* path;
	int status;
	UINT32 PathLength;

	stream_seek(irp->input, 28);
	/* DesiredAccess(4) AllocationSize(8), FileAttributes(4) */
	/* SharedAccess(4) CreateDisposition(4), CreateOptions(4) */
	stream_read_UINT32(irp->input, PathLength);

	status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(irp->input),
			PathLength / 2, &path, 0, NULL, NULL);

	if (status < 1)
		path = (char*) calloc(1, 1);

	parallel->id = irp->devman->id_sequence++;
	parallel->file = open(parallel->path, O_RDWR);

	if (parallel->file < 0)
	{
		irp->IoStatus = STATUS_ACCESS_DENIED;
		parallel->id = 0;

		DEBUG_WARN("failed to create %s: %s", parallel->path, strerror(errno));
	}
	else
	{
		/* all read and write operations should be non-blocking */
		if (fcntl(parallel->file, F_SETFL, O_NONBLOCK) == -1)
			DEBUG_WARN("%s fcntl %s", path, strerror(errno));

		DEBUG_SVC("%s(%d) created", parallel->path, parallel->file);
	}

	stream_write_UINT32(irp->output, parallel->id);
	stream_write_BYTE(irp->output, 0);

	free(path);

	irp->Complete(irp);
}
开发者ID:Arkantos7,项目名称:FreeRDP,代码行数:43,代码来源:parallel_main.c

示例7: _IoCreateDeviceEx

NTSTATUS _IoCreateDeviceEx(PDRIVER_OBJECT_EX DriverObject, ULONG DeviceExtensionSize, PUNICODE_STRING DeviceName,
		DEVICE_TYPE DeviceType, ULONG DeviceCharacteristics, BOOLEAN Exclusive, PDEVICE_OBJECT_EX* DeviceObject)
{
	int status;
	char* DeviceBasePath;
	DEVICE_OBJECT_EX* pDeviceObjectEx;

	DeviceBasePath = GetDeviceFileUnixDomainSocketBaseFilePathA();

	if (!PathFileExistsA(DeviceBasePath))
	{
		if (!mkdir(DeviceBasePath, S_IRUSR | S_IWUSR | S_IXUSR))
		{
			free(DeviceBasePath);
			return STATUS_ACCESS_DENIED;
		}
	}

	pDeviceObjectEx = (DEVICE_OBJECT_EX*) malloc(sizeof(DEVICE_OBJECT_EX));

	if (!pDeviceObjectEx)
	{
		return STATUS_NO_MEMORY;
	}

	ZeroMemory(pDeviceObjectEx, sizeof(DEVICE_OBJECT_EX));

	ConvertFromUnicode(CP_UTF8, 0, DeviceName->Buffer, DeviceName->Length / 2, &(pDeviceObjectEx->DeviceName), 0, NULL, NULL);

	pDeviceObjectEx->DeviceFileName = GetDeviceFileUnixDomainSocketFilePathA(pDeviceObjectEx->DeviceName);

	if (PathFileExistsA(pDeviceObjectEx->DeviceFileName))
	{
		unlink(pDeviceObjectEx->DeviceFileName);
	}

	status = mkfifo(pDeviceObjectEx->DeviceFileName, 0666);

	*((ULONG_PTR*) (DeviceObject)) = (ULONG_PTR) pDeviceObjectEx;

	return STATUS_SUCCESS;
}
开发者ID:AMV007,项目名称:FreeRDP,代码行数:42,代码来源:device.c

示例8: rdp_redirection_read_unicode_string

static BOOL rdp_redirection_read_unicode_string(wStream* s, char** str, size_t maxLength)
{
	UINT32 length;
	WCHAR* wstr = NULL;

	if (Stream_GetRemainingLength(s) < 4)
	{
		WLog_ERR(TAG,  "rdp_redirection_read_string failure: cannot read length");
		return FALSE;
	}

	Stream_Read_UINT32(s, length);

	if ((length % 2) || length < 2 || length > maxLength)
	{
		WLog_ERR(TAG,  "rdp_redirection_read_string failure: invalid unicode string length: %"PRIu32"", length);
		return FALSE;
	}

	if (Stream_GetRemainingLength(s) < length)
	{
		WLog_ERR(TAG,  "rdp_redirection_read_string failure: insufficient stream length (%"PRIu32" bytes required)", length);
		return FALSE;
	}

	wstr = (WCHAR*) Stream_Pointer(s);

	if (wstr[length / 2 - 1])
	{
		WLog_ERR(TAG,  "rdp_redirection_read_string failure: unterminated unicode string");
		return FALSE;
	}

	if (ConvertFromUnicode(CP_UTF8, 0, wstr, -1, str, 0, NULL, NULL) < 1)
	{
		WLog_ERR(TAG,  "rdp_redirection_read_string failure: string conversion failed");
		return FALSE;
	}
	Stream_Seek(s, length);
	return TRUE;
}
开发者ID:JunaidLoonat,项目名称:FreeRDP,代码行数:41,代码来源:redirection.c

示例9: cliprdr_process_long_format_names

void cliprdr_process_long_format_names(cliprdrPlugin* cliprdr, wStream* s, UINT32 length, UINT16 flags)
{
	int allocated_formats = 8;
	BYTE* end_mark;
	CLIPRDR_FORMAT_NAME* format_name;
	
	Stream_GetPointer(s, end_mark);
	end_mark += length;
		
	cliprdr->format_names = (CLIPRDR_FORMAT_NAME*) malloc(sizeof(CLIPRDR_FORMAT_NAME) * allocated_formats);
	cliprdr->num_format_names = 0;

	while (Stream_GetRemainingLength(s) >= 6)
	{
		BYTE* p;
		int name_len;
		
		if (cliprdr->num_format_names >= allocated_formats)
		{
			allocated_formats *= 2;
			cliprdr->format_names = (CLIPRDR_FORMAT_NAME*) realloc(cliprdr->format_names,
					sizeof(CLIPRDR_FORMAT_NAME) * allocated_formats);
		}
		
		format_name = &cliprdr->format_names[cliprdr->num_format_names++];
		Stream_Read_UINT32(s, format_name->id);
		
		format_name->name = NULL;
		format_name->length = 0;

		for (p = Stream_Pointer(s), name_len = 0; p + 1 < end_mark; p += 2, name_len += 2)
		{
			if (*((unsigned short*) p) == 0)
				break;
		}
		
		format_name->length = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), name_len / 2, &format_name->name, 0, NULL, NULL);

		Stream_Seek(s, name_len + 2);
	}
}
开发者ID:AhmadKabakibi,项目名称:FreeRDP,代码行数:41,代码来源:cliprdr_format.c

示例10: nsMsgI18NEncodeMimePartIIStr

// MIME encoder, output string should be freed by PR_FREE
// XXX : fix callers later to avoid allocation and copy
char * nsMsgI18NEncodeMimePartIIStr(const char *header, bool structured, const char *charset, int32_t fieldnamelen, bool usemime) 
{
  // No MIME, convert to the outgoing mail charset.
  if (false == usemime) {
    nsAutoCString convertedStr;
    if (NS_SUCCEEDED(ConvertFromUnicode(charset, NS_ConvertUTF8toUTF16(header),
                                        convertedStr)))
      return PL_strdup(convertedStr.get());
    else
      return PL_strdup(header);
  }

  char *encodedString = nullptr;
  nsresult res;
  nsCOMPtr<nsIMimeConverter> converter = do_GetService(NS_MIME_CONVERTER_CONTRACTID, &res);
  if (NS_SUCCEEDED(res) && nullptr != converter)
    res = converter->EncodeMimePartIIStr_UTF8(nsDependentCString(header), structured, charset,
      fieldnamelen, nsIMimeConverter::MIME_ENCODED_WORD_SIZE, &encodedString);

  return NS_SUCCEEDED(res) ? encodedString : nullptr;
}
开发者ID:aleth,项目名称:releases-comm-central,代码行数:23,代码来源:nsMsgI18N.cpp

示例11: remdesk_recv_ctl_verify_password_pdu

static int remdesk_recv_ctl_verify_password_pdu(RemdeskServerContext* context, wStream* s, REMDESK_CHANNEL_HEADER* header)
{
	int status;
	int cbExpertBlobW = 0;
	WCHAR* expertBlobW = NULL;
	REMDESK_CTL_VERIFY_PASSWORD_PDU pdu;

	if (Stream_GetRemainingLength(s) < 8)
		return -1;

	pdu.expertBlob = NULL;
	expertBlobW = (WCHAR*) Stream_Pointer(s);
	cbExpertBlobW = header->DataLength - 4;

	status = ConvertFromUnicode(CP_UTF8, 0, expertBlobW, cbExpertBlobW / 2, &pdu.expertBlob, 0, NULL, NULL);

	printf("ExpertBlob: %s\n", pdu.expertBlob);

	remdesk_send_ctl_result_pdu(context, 0);

	return 1;
}
开发者ID:alexeilebedev,项目名称:FreeRDP,代码行数:22,代码来源:remdesk_main.c

示例12: rdp_redirection_read_string

BOOL rdp_redirection_read_string(wStream* s, char** str)
{
	UINT32 length;

	if (Stream_GetRemainingLength(s) < 4)
	{
		WLog_ERR(TAG,  "rdp_redirection_read_string failure: cannot read length");
		return FALSE;
	}

	Stream_Read_UINT32(s, length);

	if (Stream_GetRemainingLength(s) < length)
	{
		WLog_ERR(TAG,  "rdp_redirection_read_string failure: incorrect length %d", length);
		return FALSE;
	}

	ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), length / 2, str, 0, NULL, NULL);
	Stream_Seek(s, length);
	return TRUE;
}
开发者ID:BenoitDevolutions,项目名称:FreeRDP,代码行数:22,代码来源:redirection.c

示例13: drive_process_irp_query_directory

/**
 * Function description
 *
 * @return 0 on success, otherwise a Win32 error code
 */
static UINT drive_process_irp_query_directory(DRIVE_DEVICE* drive, IRP* irp)
{
	char* path = NULL;
	int status;
	DRIVE_FILE* file;
	BYTE InitialQuery;
	UINT32 PathLength;
	UINT32 FsInformationClass;
	Stream_Read_UINT32(irp->input, FsInformationClass);
	Stream_Read_UINT8(irp->input, InitialQuery);
	Stream_Read_UINT32(irp->input, PathLength);
	Stream_Seek(irp->input, 23); /* Padding */
	status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(irp->input),
	                            PathLength / 2, &path, 0, NULL, NULL);

	if (status < 1)
		if (!(path = (char*) calloc(1, 1)))
		{
			WLog_ERR(TAG, "calloc failed!");
			return CHANNEL_RC_NO_MEMORY;
		}

	file = drive_get_file_by_id(drive, irp->FileId);

	if (file == NULL)
	{
		irp->IoStatus = STATUS_UNSUCCESSFUL;
		Stream_Write_UINT32(irp->output, 0); /* Length */
	}
	else if (!drive_file_query_directory(file, FsInformationClass, InitialQuery,
	                                     path, irp->output))
	{
		irp->IoStatus = STATUS_NO_MORE_FILES;
	}

	free(path);
	return irp->Complete(irp);
}
开发者ID:dcatonR1,项目名称:FreeRDP,代码行数:43,代码来源:drive_main.c

示例14: clipboard_synthesize_utf8_string

static void* clipboard_synthesize_utf8_string(wClipboard* clipboard, UINT32 formatId,
        const void* data, UINT32* pSize)
{
	INT64 size;
	char* pDstData = NULL;

	if (formatId == CF_UNICODETEXT)
	{
		size_t wsize = _wcsnlen(data, (*pSize) / 2);
		size = ConvertFromUnicode(CP_UTF8, 0, (LPWSTR) data,
		                          wsize, (CHAR**) &pDstData, 0, NULL, NULL);

		if (!pDstData)
			return NULL;

		size = ConvertLineEndingToLF(pDstData, size);
		*pSize = size;
		return pDstData;
	}
	else if ((formatId == CF_TEXT) || (formatId == CF_OEMTEXT) ||
	         (formatId == ClipboardGetFormatId(clipboard, "text/plain")) ||
	         (formatId == ClipboardGetFormatId(clipboard, "TEXT")) ||
	         (formatId == ClipboardGetFormatId(clipboard, "STRING")))
	{
		size = (INT64) * pSize;
		pDstData = (char*) malloc(size);

		if (!pDstData)
			return NULL;

		CopyMemory(pDstData, data, size);
		size = ConvertLineEndingToLF((char*) pDstData, size);
		*pSize = size;
		return pDstData;
	}

	return NULL;
}
开发者ID:FreeRDP,项目名称:FreeRDP,代码行数:38,代码来源:synthetic.c

示例15: drive_process_irp_query_directory

static void drive_process_irp_query_directory(DRIVE_DEVICE* disk, IRP* irp)
{
	char* path;
	int status;
	DRIVE_FILE* file;
	BYTE InitialQuery;
	UINT32 PathLength;
	UINT32 FsInformationClass;

	stream_read_UINT32(irp->input, FsInformationClass);
	stream_read_BYTE(irp->input, InitialQuery);
	stream_read_UINT32(irp->input, PathLength);
	stream_seek(irp->input, 23); /* Padding */

	status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(irp->input),
			PathLength / 2, &path, 0, NULL, NULL);

	if (status < 1)
		path = (char*) calloc(1, 1);

	file = drive_get_file_by_id(disk, irp->FileId);

	if (file == NULL)
	{
		irp->IoStatus = STATUS_UNSUCCESSFUL;
		stream_write_UINT32(irp->output, 0); /* Length */
		DEBUG_WARN("FileId %d not valid.", irp->FileId);
	}
	else if (!drive_file_query_directory(file, FsInformationClass, InitialQuery, path, irp->output))
	{
		irp->IoStatus = STATUS_NO_MORE_FILES;
	}

	free(path);

	irp->Complete(irp);
}
开发者ID:effort,项目名称:FreeRDP,代码行数:37,代码来源:drive_main.c


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