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


C++ ConvertToUnicode函数代码示例

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


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

示例1: sspi_SetAuthIdentity

void sspi_SetAuthIdentity(SEC_WINNT_AUTH_IDENTITY* identity, char* user, char* domain, char* password)
{
	identity->Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;

	if (user)
	{
		identity->UserLength = ConvertToUnicode(CP_UTF8, 0, user, -1, &identity->User, 0) - 1;
	}
	else
	{
		identity->User = (UINT16*) NULL;
		identity->UserLength = 0;
	}

	if (domain)
	{
		identity->DomainLength = ConvertToUnicode(CP_UTF8, 0, domain, -1, &identity->Domain, 0) - 1;
	}
	else
	{
		identity->Domain = (UINT16*) NULL;
		identity->DomainLength = 0;
	}

	if (password != NULL)
	{
		identity->PasswordLength = ConvertToUnicode(CP_UTF8, 0, password, -1, &identity->Password, 0) - 1;
	}
	else
	{
		identity->Password = NULL;
		identity->PasswordLength = 0;
	}
}
开发者ID:ayoubkiler,项目名称:FreeRDP,代码行数:34,代码来源:sspi.c

示例2: test_unicode_uppercasing

int test_unicode_uppercasing(BYTE* lower, BYTE* upper)
{
	WCHAR* lowerW = NULL;
	int lowerLength;
	WCHAR* upperW = NULL;
	int upperLength;

	lowerLength = ConvertToUnicode(CP_UTF8, 0, (LPSTR) lower, -1, &lowerW, 0);
	upperLength = ConvertToUnicode(CP_UTF8, 0, (LPSTR) upper, -1, &upperW, 0);

	CharUpperBuffW(lowerW, lowerLength);

	if (_wcscmp(lowerW, upperW) != 0)
	{
		printf("Lowercase String:\n");
		string_hexdump((BYTE*) lowerW, lowerLength * 2);

		printf("Uppercase String:\n");
		string_hexdump((BYTE*) upperW, upperLength * 2);

		return -1;
	}

	free(lowerW);
	free(upperW);

	return 0;
}
开发者ID:BUGgs,项目名称:FreeRDP,代码行数:28,代码来源:TestUnicodeConversion.c

示例3: do_GetService

// This method is called during the sending of message from nsMsgCompose::CheckAndPopulateRecipients()
nsresult nsMsgCompFields::SplitRecipientsEx(const nsAString &recipients,
                                            nsTArray<nsMsgRecipient> &aResult)
{
  nsresult rv;
  
  nsCOMPtr<nsIMsgHeaderParser> parser =
    do_GetService(NS_MAILNEWS_MIME_HEADER_PARSER_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv, rv);
  nsCOMPtr<nsIMimeConverter> converter = do_GetService(NS_MIME_CONVERTER_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCAutoString recipientsStr;
  char *names;
  char *addresses;
  PRUint32 numAddresses;
      
  CopyUTF16toUTF8(recipients, recipientsStr);
  rv = parser->ParseHeaderAddresses(recipientsStr.get(), &names,
                                    &addresses, &numAddresses);
  if (NS_SUCCEEDED(rv))
  {
    char *pNames = names;
    char *pAddresses = addresses;

    for (PRUint32 i = 0; i < numAddresses; ++i)
    {
      nsCString fullAddress;
      nsCString decodedName;
      converter->DecodeMimeHeaderToCharPtr(pNames, GetCharacterSet(), false, true, 
                                           getter_Copies(decodedName));
      rv = parser->MakeFullAddressString((!decodedName.IsEmpty() ? 
                                          decodedName.get() : pNames), 
                                         pAddresses, 
                                         getter_Copies(fullAddress));

      nsMsgRecipient msgRecipient;

      rv = ConvertToUnicode("UTF-8",
                            NS_SUCCEEDED(rv) ? fullAddress.get() : pAddresses,
                            msgRecipient.mAddress);
      if (NS_FAILED(rv))
        return rv;

      rv = ConvertToUnicode("UTF-8", pAddresses, msgRecipient.mEmail);
      if (NS_FAILED(rv))
        return rv;

      aResult.AppendElement(msgRecipient);

      pNames += PL_strlen(pNames) + 1;
      pAddresses += PL_strlen(pAddresses) + 1;
    }

    PR_FREEIF(names);
    PR_FREEIF(addresses);
  }
 
  return rv;
}
开发者ID:vanto,项目名称:comm-central,代码行数:60,代码来源:nsMsgCompFields.cpp

示例4: nla_make_spn

LPTSTR nla_make_spn(const char* ServiceClass, const char* hostname)
{
	DWORD status;
	DWORD SpnLength;
	LPTSTR hostnameX = NULL;
	LPTSTR ServiceClassX = NULL;
	LPTSTR ServicePrincipalName = NULL;
#ifdef UNICODE
	ConvertToUnicode(CP_UTF8, 0, hostname, -1, &hostnameX, 0);
	ConvertToUnicode(CP_UTF8, 0, ServiceClass, -1, &ServiceClassX, 0);
#else
	hostnameX = _strdup(hostname);
	ServiceClassX = _strdup(ServiceClass);
#endif
	if (!hostnameX || !ServiceClassX)
	{
		free(hostnameX);
		free(ServiceClassX);
		return NULL;
	}

	if (!ServiceClass)
	{
		ServicePrincipalName = (LPTSTR) _tcsdup(hostnameX);
		free(ServiceClassX);
		free(hostnameX);
		return ServicePrincipalName;
	}

	SpnLength = 0;
	status = DsMakeSpn(ServiceClassX, hostnameX, NULL, 0, NULL, &SpnLength, NULL);

	if (status != ERROR_BUFFER_OVERFLOW)
	{
		free(ServiceClassX);
		free(hostnameX);
		return NULL;
	}

	ServicePrincipalName = (LPTSTR) malloc(SpnLength * sizeof(TCHAR));

	if (!ServicePrincipalName)
		return NULL;

	status = DsMakeSpn(ServiceClassX, hostnameX, NULL, 0, NULL, &SpnLength, ServicePrincipalName);

	if (status != ERROR_SUCCESS)
	{
		free(ServicePrincipalName);
		free(ServiceClassX);
		free(hostnameX);
		return NULL;
	}

	free(ServiceClassX);
	free(hostnameX);
	return ServicePrincipalName;
}
开发者ID:BrianChangchien,项目名称:FiWoRDC,代码行数:58,代码来源:nla.c

示例5: sspi_SetAuthIdentity

int sspi_SetAuthIdentity(SEC_WINNT_AUTH_IDENTITY* identity, const char* user, const char* domain, const char* password)
{
	int status;

	identity->Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;

	if (identity->User)
		free(identity->User);

	identity->User = (UINT16*) NULL;
	identity->UserLength = 0;

	if (user)
	{
		status = ConvertToUnicode(CP_UTF8, 0, user, -1, (LPWSTR*) &(identity->User), 0);

		if (status <= 0)
			return -1;

		identity->UserLength = (ULONG) (status - 1);
	}

	if (identity->Domain)
		free(identity->Domain);

	identity->Domain = (UINT16*) NULL;
	identity->DomainLength = 0;

	if (domain)
	{
		status = ConvertToUnicode(CP_UTF8, 0, domain, -1, (LPWSTR*) &(identity->Domain), 0);

		if (status <= 0)
			return -1;

		identity->DomainLength = (ULONG) (status - 1);
	}

	if (identity->Password)
		free(identity->Password);

	identity->Password = NULL;
	identity->PasswordLength = 0;

	if (password)
	{
		status = ConvertToUnicode(CP_UTF8, 0, password, -1, (LPWSTR*) &(identity->Password), 0);

		if (status <= 0)
			return -1;

		identity->PasswordLength = (ULONG) (status - 1);
	}

	return 1;
}
开发者ID:Auto-Droid,项目名称:FreeRDP,代码行数:56,代码来源:sspi_winpr.c

示例6: rdp_write_extended_info_packet

void rdp_write_extended_info_packet(rdpRdp* rdp, wStream* s)
{
	int clientAddressFamily;
	WCHAR* clientAddress = NULL;
	int cbClientAddress;
	WCHAR* clientDir = NULL;
	int cbClientDir;
	int cbAutoReconnectCookie;
	rdpSettings* settings = rdp->settings;

	clientAddressFamily = settings->IPv6Enabled ? ADDRESS_FAMILY_INET6 : ADDRESS_FAMILY_INET;

	cbClientAddress = ConvertToUnicode(CP_UTF8, 0, settings->ClientAddress, -1, &clientAddress, 0) * 2;

	cbClientDir = ConvertToUnicode(CP_UTF8, 0, settings->ClientDir, -1, &clientDir, 0) * 2;

	cbAutoReconnectCookie = (int) settings->ServerAutoReconnectCookie->cbLen;

	Stream_Write_UINT16(s, clientAddressFamily); /* clientAddressFamily (2 bytes) */

	Stream_Write_UINT16(s, cbClientAddress + 2); /* cbClientAddress (2 bytes) */

	if (cbClientAddress > 0)
		Stream_Write(s, clientAddress, cbClientAddress); /* clientAddress */
	Stream_Write_UINT16(s, 0);

	Stream_Write_UINT16(s, cbClientDir + 2); /* cbClientDir (2 bytes) */

	if (cbClientDir > 0)
		Stream_Write(s, clientDir, cbClientDir); /* clientDir */
	Stream_Write_UINT16(s, 0);

	rdp_write_client_time_zone(s, settings); /* clientTimeZone (172 bytes) */

	Stream_Write_UINT32(s, 0); /* clientSessionId (4 bytes), should be set to 0 */

	freerdp_performance_flags_make(settings);
	Stream_Write_UINT32(s, settings->PerformanceFlags); /* performanceFlags (4 bytes) */

	Stream_Write_UINT16(s, cbAutoReconnectCookie); /* cbAutoReconnectCookie (2 bytes) */

	if (cbAutoReconnectCookie > 0)
	{
		rdp_compute_client_auto_reconnect_cookie(rdp);

		rdp_write_client_auto_reconnect_cookie(rdp, s); /* autoReconnectCookie */

		Stream_Write_UINT16(s, 0); /* reserved1 (2 bytes) */
		Stream_Write_UINT16(s, 0); /* reserved2 (2 bytes) */
	}

	free(clientAddress);
	free(clientDir);
}
开发者ID:C4rt,项目名称:FreeRDP,代码行数:54,代码来源:info.c

示例7: remdesk_send_ctl_authenticate_pdu

static int remdesk_send_ctl_authenticate_pdu(remdeskPlugin* remdesk)
{
	int status;
	wStream* s;
	int cbExpertBlobW = 0;
	WCHAR* expertBlobW = NULL;
	int cbRaConnectionStringW = 0;
	WCHAR* raConnectionStringW = NULL;
	REMDESK_CTL_AUTHENTICATE_PDU pdu;

	status = remdesk_generate_expert_blob(remdesk);

	if (status < 0)
		return -1;

	pdu.expertBlob = remdesk->ExpertBlob;
	pdu.raConnectionString = remdesk->settings->RemoteAssistanceRCTicket;

	status = ConvertToUnicode(CP_UTF8, 0, pdu.raConnectionString, -1, &raConnectionStringW, 0);

	if (status <= 0)
		return -1;

	cbRaConnectionStringW = status * 2;

	status = ConvertToUnicode(CP_UTF8, 0, pdu.expertBlob, -1, &expertBlobW, 0);

	if (status <= 0)
		return -1;

	cbExpertBlobW = status * 2;

	remdesk_prepare_ctl_header(&(pdu.ctlHeader), REMDESK_CTL_AUTHENTICATE,
			cbRaConnectionStringW + cbExpertBlobW);

	s = Stream_New(NULL, REMDESK_CHANNEL_CTL_SIZE + pdu.ctlHeader.DataLength);

	remdesk_write_ctl_header(s, &(pdu.ctlHeader));

	Stream_Write(s, (BYTE*) raConnectionStringW, cbRaConnectionStringW);
	Stream_Write(s, (BYTE*) expertBlobW, cbExpertBlobW);

	Stream_SealLength(s);

	remdesk_virtual_channel_write(remdesk, s);

	free(raConnectionStringW);
	free(expertBlobW);

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

示例8: LoadLibraryA

HMODULE LoadLibraryA(LPCSTR lpLibFileName)
{
#if defined(_UWP)
	int status;
	HMODULE hModule = NULL;
	WCHAR* filenameW = NULL;

	if (!lpLibFileName)
		return NULL;

	status = ConvertToUnicode(CP_UTF8, 0, lpLibFileName, -1, &filenameW, 0);

	if (status < 1)
		return NULL;

	hModule = LoadPackagedLibrary(filenameW, 0);

	free(filenameW);

	return hModule;
#else
	HMODULE library;

	library = dlopen(lpLibFileName, RTLD_LOCAL | RTLD_LAZY);

	if (!library)
	{
		WLog_ERR(TAG, "LoadLibraryA: %s", dlerror());
		return NULL;
	}

	return library;
#endif
}
开发者ID:BrianChangchien,项目名称:FiWoRDC,代码行数:34,代码来源:library.c

示例9: cliprdr_temp_directory

int cliprdr_temp_directory(CliprdrClientContext* context, CLIPRDR_TEMP_DIRECTORY* tempDirectory)
{
	int length;
	wStream* s;
	WCHAR* wszTempDir = NULL;
	cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;

	s = cliprdr_packet_new(CB_TEMP_DIRECTORY, 0, 520 * 2);

	length = ConvertToUnicode(CP_UTF8, 0, tempDirectory->szTempDir, -1, &wszTempDir, 0);

	if (length < 0)
		return -1;

	if (length > 520)
		length = 520;

	Stream_Write(s, tempDirectory->szTempDir, length * 2);
	Stream_Zero(s, (520 - length) * 2);

	free(wszTempDir);

	WLog_Print(cliprdr->log, WLOG_DEBUG, "TempDirectory: %s",
			tempDirectory->szTempDir);

	cliprdr_packet_send(cliprdr, s);

	return 1;
}
开发者ID:akallabeth,项目名称:FreeRDP,代码行数:29,代码来源:cliprdr_main.c

示例10: statvfs

int statvfs(const char *path, struct statvfs *buf)
{
	BOOL res;
	int len;
	LPWSTR unicodestr = NULL;
	DWORD lpSectorsPerCluster;
	DWORD lpBytesPerSector;
	DWORD lpNumberOfFreeClusters;
	DWORD lpTotalNumberOfClusters;

	len = ConvertToUnicode(CP_ACP, 0, path, -1, &unicodestr, 0);
	if (len <= 0)
		return -1;

	res = GetDiskFreeSpaceW(unicodestr, &lpSectorsPerCluster, &lpBytesPerSector, &lpNumberOfFreeClusters, &lpTotalNumberOfClusters);
	free(unicodestr);

	buf->f_bsize = lpBytesPerSector; /* file system block size */
	buf->f_frsize = 0; /* fragment size */
	buf->f_blocks = lpTotalNumberOfClusters; /* size of fs in f_frsize units */
	buf->f_bfree = lpNumberOfFreeClusters; /* # free blocks */
	buf->f_bavail = lpNumberOfFreeClusters; /* # free blocks for unprivileged users */
	buf->f_files = 0; /* # inodes */
	buf->f_ffree = 0; /* # free inodes */
	buf->f_favail = 0; /* # free inodes for unprivileged users */
	buf->f_fsid = lpNumberOfFreeClusters & 0xffff; /* file system ID */
	buf->f_flag = 0; /* mount flags */
	buf->f_namemax = 250; /* maximum filename length */
	
	return res;
}
开发者ID:BrianChangchien,项目名称:FiWoRDC,代码行数:31,代码来源:statvfs.c

示例11: clipboard_synthesize_cf_unicodetext

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

	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")))
	{
		if (!pSize || (*pSize > INT32_MAX))
			return NULL;

		size = (int) * pSize;
		crlfStr = ConvertLineEndingToCRLF((char*) data, &size);

		if (!crlfStr)
			return NULL;

		status = ConvertToUnicode(CP_UTF8, 0, crlfStr, size, &pDstData, 0);
		free(crlfStr);

		if (status <= 0)
			return NULL;

		*pSize = status * 2;
	}

	return (void*) pDstData;
}
开发者ID:FreeRDP,项目名称:FreeRDP,代码行数:34,代码来源:synthetic.c

示例12: ntlm_SetContextWorkstation

int ntlm_SetContextWorkstation(NTLM_CONTEXT* context, char* Workstation)
{
	int status;
	DWORD nSize = 0;
	char* ws = Workstation;

	if (!Workstation)
	{
		GetComputerNameExA(ComputerNameNetBIOS, NULL, &nSize);
		
		ws = (char*) malloc(nSize);

		if (!ws)
			return -1;

		if (!GetComputerNameExA(ComputerNameNetBIOS, ws, &nSize))
			return 0;
	}

	context->Workstation.Buffer = NULL;
	status = ConvertToUnicode(CP_UTF8, 0, ws, -1, &context->Workstation.Buffer, 0);
	free(ws);

	if (status <= 0)
		return -1;

	context->Workstation.Length = (USHORT) (status - 1);
	context->Workstation.Length *= 2;

	if (!Workstation)
		free(Workstation);

	return 1;
}
开发者ID:Auto-Droid,项目名称:FreeRDP,代码行数:34,代码来源:ntlm.c

示例13: nsMsgI18NConvertRawBytesToUTF16

void nsMsgI18NConvertRawBytesToUTF16(const nsCString& inString, 
                                     const char* charset,
                                     nsAString& outString)
{
  if (MsgIsUTF8(inString))
  {
    CopyUTF8toUTF16(inString, outString);
    return;
  }

  nsresult rv = ConvertToUnicode(charset, inString, outString);
  if (NS_SUCCEEDED(rv))
    return;

  const char* cur = inString.BeginReading();
  const char* end = inString.EndReading();
  outString.Truncate();
  while (cur < end) {
    char c = *cur++;
    if (c & char(0x80))
      outString.Append(UCS2_REPLACEMENT_CHAR);
    else
      outString.Append(c);
  }
}
开发者ID:cmotc,项目名称:spacehamster,代码行数:25,代码来源:nsMsgI18N.cpp

示例14: rdpdr_send_client_name_request

static void rdpdr_send_client_name_request(rdpdrPlugin* rdpdr)
{
	STREAM* data_out;
	WCHAR* computerNameW = NULL;
	size_t computerNameLenW;

	if (!rdpdr->computerName[0])
		gethostname(rdpdr->computerName, sizeof(rdpdr->computerName) - 1);

	computerNameLenW = ConvertToUnicode(CP_UTF8, 0, rdpdr->computerName, -1, &computerNameW, 0) * 2;

	data_out = stream_new(16 + computerNameLenW + 2);

	stream_write_UINT16(data_out, RDPDR_CTYP_CORE);
	stream_write_UINT16(data_out, PAKID_CORE_CLIENT_NAME);

	stream_write_UINT32(data_out, 1); /* unicodeFlag, 0 for ASCII and 1 for Unicode */
	stream_write_UINT32(data_out, 0); /* codePage, must be set to zero */
	stream_write_UINT32(data_out, computerNameLenW + 2); /* computerNameLen, including null terminator */
	stream_write(data_out, computerNameW, computerNameLenW);
	stream_write_UINT16(data_out, 0); /* null terminator */

	free(computerNameW);

	svc_plugin_send((rdpSvcPlugin*) rdpdr, data_out);
}
开发者ID:4hosi,项目名称:FreeRDP,代码行数:26,代码来源:rdpdr_main.c

示例15: remdesk_send_ctl_remote_control_desktop_pdu

static int remdesk_send_ctl_remote_control_desktop_pdu(remdeskPlugin* remdesk)
{
	int status;
	wStream* s;
	int cbRaConnectionStringW = 0;
	WCHAR* raConnectionStringW = NULL;
	REMDESK_CTL_REMOTE_CONTROL_DESKTOP_PDU pdu;

	pdu.raConnectionString = remdesk->settings->RemoteAssistanceRCTicket;

	status = ConvertToUnicode(CP_UTF8, 0, pdu.raConnectionString, -1, &raConnectionStringW, 0);

	if (status <= 0)
		return -1;

	cbRaConnectionStringW = status * 2;

	remdesk_prepare_ctl_header(&(pdu.ctlHeader), REMDESK_CTL_REMOTE_CONTROL_DESKTOP, cbRaConnectionStringW);

	s = Stream_New(NULL, REMDESK_CHANNEL_CTL_SIZE + pdu.ctlHeader.DataLength);

	remdesk_write_ctl_header(s, &(pdu.ctlHeader));

	Stream_Write(s, (BYTE*) raConnectionStringW, cbRaConnectionStringW);

	Stream_SealLength(s);

	remdesk_virtual_channel_write(remdesk, s);

	free(raConnectionStringW);

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


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