您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ toUTF8函数代码示例

51自学网 2021-06-03 08:53:40
  C++
这篇教程C++ toUTF8函数代码示例写得很实用,希望能帮到您。

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

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

示例1: cAudioSource

	IAudioSource* cAudioManager::createAudioSource(IAudioDecoder* decoder, const cAudioString& audioName, const cAudioString& dataSource)	{        if (!decoder)            return NULL;        		if(decoder->isValid())		{#if CAUDIO_EFX_ENABLED == 1			IAudioSource* audio = CAUDIO_NEW cAudioSource(decoder, AudioContext, ((cAudioEffects*)getEffects())->getEFXInterface());#else			IAudioSource* audio = CAUDIO_NEW cAudioSource(decoder, AudioContext);#endif			decoder->drop();			if(audio && audio->isValid())			{				if(!audioName.empty())					audioIndex[audioName] = audio;				audioSources.push_back(audio);						getLogger()->logInfo("AudioManager", "Audio Source (%s) created from Data Source %s.", toUTF8(audioName), toUTF8(dataSource));				return audio;			}			getLogger()->logError("AudioManager", "Failed to create Audio Source (%s): Error creating audio source.", toUTF8(audioName));			audio->drop();			return NULL;		}		getLogger()->logError("AudioManager", "Failed to create Audio Source (%s): Audio data could not be decoded by (.%s) decoder.",                              toUTF8(audioName), toUTF8(decoder->getType()));		decoder->drop();		return NULL;	}
开发者ID:Lavesson,项目名称:cAudio,代码行数:33,


示例2: fromUTF8

void FSAdapter::scan(const wstring& path){    wstring localPath = fromUTF8(m_dirPath) + path;    WIN32_FIND_DATAW fd;    HANDLE fh = FindFirstFileW((LPCWSTR)(localPath + L"*").c_str(), &fd);    if (fh == INVALID_HANDLE_VALUE)    {        Log::error() << "Cannot open directory " << toUTF8(localPath) << ": " << strerror(errno);        return;    }    do    {        if (!wcscmp(fd.cFileName, L".") || !wcscmp(fd.cFileName, L".."))        {            continue;        }        if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)            scan(path + fd.cFileName + L'//');        else        {            wstring fileName = path + fd.cFileName;            std::replace(fileName.begin(), fileName.end(), L'//', L'/');            std::wstring lcPath = fileName;            std::transform(fileName.begin(), fileName.end(), lcPath.begin(), ::towlower);            m_files[toUTF8(lcPath)] = toUTF8(fileName);        }    }    while (FindNextFileW(fh, &fd));}
开发者ID:GoodRon,项目名称:OpenSR,代码行数:30,


示例3: init

logtofile& logtofile::operator<<(wstring buf){	if(_bDebugLog != bDebugLog)		init();	log_mutex.lock();	log.open(toUTF8(path).c_str(), std::ios::app |std::ios::ate);	log<<toUTF8(buf);	log<<"/n";	log.close();	log_mutex.unlock();	return *this;}
开发者ID:Seldom,项目名称:miranda-ng,代码行数:12,


示例4: logit

void SFTP::handle_log_close(int handle, char *emsg){	if (handle_is_ok(handle, HANDLE_FILE)) {		logit("%s%sclose /"%s/" bytes read %llu written %llu",		    emsg == NULL ? "" : emsg, emsg == NULL ? "" : " ",		    toUTF8(handle_to_name(handle)).c_str (),		    (unsigned long long)handle_bytes_read(handle),		    (unsigned long long)handle_bytes_write(handle));	} else {		logit("%s%sclosedir /"%s/"",		    emsg == NULL ? "" : emsg, emsg == NULL ? "" : " ",		    toUTF8(handle_to_name(handle)).c_str ());	}}
开发者ID:lodyagin,项目名称:shiesh,代码行数:14,


示例5: HistoryLogFunc

void HistoryLogFunc(HANDLE hContact, std::string message){	if(gbHistoryLog)	{		if(hContact == INVALID_HANDLE_VALUE)			return;		std::string msg = message;		msg.append("/n");		msg.append("Protocol: ").append(GetContactProto(hContact)).append(" Contact: ");		msg.append(toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR))).append(" ID: ");		msg.append(toUTF8(GetContactUid(hContact,toUTF16(GetContactProto(hContact)))));		HistoryLog(NULL, (char*)msg.c_str(), EVENTTYPE_MESSAGE, DBEF_READ);	}}
开发者ID:MrtsComputers,项目名称:miranda-ng,代码行数:14,


示例6: toQString

QString Server::findIssue(const QString & text, int & issue_id) {		issue_id = -1; // Not found		QUrlQuery params;	params.addQueryItem("filters[text][operator]", "=");	params.addQueryItem("filters[text][value]", text);		QString url = "/arx/issues/find/format/rss?issues/project_key/arx&"	              + toQString(qUrlQueryToPostData(params));		http::Request request(toUTF8(m_serverPrefix + url));		boost::scoped_ptr<http::Response> response(get(request));		if(!response->ok()) {		return QString();	}		QXmlStreamReader xml(toQByteArray(response->data()));		// Using XPath would have probably been simpler, but it would	// add a dependency to QtXmlPatterns...	// Look for the first "/rss/channel/item/link" entry...	const QString XML_PATH[] = { "rss", "channel", "item", "link" };		size_t currentItem = 0;	QString issueLink;	while(!xml.atEnd() && !xml.hasError()) {				// Read next element		QXmlStreamReader::TokenType token = xml.readNext();				if(currentItem == size_t(boost::size(XML_PATH))) {			QString issue = xml.text().toString();			if(getIssueIdFromUrl(toUTF8(issue), issue_id)) {				return issue;			}			break;		}				// If token is StartElement, we'll see if we can read it.		if(token == QXmlStreamReader::StartElement && xml.name() == XML_PATH[currentItem]) {			currentItem++;		}			}		return QString();}
开发者ID:bsxf-47,项目名称:ArxLibertatis,代码行数:50,


示例7: notepad_save_file

int notepad_save_file(){	int i;	char file[256];	xmlDocPtr doc = NULL;                      // document pointer	xmlNodePtr root_node = NULL, node = NULL;  // node pointers	safe_snprintf (file, sizeof (file), "%snotes.xml", configdir);	doc = xmlNewDoc (BAD_CAST "1.0");	root_node = xmlNewNode (NULL, BAD_CAST "PAD");	xmlDocSetRootElement (doc, root_node);	for (i = 0; i < nr_notes; i++)	{		xmlChar* data;		char* subst_string = NULL;		// libxml2 expects all data in UTF-8 encoding.		xmlChar* name = toUTF8 (note_list[i].name, strlen (note_list[i].name));		substitute_char_with_string (note_list[i].text.data, &subst_string, '&', "&amp;");				data = toUTF8 (subst_string, strlen(subst_string));		node = xmlNewChild (root_node, NULL, BAD_CAST "NOTE", data);		xmlNewProp (node, BAD_CAST "NAME", name);		free (subst_string);		free (data);		free (name);	}	if (xmlSaveFormatFileEnc (file, doc, "UTF-8", 1) < 0)	{#ifndef WINDOWS		// error writing. try the data directory		safe_snprintf (file, sizeof (file), "%s/%s", datadir, "notes.xml");		if (xmlSaveFormatFileEnc(file, doc, "UTF-8", 1) < 0)		{			LOG_ERROR_OLD(cant_save_notes, file);		}#else		LOG_ERROR_OLD(cant_save_notes, file);#endif		return 0;	}	// Success!	return 1;}
开发者ID:xaphier,项目名称:Eternal-Lands,代码行数:48,


示例8: qUrlQueryToPostData

static std::string qUrlQueryToPostData(const QUrlQuery & query) {#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)	return toStdString(query.encodedQuery());#else	return toUTF8(query.query(QUrl::FullyEncoded));#endif}
开发者ID:bsxf-47,项目名称:ArxLibertatis,代码行数:7,


示例9: request

QString Server::createCrashReport(const QString & title, const QString & description,                                  const QString & reproSteps, int version_id,                                  int & issue_id) {		QUrlQuery params;	params.addQueryItem("project_id", "2");	params.addQueryItem("issuetype_id", "7");	params.addQueryItem("title", title);	params.addQueryItem("description", description);	params.addQueryItem("reproduction_steps", reproSteps);	params.addQueryItem("build_id", QString::number(version_id));	params.addQueryItem("component_id", "");	params.addQueryItem("category_id", "0");	params.addQueryItem("reproducability_id", "0");	params.addQueryItem("estimated_time", "");	params.addQueryItem("priority_id", "0");	params.addQueryItem("resolution_id", "0");	params.addQueryItem("severity_id", "0");		http::POSTRequest request(toUTF8(m_serverPrefix + "/arx/issues/new"));	request.setData(qUrlQueryToPostData(params));	request.setFollowRedirects(false);		boost::scoped_ptr<http::Response> response(post(request));		if(response->ok() && getIssueIdFromUrl(response->url(), issue_id)) {		return toQString(response->url());	}		return QString();}
开发者ID:bsxf-47,项目名称:ArxLibertatis,代码行数:31,


示例10: toUTF8

bool WString::empty() const{  if (literal())    return utf8_.empty();  else    return toUTF8().empty();}
开发者ID:traw,项目名称:WebWidgets,代码行数:7,


示例11: FormatMessageW

// the returned pointer is actually to the second character// if the first character is - then free, otherwise don'tstatic const char *initerr(const char *message, const WCHAR *label, DWORD value){	WCHAR *sysmsg;	BOOL hassysmsg;	WCHAR *wmessage;	WCHAR *wout;	char *out;	hassysmsg = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, value, 0, (LPWSTR) (&sysmsg), 0, NULL) != 0;	if (!hassysmsg)		sysmsg = L"";	wmessage = toUTF16(message + 1);	wout = debugstrf(L"-error initializing libui: %s; code %I32d (0x%08I32X) %s",		wmessage,		value, value,		sysmsg);	uiFree(wmessage);	if (hassysmsg)		LocalFree(sysmsg);		// ignore error	if (wout == NULL)			// debugstrf() failed; return message raw		return message + 1;	out = toUTF8(wout);	uiFree(wout);	return out + 1;}
开发者ID:binson001,项目名称:libui,代码行数:27,


示例12: toUTF16

static const char *initerr(const char *message, const WCHAR *label, DWORD value){    WCHAR *sysmsg;    BOOL hassysmsg;    WCHAR *beforele;    WCHAR *afterle;    int n;    WCHAR *wmessage;    WCHAR *wstr;    const char *str;    if (FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, value, 0, (LPWSTR) (&sysmsg), 0, NULL) != 0) {        hassysmsg = TRUE;        beforele = L" (";        afterle = L")";    } else {        hassysmsg = FALSE;        sysmsg = L"";        beforele = L"";        afterle = L"";    }    wmessage = toUTF16(message);    n = _scwprintf(initErrorFormat, initErrorArgs);    wstr = (WCHAR *) uiAlloc((n + 1) * sizeof (WCHAR), "WCHAR[]");    snwprintf(wstr, n + 1, initErrorFormat, initErrorArgs);    str = toUTF8(wstr);    uiFree(wstr);    if (hassysmsg)        if (LocalFree(sysmsg) != NULL)            logLastError("error freeing system message in loadLastError()");    uiFree(wmessage);    return str;}
开发者ID:mantyr,项目名称:libui,代码行数:33,


示例13: get_int

void SFTP::process_fstat(void){	Attrib a;	BY_HANDLE_FILE_INFORMATION st;	u_int32_t id;	int handle, status = SSH2_FX_FAILURE;	id = get_int();	handle = get_handle();	debug("request %u: fstat /"%s/" (handle %u)",	    id, toUTF8(handle_to_name(handle)).c_str (), handle);	const HANDLE fh = handle_to_fh(handle);  if (fh != INVALID_HANDLE_VALUE)   {		if (!::GetFileInformationByHandle (fh, &st))     {			status = errno_to_portable(::GetLastError ());		}     else     {			stat_to_attrib(&st, &a);			send_attrib(id, &a);			status = SSH2_FX_OK;		}	}	if (status != SSH2_FX_OK)		send_status(id, status);}
开发者ID:lodyagin,项目名称:shiesh,代码行数:28,


示例14: outputTags

void outputTags(FILE* output) {    lua_getglobal(state, "getTagsFromInfoTable");    lua_newtable(state);    int size = 0;    long lines = getSOSILinesLength();    for (int i = 0; i < lines; i++) {        char buffer[256];        char* line = toUTF8(getSOSILine(i), buffer, 256);        if (line != NULL) {            lua_pushinteger(state, ++size);            lua_pushstring(state, line);            lua_settable(state, -3);        }    }        lua_setglobal(state, "info");    lua_call(state, 0, 1);        lua_pushnil(state);    while (lua_next(state, 1) != 0) {        if (lua_type(state, -2) != LUA_TSTRING) {            fprintf(stderr, "Error in lua script: key must be string, got '%s'/n", lua_tostring(state, -2));            exit(1);        }        const char* key = lua_tostring(state, -2);        const char* value = lua_tostring(state, -1);        fprintf(output, "<tag k=/"%s/" v=/"%s/"/>", key, value);        lua_pop(state, 1);    }        lua_pop(state, 1);}
开发者ID:Gnonthgol,项目名称:sosi2osm,代码行数:33,


示例15: lock

    IAudioSource* cAudioManager::createFromMemory(const char* name, const char* data, size_t length, const char* extension)    {		if(!Initialized) return NULL;		cAudioMutexBasicLock lock(Mutex);		cAudioString audioName = fromUTF8(name);		cAudioString ext = fromUTF8(extension);		IAudioDecoderFactory* factory = getAudioDecoderFactory(toUTF8(ext));		if(!factory) {			getLogger()->logError("AudioManager", "Failed to create Audio Source (%s): Codec (.%s) is not supported.", toUTF8(audioName), toUTF8(ext));			return NULL;		}		cMemorySource* source = CAUDIO_NEW cMemorySource(data, length, true);		if(source && source->isValid())		{			IAudioDecoder* decoder = factory->CreateAudioDecoder(source);			source->drop();			IAudioSource* audio = createAudioSource(decoder, audioName, _CTEXT("cMemorySource"));			if(audio != NULL)				return audio;			if(source)				source->drop();		}		return NULL;    }
开发者ID:Lavesson,项目名称:cAudio,代码行数:29,


示例16: toUTF8

// toUTF8 returns the whole string in UTF-8.std::string toUTF8(TextWord *w) {	std::u32string s;	for (int i = 0; i < w->getLength(); i++) {		s += static_cast<char32_t>(*w->getChar(i));	}	return toUTF8(s);}
开发者ID:Cophy08,项目名称:pdf2msgpack,代码行数:8,


示例17: create

        static void create (MemoryBlock& block, const StringPairArray& values)        {            auto numNotes = values.getValue ("NumCueNotes", "0").getIntValue();            if (numNotes > 0)            {                MemoryOutputStream out (block, false);                out.writeShortBigEndian ((short) numNotes);                for (int i = 0; i < numNotes; ++i)                {                    auto prefix = "CueNote" + String (i);                    out.writeIntBigEndian (values.getValue (prefix + "TimeStamp", "0").getIntValue());                    out.writeShortBigEndian ((short) values.getValue (prefix + "Identifier", "0").getIntValue());                    auto comment = values.getValue (prefix + "Text", String());                    auto commentLength = jmin (comment.getNumBytesAsUTF8(), (size_t) 65534);                    out.writeShortBigEndian ((short) commentLength + 1);                    out.write (comment.toUTF8(), commentLength);                    out.writeByte (0);                    if ((out.getDataSize() & 1) != 0)                        out.writeByte (0);                }            }        }
开发者ID:Sentinel77,项目名称:dexed,代码行数:28,


示例18: CoCreateInstance

char *commonItemDialog(HWND parent, REFCLSID clsid, REFIID iid, FILEOPENDIALOGOPTIONS optsadd){	IFileDialog *d = NULL;	FILEOPENDIALOGOPTIONS opts;	IShellItem *result = NULL;	WCHAR *wname = NULL;	char *name = NULL;	HRESULT hr;	hr = CoCreateInstance(clsid,		NULL, CLSCTX_INPROC_SERVER,		iid, (LPVOID *) (&d));	if (hr != S_OK) {		logHRESULT(L"error creating common item dialog", hr);		// always return NULL on error		goto out;	}	hr = d->GetOptions(&opts);	if (hr != S_OK) {		logHRESULT(L"error getting current options", hr);		goto out;	}	opts |= optsadd;	// the other platforms don't check read-only; we won't either	opts &= ~FOS_NOREADONLYRETURN;	hr = d->SetOptions(opts);	if (hr != S_OK) {		logHRESULT(L"error setting options", hr);		goto out;	}	hr = d->Show(parent);	if (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED))		// cancelled; return NULL like we have ready		goto out;	if (hr != S_OK) {		logHRESULT(L"error showing dialog", hr);		goto out;	}	hr = d->GetResult(&result);	if (hr != S_OK) {		logHRESULT(L"error getting dialog result", hr);		goto out;	}	hr = result->GetDisplayName(SIGDN_FILESYSPATH, &wname);	if (hr != S_OK) {		logHRESULT(L"error getting filename", hr);		goto out;	}	name = toUTF8(wname);out:	if (wname != NULL)		CoTaskMemFree(wname);	if (result != NULL)		result->Release();	if (d != NULL)		d->Release();	return name;}
开发者ID:08opt,项目名称:libui,代码行数:59,


示例19: utf8

 SingleString StringUtils::toUTF8(const wchar_t* unicode, int32_t length) {     if (length == 0)         return "";     ByteArray utf8(ByteArray::newInstance(length * MAX_ENCODING_UTF8_SIZE));     int32_t result = toUTF8(unicode, length, utf8);     return SingleString((char*)utf8.get(), result); }
开发者ID:alesha1488,项目名称:LucenePlusPlus,代码行数:8,


示例20: windowText

char *uiWindowsWindowText(HWND hwnd){	WCHAR *wtext;	char *text;	wtext = windowText(hwnd);	text = toUTF8(wtext);	uiFree(wtext);	return text;}
开发者ID:Alcaro,项目名称:RetroArch,代码行数:10,


示例21: toUTF8

int32_t StringUtils::toUTF8(const wchar_t* unicode, int32_t length, const UTF8ResultPtr& utf8Result) {    if (length == 0) {        utf8Result->length = 0;    } else {        if (length * MAX_ENCODING_UTF8_SIZE > utf8Result->result.size()) {            utf8Result->result.resize(length * MAX_ENCODING_UTF8_SIZE);        }        utf8Result->length = toUTF8(unicode, length, utf8Result->result);    }    return utf8Result->length;}
开发者ID:304471720,项目名称:LucenePlusPlus,代码行数:11,


示例22: section

MwIniImporter::multistrmap MwIniImporter::loadIniFile(std::string filename) {    std::cout << "load ini file: " << filename << std::endl;    std::string section("");    MwIniImporter::multistrmap map;    boost::iostreams::stream<boost::iostreams::file_source>file(filename.c_str());    std::string line;    while (std::getline(file, line)) {        line = toUTF8(line);        // unify Unix-style and Windows file ending        if (!(line.empty()) && (line[line.length()-1]) == '/r') {            line = line.substr(0, line.length()-1);        }        if(line[0] == '[') {            int pos = line.find(']');            if(pos < 2) {                std::cout << "Warning: ini file wrongly formatted (" << line << "). Line ignored." << std::endl;                continue;            }            section = line.substr(1, line.find(']')-1);            continue;        }        int comment_pos = line.find(";");        if(comment_pos > 0) {            line = line.substr(0,comment_pos);        }        if(line.empty()) {            continue;        }        int pos = line.find("=");        if(pos < 1) {            continue;        }        std::string key(section + ":" + line.substr(0,pos));        std::string value(line.substr(pos+1));        multistrmap::iterator it;        if((it = map.find(key)) == map.end()) {            map.insert( std::make_pair (key, std::vector<std::string>() ) );        }        map[key].push_back(value);    }    return map;}
开发者ID:woolto,项目名称:openmw,代码行数:54,


示例23: toENC

/* internal (EUC/SJIS/UPTEX) to 'enc' code conversion */static long toENC(long kcode, int enc){    switch (enc) {    case ENC_UTF8: return toUTF8(kcode);    case ENC_JIS:  return toJIS(kcode);    case ENC_EUC:  return toEUC(kcode);    case ENC_SJIS: return toSJIS(kcode);    default:        fprintf(stderr, "toENC: unknown enc (%d)./n", enc);        return 0;    }}
开发者ID:clerkma,项目名称:ptex-ng,代码行数:13,


示例24: toUTF8

std::string toUTF8(const std::string& s){#ifndef WT_NO_STD_WSTRING  return toUTF8(widen(s));#else  // You may want to rewrite this for your system  std::string retval = s;  for(std::size_t i = 0; i < retval.size(); ++i)    if (retval[i] > 127) retval[i] = '?';  return s;#endif}
开发者ID:StevenFarley,项目名称:wt,代码行数:12,


示例25: writeToStream

bool CodeDocument::writeToStream (OutputStream& stream){    for (auto* l : lines)    {        auto temp = l->line; // use a copy to avoid bloating the memory footprint of the stored string.        const char* utf8 = temp.toUTF8();        if (! stream.write (utf8, strlen (utf8)))            return false;    }    return true;}
开发者ID:christophhart,项目名称:HISE,代码行数:13,



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


C++ toUnicode函数代码示例
C++ toSymbol函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。