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


C++ ToUTF8函数代码示例

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


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

示例1: SHGetFolderPathW

SString SharedUtil::GetSystemSystemPath ( void )
{
    wchar_t szResult[MAX_PATH] = L"";
    SHGetFolderPathW( NULL, CSIDL_SYSTEM, NULL, 0, szResult );
    if ( IsShortPathName( szResult ) )
        return GetSystemLongPathName( ToUTF8( szResult ) );
    return ToUTF8( szResult );
}
开发者ID:Cazomino05,项目名称:Test1,代码行数:8,代码来源:SharedUtil.File.hpp

示例2: GetDllDirectoryW

SString SharedUtil::GetSystemDllDirectory ( void )
{
    wchar_t szResult [ 1024 ] = L"";
    GetDllDirectoryW ( NUMELMS ( szResult ), szResult );
    if ( IsShortPathName( szResult ) )
        return GetSystemLongPathName( ToUTF8( szResult ) );
    return ToUTF8( szResult );
}
开发者ID:Cazomino05,项目名称:Test1,代码行数:8,代码来源:SharedUtil.File.hpp

示例3: GetTempPathW

SString SharedUtil::GetSystemTempPath ( void )
{
    wchar_t szResult[4030] = L"";
    GetTempPathW( 4000, szResult );
    if ( IsShortPathName( szResult ) )
        return GetSystemLongPathName( ToUTF8( szResult ) );
    return ToUTF8( szResult );
}
开发者ID:Cazomino05,项目名称:Test1,代码行数:8,代码来源:SharedUtil.File.hpp

示例4: sizeof

void
CExampleDlg::OnBnClickedConnectButton()
{
	WCHAR awcTempBuf[100];
	const int kTempBufSize = sizeof(awcTempBuf) / sizeof(awcTempBuf[0]);

	// Pull user input into our member variables
	UpdateData(TRUE);

	// Clear out the results list, in case this isn't the first time
	// we've come in here.
	ResultsList.ResetContent();

	// Translate the Unicode text we get from the UI into the UTF-8 form
	// that MySQL wants.
	const int kInputBufSize = 100;
	char acServerAddress[kInputBufSize];
	char acUserName[kInputBufSize];
	char acPassword[kInputBufSize];
	ToUTF8(acServerAddress, kInputBufSize, sServerAddress);
	ToUTF8(acUserName, kInputBufSize, sUserName);
	ToUTF8(acPassword, kInputBufSize, sPassword);

	// Connect to the sample database.
	mysqlpp::Connection con(false);
	if (!con.connect("mysql_cpp_data", acServerAddress, acUserName,
			acPassword)) {
		AddMessage(_T("Failed to connect to server:"));
		if (ToUCS2(awcTempBuf, kTempBufSize, con.error())) {
			AddMessage(awcTempBuf);
		}
		return;
	}

	// Retrieve a subset of the sample stock table set up by resetdb
	mysqlpp::Query query = con.query();
	query << "select item from stock";
	mysqlpp::StoreQueryResult res = query.store();

	if (res) {
		// Display the result set
		for (size_t i = 0; i < res.num_rows(); ++i) {
			if (ToUCS2(awcTempBuf, kTempBufSize, res[i][0])) {
				AddMessage(awcTempBuf);
			}
		}

		// Retreive was successful, so save user inputs now
		SaveInputs();
	}
	else {
		// Retreive failed
		AddMessage(_T("Failed to get item list:"));
		if (ToUCS2(awcTempBuf, kTempBufSize, query.error())) {
			AddMessage(awcTempBuf);
		}
	}
}
开发者ID:RavenX8,项目名称:mysqlpp,代码行数:58,代码来源:mfc_dlg.cpp

示例5: GetTempFilePath

EPUB3_BEGIN_NAMESPACE

static string GetTempFilePath(const string& ext)
{
#if EPUB_PLATFORM(WIN)
    TCHAR tmpPath[MAX_PATH];
    TCHAR tmpFile[MAX_PATH];

    DWORD pathLen = ::GetTempPath(MAX_PATH, tmpPath);
    if ( pathLen == 0 || pathLen > MAX_PATH )
        throw std::system_error(static_cast<int>(::GetLastError()), std::system_category());

    UINT fileLen = ::GetTempFileName(tmpPath, TEXT("ZIP"), 0, tmpFile);
    if ( fileLen == 0 )
        throw std::system_error(static_cast<int>(::GetLastError()), std::system_category());

    string r(tmpFile);
    return r;
#elif EPUB_PLATFORM(WINRT)
	using ToUTF8 = std::wstring_convert<std::codecvt_utf8<wchar_t>>;

	auto tempFolder = ::Windows::Storage::ApplicationData::Current->TemporaryFolder;
	std::wstring tempFolderPath(tempFolder->Path->Data(), tempFolder->Path->Length());
	std::wstringstream ss;

	ss << tempFolderPath;
	ss << TEXT("\\epub3.");
	ss << Windows::Security::Cryptography::CryptographicBuffer::GenerateRandomNumber();
	ss << TEXT(".");
	ss << ToUTF8().from_bytes(ext.stl_str());
	
	return ToUTF8().to_bytes(ss.str());
#else
    std::stringstream ss;
#if EPUB_OS(ANDROID)
    ss << gAndroidCacheDir << "epub3.XXXXXX";
#else
    ss << "/tmp/epub3.XXXXXX." << ext;
#endif
    string path(ss.str());
    
    char *buf = new char[path.length()];
    std::char_traits<char>::copy(buf, ss.str().c_str(), sizeof(buf));

#if EPUB_OS(ANDROID)
    int fd = ::mkstemp(buf);
#else
    int fd = ::mkstemps(buf, static_cast<int>(ext.size()+1));
#endif
    if ( fd == -1 )
        throw std::runtime_error(std::string("mkstemp() failed: ") + strerror(errno));
    
    ::close(fd);
    return string(buf);
#endif
}
开发者ID:datalogics-bhaugen,项目名称:SDKLauncher-Windows,代码行数:56,代码来源:zip_archive.cpp

示例6: mValues

  RESULT cConnection::PostRequest(const std::string& sRelativeURI, const string_t& sUserName, const string_t& sPassword, const std::map<std::string, std::string>& _mValues)
  {
    std::map<std::string, std::string> mValues(_mValues);

    mValues["version"] = "1";

    mValues["user"] = ToUTF8(sUserName);
    mValues["pass"] = ToUTF8(sPassword);

    return _PostRequest(sRelativeURI, mValues);
  }
开发者ID:pilkch,项目名称:library,代码行数:11,代码来源:libfinaltvmm.cpp

示例7: GetModuleFileNameW

// C:\Program Files\gta_sa.exe
SString SharedUtil::GetLaunchPathFilename( void )
{
    static SString strLaunchPathFilename;
    if ( strLaunchPathFilename.empty() )
    {
        wchar_t szBuffer[2048];
        GetModuleFileNameW( NULL, szBuffer, NUMELMS(szBuffer) - 1 );
        if ( IsShortPathName( szBuffer ) )
            return GetSystemLongPathName( ToUTF8( szBuffer ) );
        strLaunchPathFilename = ToUTF8( szBuffer );
    }
    return strLaunchPathFilename;
}
开发者ID:Cazomino05,项目名称:Test1,代码行数:14,代码来源:SharedUtil.File.hpp

示例8: GetCurrentDirectoryW

SString SharedUtil::GetSystemCurrentDirectory ( void )
{
#ifdef WIN32
    wchar_t szResult [ 1024 ] = L"";
    GetCurrentDirectoryW ( NUMELMS ( szResult ), szResult );
    if ( IsShortPathName( szResult ) )
        return GetSystemLongPathName( ToUTF8( szResult ) );
    return ToUTF8( szResult );
#else
    char szBuffer[ MAX_PATH ];
    getcwd ( szBuffer, MAX_PATH - 1 );
    return szBuffer;
#endif
}
开发者ID:Cazomino05,项目名称:Test1,代码行数:14,代码来源:SharedUtil.File.hpp

示例9: assert

  RESULT cConnection::WatchingMovie(const string_t& sTitle, const cDuration& durationThroughMovie, const cDuration& durationOfMovie)
  {
    assert(IsOpen());

    std::map<std::string, std::string> mValues;

    mValues["action"] = "watching";
    mValues["title"] = ToUTF8(sTitle);
    mValues["position_seconds"] = ToUTF8(durationThroughMovie);
    mValues["length_seconds"] = ToUTF8(durationOfMovie);

    RESULT result = PostRequest("submit.php", sUserName, sPassword, mValues);

    return result;
  }
开发者ID:pilkch,项目名称:library,代码行数:15,代码来源:libfinaltvmm.cpp

示例10: NS_UnescapeURL

NS_IMETHODIMP  
nsUTF8ConverterService::ConvertURISpecToUTF8(const nsACString &aSpec, 
                                             const char *aCharset, 
                                             nsACString &aUTF8Spec)
{
  // assume UTF-8 if the spec contains unescaped non-ASCII characters.
  // No valid spec in Mozilla would break this assumption.
  if (!IsASCII(aSpec)) {
    aUTF8Spec = aSpec;
    return NS_OK;
  }

  aUTF8Spec.Truncate();

  nsAutoCString unescapedSpec; 
  // NS_UnescapeURL does not fill up unescapedSpec unless there's at least 
  // one character to unescape.
  bool written = NS_UnescapeURL(PromiseFlatCString(aSpec).get(), aSpec.Length(), 
                                  esc_OnlyNonASCII, unescapedSpec);

  if (!written) {
    aUTF8Spec = aSpec;
    return NS_OK;
  }
  // return if ASCII only or escaped UTF-8
  if (IsASCII(unescapedSpec) || IsUTF8(unescapedSpec)) {
    aUTF8Spec = unescapedSpec;
    return NS_OK;
  }

  return ToUTF8(unescapedSpec, aCharset, true, aUTF8Spec);
}
开发者ID:Gabuzo,项目名称:mozilla-central,代码行数:32,代码来源:nsUTF8ConverterService.cpp

示例11: SendMessage

wstring MediaPlayers::GetTitleFromWinampAPI(HWND hwnd, bool use_unicode) {
    if (IsWindow(hwnd)) {
        if (SendMessage(hwnd, WM_USER, 0, IPC_ISPLAYING)) {
            int list_index = SendMessage(hwnd, WM_USER, 0, IPC_GETLISTPOS);
            int base_address = SendMessage(hwnd, WM_USER, list_index,
                                           use_unicode ? IPC_GETPLAYLISTFILEW : IPC_GETPLAYLISTFILE);
            if (base_address) {
                DWORD process_id;
                GetWindowThreadProcessId(hwnd, &process_id);
                HANDLE hwnd_winamp = OpenProcess(PROCESS_VM_READ, FALSE, process_id);
                if (hwnd_winamp) {
                    if (use_unicode) {
                        wchar_t file_name[MAX_PATH];
                        ReadProcessMemory(hwnd_winamp, reinterpret_cast<LPCVOID>(base_address),
                                          file_name, MAX_PATH, NULL);
                        CloseHandle(hwnd_winamp);
                        return file_name;
                    } else {
                        char file_name[MAX_PATH];
                        ReadProcessMemory(hwnd_winamp, reinterpret_cast<LPCVOID>(base_address),
                                          file_name, MAX_PATH, NULL);
                        CloseHandle(hwnd_winamp);
                        return ToUTF8(file_name);
                    }
                }
            }
        }
    }
    return L"";
}
开发者ID:Greathood,项目名称:taiga,代码行数:30,代码来源:mediaplayers.cpp

示例12: while

bool CLocalizeStrings::LoadXML(const CStdString &filename, CStdString &encoding, uint32_t offset /* = 0 */)
{
  TiXmlDocument xmlDoc;
  if (!xmlDoc.LoadFile(CSpecialProtocol::TranslatePathConvertCase(filename)))
  {
    CLog::Log(LOGDEBUG, "unable to load %s: %s at line %d", filename.c_str(), xmlDoc.ErrorDesc(), xmlDoc.ErrorRow());
    return false;
  }

  XMLUtils::GetEncoding(&xmlDoc, encoding);

  TiXmlElement* pRootElement = xmlDoc.RootElement();
  if (!pRootElement || pRootElement->NoChildren() ||
       pRootElement->ValueStr()!=CStdString("strings"))
  {
    CLog::Log(LOGERROR, "%s Doesn't contain <strings>", filename.c_str());
    return false;
  }

  const TiXmlElement *pChild = pRootElement->FirstChildElement("string");
  while (pChild)
  {
    // Load new style language file with id as attribute
    const char* attrId=pChild->Attribute("id");
    if (attrId && !pChild->NoChildren())
    {
      int id = atoi(attrId) + offset;
      if (m_strings.find(id) == m_strings.end())
        m_strings[id] = ToUTF8(encoding, pChild->FirstChild()->Value());
    }
    pChild = pChild->NextSiblingElement("string");
  }
  return true;
}
开发者ID:Ayu222,项目名称:android,代码行数:34,代码来源:LocalizeStrings.cpp

示例13: ToUTF8

/*---------------------------------------------------------------------------*/
wxString wxSQLBook::GetSQLStatementAt(long start, long& end)
{
    wxString Str, temp;
    bool first = true;
    long count = m_SQLEdit->GetLineCount();

    end = -1;

    for (long i = start; i < count; i++)
    {
        if (!first)
            Str += ("\n");
        else
            first = false;

        temp = m_SQLEdit->GetLine(i).Trim();
        if ((temp.Last() == (';')) && !m_SQLEdit->EndLineIsComment(i)) // Arrêt au point virgule de fin de commande
            // if (temp.IsEmpty())  // Arrêt à la première ligne vide
        {
            end = i;
            Str += temp;
            break;
        }
        Str += temp;
    }
    return ToUTF8(Str);
}
开发者ID:4silvertooth,项目名称:wxSqlitePlus,代码行数:28,代码来源:sqlbook.cpp

示例14: WriteStrLine

// we write str lines into the file
void WriteStrLine(std::string prefix, std::string linkedString, std::string encoding)
{
  linkedString = ToUTF8(encoding, linkedString);
  fprintf (pPOTFile, "%s", prefix.c_str());
  fprintf (pPOTFile, "\"%s\"\n", linkedString.c_str());
  return;
}
开发者ID:KB3NZQ,项目名称:xbmc-xml2po,代码行数:8,代码来源:xbmc-xml2po.cpp

示例15: GetLongPathNameW

SString SharedUtil::GetSystemLongPathName( const SString& strPath )
{
    wchar_t szBuffer[32000];
    szBuffer[0] = 0;
    GetLongPathNameW( FromUTF8( strPath ), szBuffer, NUMELMS( szBuffer ) - 1 );
    return ToUTF8( szBuffer );
}
开发者ID:Cazomino05,项目名称:Test1,代码行数:7,代码来源:SharedUtil.File.hpp


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