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

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

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

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

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

示例1: UNUSED

void JSI_Lobby::LobbyBan(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), std::wstring nick, std::wstring reason){	if (!g_XmppClient)		return;	g_XmppClient->ban(utf8_from_wstring(nick), utf8_from_wstring(reason));}
开发者ID:Rektosauros,项目名称:0ad,代码行数:7,


示例2: rq

bool ScriptInterface::ParseJSON(const std::string& string_utf8, JS::MutableHandleValue out){	JSAutoRequest rq(m->m_cx);	std::wstring attrsW = wstring_from_utf8(string_utf8); 	utf16string string(attrsW.begin(), attrsW.end());	if (JS_ParseJSON(m->m_cx, reinterpret_cast<const jschar*>(string.c_str()), (u32)string.size(), out))		return true;	LOGERROR("JS_ParseJSON failed!");	if (!JS_IsExceptionPending(m->m_cx))		return false;	JS::RootedValue exc(m->m_cx);	if (!JS_GetPendingException(m->m_cx, &exc))		return false;	JS_ClearPendingException(m->m_cx);	// We expect an object of type SyntaxError	if (!exc.isObject())		return false;	JS::RootedValue rval(m->m_cx);	JS::RootedObject excObj(m->m_cx, &exc.toObject());	if (!JS_CallFunctionName(m->m_cx, excObj, "toString", JS::HandleValueArray::empty(), &rval))		return false;	std::wstring error;	ScriptInterface::FromJSVal(m->m_cx, rval, error);	LOGERROR("%s", utf8_from_wstring(error));	return false;}
开发者ID:Rektosauros,项目名称:0ad,代码行数:31,


示例3: GetJSONData

static std::vector<std::string> GetJSONData(const VfsPath& path){	VfsPaths pathnames;	Status ret = vfs::GetPathnames(g_VFS, path, L"*.json", pathnames);	if (ret != INFO::OK)	{		// Some error reading directory		wchar_t error[200];		LOGERROR("Error reading directory '%s': %s", path.string8(), utf8_from_wstring(StatusDescription(ret, error, ARRAY_SIZE(error))));		return std::vector<std::string>();	}	std::vector<std::string> data;	for (const VfsPath& p : pathnames)	{		// Load JSON file		CVFSFile file;		PSRETURN ret = file.Load(g_VFS, p);		if (ret != PSRETURN_OK)		{			LOGERROR("GetJSONData: Failed to load file '%s': %s", p.string8(), GetErrorString(ret));			continue;		}		data.push_back(file.DecodeUTF8()); // assume it's UTF-8	}	return data;}
开发者ID:JoshuaBelden,项目名称:0ad,代码行数:29,


示例4: CopyMirageSubset

void CTemplateLoader::CopyMirageSubset(CParamNode& out, const CParamNode& in){	// Currently used for mirage entities replacing real ones in fog-of-war	std::set<std::string> permittedComponentTypes;	permittedComponentTypes.insert("Footprint");	permittedComponentTypes.insert("Minimap");	permittedComponentTypes.insert("Ownership");	permittedComponentTypes.insert("OverlayRenderer");	permittedComponentTypes.insert("Position");	permittedComponentTypes.insert("Selectable");	permittedComponentTypes.insert("StatusBars");	permittedComponentTypes.insert("Visibility");	permittedComponentTypes.insert("VisualActor");	CParamNode::LoadXMLString(out, "<Entity/>");	out.CopyFilteredChildrenOfChild(in, "Entity", permittedComponentTypes);	// Select a subset of identity data. We don't want to have, for example, a CC mirage	// that has also the CC class and then prevents construction of other CCs	std::set<std::string> identitySubset;	identitySubset.insert("Civ");	identitySubset.insert("GenericName");	identitySubset.insert("SpecificName");	identitySubset.insert("Tooltip");	identitySubset.insert("History");	identitySubset.insert("Icon");	CParamNode identity;	CParamNode::LoadXMLString(identity, "<Identity/>");	identity.CopyFilteredChildrenOfChild(in.GetChild("Entity"), "Identity", identitySubset);	CParamNode::LoadXMLString(out, ("<Entity>"+utf8_from_wstring(identity.ToXML())+"</Entity>").c_str());	// Set the entity as mirage entity	CParamNode::LoadXMLString(out, "<Entity><Mirage/></Entity>");}
开发者ID:Rektosauros,项目名称:0ad,代码行数:35,


示例5: LOGERROR

void CTemplateLoader::ConstructTemplateActor(const std::string& actorName, CParamNode& out){	// Load the base actor template if necessary	const char* templateName = "special/actor";	if (!LoadTemplateFile(templateName, 0))	{		LOGERROR("Failed to load entity template '%s'", templateName);		return;	}	// Copy the actor template	out = m_TemplateFileData[templateName];	// Initialise the actor's name and make it an Atlas selectable entity.	std::wstring actorNameW = wstring_from_utf8(actorName);	std::string name = utf8_from_wstring(CParamNode::EscapeXMLString(actorNameW));	std::string xml = "<Entity>"	                      "<VisualActor><Actor>" + name + "</Actor><ActorOnly/></VisualActor>"						  // arbitrary-sized Footprint definition to make actors' selection outlines show up in Atlas						  "<Footprint><Circle radius='2.0'/><Height>1.0</Height></Footprint>"	                      "<Selectable>"	                          "<EditorOnly/>"	                          "<Overlay><Texture><MainTexture>actor.png</MainTexture><MainTextureMask>actor_mask.png</MainTextureMask></Texture></Overlay>"	                      "</Selectable>"	                  "</Entity>";	CParamNode::LoadXMLString(out, xml.c_str(), actorNameW.c_str());}
开发者ID:Rektosauros,项目名称:0ad,代码行数:28,


示例6: utf8_from_wstring

void CNetTurnManager::DisplayOOSError(u32 turn, const std::string& hash, const std::string& expectedHash, bool isReplay, OsPath* path = NULL){	m_HasSyncError = true;	std::stringstream msg;	msg << "Out of sync on turn " << turn << ": expected hash " << expectedHash << "/n";	if (expectedHash != hash || m_CurrentTurn != turn)		msg << "/nCurrent state: turn " << m_CurrentTurn << ", hash " << hash << "/n/n";	if (isReplay)		msg << "/nThe current game state is different from the original game state./n/n";	else	{		if (expectedHash == hash)			msg << "Your game state is identical to the hosts game state./n/n";		else			msg << "Your game state is different from the hosts game state./n/n";	}	if (path)		msg << "Dumping current state to " << utf8_from_wstring(OsPath(*path).string());	LOGERROR("%s", msg.str());	if (g_GUI)		g_GUI->DisplayMessageBox(600, 350, L"Sync error", wstring_from_utf8(msg.str()));}
开发者ID:righnatios,项目名称:0ad,代码行数:28,


示例7: Locale

void L10n::LoadListOfAvailableLocales(){	for (Locale* const& locale : availableLocales)		delete locale;	availableLocales.clear();	Locale* defaultLocale = new Locale(Locale::getUS());	availableLocales.push_back(defaultLocale); // Always available.	VfsPaths filenames;	if (vfs::GetPathnames(g_VFS, L"l10n/", L"*.po", filenames) < 0)		return;	for (const VfsPath& path : filenames)	{		// Note: PO files follow this naming convention: “l10n/<locale code>.<mod name>.po”. For example: “l10n/gl.public.po”.		std::string filename = utf8_from_wstring(path.string()).substr(strlen("l10n/"));		size_t lengthToFirstDot = filename.find('.');		std::string localeCode = filename.substr(0, lengthToFirstDot);		Locale* locale = new Locale(Locale::createCanonical(localeCode.c_str()));		auto it = std::find_if(availableLocales.begin(), availableLocales.end(), [&locale](Locale* const& l) {			return *locale == *l;		});		if (it != availableLocales.end())		{			delete locale;			continue;		}		availableLocales.push_back(locale);	}}
开发者ID:Rektosauros,项目名称:0ad,代码行数:33,


示例8: sizeof

BOOL CALLBACK sdl_monitor_info::monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data){	osd_monitor_info ***tailptr = (osd_monitor_info ***)data;	osd_monitor_info *monitor;	MONITORINFOEX info;	BOOL result;	// get the monitor info	info.cbSize = sizeof(info);	result = GetMonitorInfo(handle, (LPMONITORINFO)&info);	assert(result);	(void)result; // to silence gcc 4.6	// guess the aspect ratio assuming square pixels	float aspect = (float)(info.rcMonitor.right - info.rcMonitor.left) / (float)(info.rcMonitor.bottom - info.rcMonitor.top);	// allocate a new monitor info	char *temp = utf8_from_wstring(info.szDevice);	// copy in the data	monitor = global_alloc(sdl_monitor_info((UINT64) handle, temp, aspect));	osd_free(temp);	// hook us into the list	**tailptr = monitor;	*tailptr = &monitor->m_next;	// enumerate all the available monitors so to list their names in verbose mode	return TRUE;}
开发者ID:gregdickhudl,项目名称:mame,代码行数:29,


示例9: UNUSED

// Return a translated version of the items in the specified array.std::vector<std::wstring> JSI_L10n::TranslateArray(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::vector<std::wstring>& sourceArray){	std::vector<std::wstring> translatedArray;	for (const std::wstring& elem : sourceArray)		translatedArray.push_back(wstring_from_utf8(g_L10n.Translate(utf8_from_wstring(elem))));	return translatedArray;}
开发者ID:krichter722,项目名称:0ad,代码行数:9,


示例10: callback

	static bool callback(const jschar* buf, u32 len, void* data)	{		utf16string str(buf, buf+len);		std::wstring strw(str.begin(), str.end());		Status err; // ignore Unicode errors		static_cast<Stringifier*>(data)->stream << utf8_from_wstring(strw, &err);		return true;	}
开发者ID:Rektosauros,项目名称:0ad,代码行数:9,


示例11: sys_clipboard_set

Status sys_clipboard_set(const wchar_t* text){	Status ret = INFO::OK;	std::string str = utf8_from_wstring(text);	bool ok = osx_SendStringToPasteboard(str);	if (!ok)		ret = ERR::FAIL;	return ret;}
开发者ID:righnatios,项目名称:0ad,代码行数:10,


示例12: TIMER_ACCRUE

bool RelaxNGValidator::ValidateEncoded(const std::wstring& filename, const std::string& document) const{	TIMER_ACCRUE(xml_validation);	if (!m_Schema)	{		LOGERROR("RelaxNGValidator: No grammar loaded");		return false;	}	xmlDocPtr doc = xmlReadMemory(document.c_str(), (int)document.size(), utf8_from_wstring(filename).c_str(), NULL, XML_PARSE_NONET);	if (doc == NULL)	{		LOGERROR("RelaxNGValidator: Failed to parse document '%s'", utf8_from_wstring(filename).c_str());		return false;	}	bool ret = ValidateEncoded(doc);	xmlFreeDoc(doc);	return ret;}
开发者ID:righnatios,项目名称:0ad,代码行数:21,


示例13: file

void CGUI::Xeromyces_ReadScript(XMBElement Element, CXeromyces* pFile, boost::unordered_set<VfsPath>& Paths){	// Check for a 'file' parameter	CStrW file(Element.GetAttributes().GetNamedItem(pFile->GetAttributeID("file")).FromUTF8());	// If there is a file specified, open and execute it	if (!file.empty())	{		Paths.insert(file);		try		{			m_ScriptInterface->LoadGlobalScriptFile(file);		}		catch (PSERROR_Scripting& e)		{			LOGERROR("GUI: Error executing script %s: %s", utf8_from_wstring(file), e.what());		}	}	// If it has a directory attribute, read all JS files in that directory	CStrW directory(Element.GetAttributes().GetNamedItem(pFile->GetAttributeID("directory")).FromUTF8());	if (!directory.empty())	{		VfsPaths pathnames;		vfs::GetPathnames(g_VFS, directory, L"*.js", pathnames);		for (const VfsPath& path : pathnames)		{			// Only load new files (so when the insert succeeds)			if (Paths.insert(path).second)				try				{					m_ScriptInterface->LoadGlobalScriptFile(path);				}				catch (PSERROR_Scripting& e)				{					LOGERROR("GUI: Error executing script %s: %s", path.string8(), e.what());				}		}	}	// Execute inline scripts	try	{		CStr code(Element.GetText());		if (!code.empty())			m_ScriptInterface->LoadGlobalScript(L"Some XML file", code.FromUTF8());	}	catch (PSERROR_Scripting& e)	{		LOGERROR("GUI: Error executing inline script: %s", e.what());	}}
开发者ID:2asoft,项目名称:0ad,代码行数:52,


示例14: h_data_tag_type

// get HDATA for the given handle.// also verifies the type.// used by most functions accessing handle data.static Status h_data_tag_type(const Handle h, const H_Type type, HDATA*& hd){	RETURN_STATUS_IF_ERR(h_data_tag(h, hd));	// h_alloc makes sure type isn't 0, so no need to check that here.	if(hd->type != type)	{		debug_printf("h_mgr: expected type %s, got %s/n", utf8_from_wstring(hd->type->name).c_str(), utf8_from_wstring(type->name).c_str());		WARN_RETURN(ERR::H_TYPE_MISMATCH);	}	return INFO::OK;}
开发者ID:righnatios,项目名称:0ad,代码行数:16,


示例15: LOGMESSAGE

Status CGUIManager::ReloadChangedFile(const VfsPath& path){	for (PageStackType::iterator it = m_PageStack.begin(); it != m_PageStack.end(); ++it)	{		if (it->inputs.count(path))		{			LOGMESSAGE("GUI file '%s' changed - reloading page '%s'", path.string8(), utf8_from_wstring(it->name));			LoadPage(*it);			// TODO: this can crash if LoadPage runs an init script which modifies the page stack and breaks our iterators		}	}	return INFO::OK;}
开发者ID:righnatios,项目名称:0ad,代码行数:14,



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


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