这篇教程C++ utf16_to_utf8函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中utf16_to_utf8函数的典型用法代码示例。如果您正苦于以下问题:C++ utf16_to_utf8函数的具体用法?C++ utf16_to_utf8怎么用?C++ utf16_to_utf8使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了utf16_to_utf8函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: GetFileNamevoid CWndStyleEditor::OnBnClickedSelectPic(){ if(NULL == SQRGUIStyleManager::GetInst()->GetActiveStyle()) return; // TODO: Add your control notification handler code here CString FileName = GetFileName(true, L"GUI Texture (*.tex *.dds)|*.tex;*.dds||"); SQRGUIStyle* pStyle = SQRGUIStyleManager::GetInst()->GetActiveStyle(); CString CurPath = utf8_to_utf16(pStyle->GetTexturePath()).c_str(); CurPath.MakeLower(); wstring Str = FileName.GetBuffer(); wstring TexStr = Str.substr(Str.rfind(L"//") + 1, Str.size()); CString TexPath = Str.substr(0, Str.rfind(L"//") + 1).c_str(); if(m_pStyleStruct!=NULL && Str.size()>0 && m_pStyleStruct->m_TexString!=utf16_to_utf8(TexStr).c_str() && TexPath == CurPath ) { m_pStyleStruct->m_TexString = utf16_to_utf8(TexStr).c_str(); m_pStyleStruct->Release(); CGraphic::GetInst()->CreateTexture(L"", (SQRGUIStyleManager::GetInst()->GetActiveStyle()->GetTexturePath()+utf16_to_utf8(TexStr)).c_str(), &(m_pStyleStruct->pTexture) ); m_TextureEdit.SetWindowText(TexStr.c_str()); RefreshMaskList(); }}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:29,
示例2: TRACEvoid win32_windowed_app_setup_params::trace_dump() const { TRACE("hinstance : {:x}", (unsigned int)get_hinstance()); TRACE("window_class_name : {}", utf16_to_utf8(get_window_class_name())); TRACE("window_caption : {}", utf16_to_utf8(get_window_caption())); TRACE("min_window_size : {}", get_min_window_size()); TRACE("small_icon_id : {}", get_small_icon_id()); TRACE("large_icon_id : {}", get_large_icon_id()); TRACE("is_visible_by_default : {}", bool_to_string(get_is_visible_by_default()));}
开发者ID:jseward,项目名称:solar,代码行数:9,
示例3: utf16_to_utf8const char* CBaseScriptApp::GetXMLFilePath(const char* szRelaFilePath) const{ if ( !szRelaFilePath ) m_szXMLFilePath = utf16_to_utf8(m_pXMLPathMgr->GetFullPath(NULL)); else m_szXMLFilePath = utf16_to_utf8(m_pXMLPathMgr->GetFullPath(utf8_to_utf16(szRelaFilePath).c_str())); return m_szXMLFilePath.c_str();}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:9,
示例4: GenErr//------------------------------------------------------------------------------CPostEffectLoader::CPostEffectLoader( const string& fileName ){ // load xml file wstring path = CGraphic::GetInst()->GetShaderConfigPath(); path.append(utf8_to_utf16(fileName)); ipkgstream stream; if ( stream.open(PATH_ALIAS_SHD.c_str(), utf16_to_utf8(path).c_str()) != 0 ) GenErr( GraphicErr::GetErrTypeStr(ShaderInit_Err), "can't open " + utf16_to_utf8(path) ); pPostEffectCfg = new CXmlConfig( "PostProcess" , stream ); xmlConfig = pPostEffectCfg->GetRootNode();}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:13,
示例5: utf16_to_utf8_allocint utf16_to_utf8_alloc(void **d,short *s){ int len; char *d8; static char *funcname="utf16_to_utf8_alloc"; (*d)=NULL; len=utf16_to_utf8(NULL,s,-1); willus_mem_alloc_warn(d,len+1,funcname,10); d8=(char *)(*d); utf16_to_utf8(d8,s,len); return(len);}
开发者ID:JiajiaGuo,项目名称:libk2pdfopt,代码行数:14,
示例6: init_commandline_arguments_utf8void init_commandline_arguments_utf8(int *argc, char ***argv){ int i, nArgs; LPWSTR *szArglist; szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs); if(NULL == szArglist) { fprintf(stderr, "/nFATAL: CommandLineToArgvW failed/n/n"); exit(-1); } *argv = (char**) malloc(sizeof(char*) * nArgs); *argc = nArgs; if(NULL == *argv) { fprintf(stderr, "/nFATAL: Malloc failed/n/n"); exit(-1); } for(i = 0; i < nArgs; i++) { (*argv)[i] = utf16_to_utf8(szArglist[i]); if(NULL == (*argv)[i]) { fprintf(stderr, "/nFATAL: utf16_to_utf8 failed/n/n"); exit(-1); } } LocalFree(szArglist);}
开发者ID:gonzojive,项目名称:dcaenc,代码行数:34,
示例7: os_get_hostname/// Gets the hostname of the current machine.////// @param hostname Buffer to store the hostname./// @param size Size of `hostname`.void os_get_hostname(char *hostname, size_t size){#ifdef HAVE_SYS_UTSNAME_H struct utsname vutsname; if (uname(&vutsname) < 0) { *hostname = '/0'; } else { xstrlcpy(hostname, vutsname.nodename, size); }#elif defined(WIN32) wchar_t host_utf16[MAX_COMPUTERNAME_LENGTH + 1]; DWORD host_wsize = sizeof(host_utf16) / sizeof(host_utf16[0]); if (GetComputerNameW(host_utf16, &host_wsize) == 0) { *hostname = '/0'; DWORD err = GetLastError(); EMSG2("GetComputerNameW failed: %d", err); return; } host_utf16[host_wsize] = '/0'; char *host_utf8; int conversion_result = utf16_to_utf8(host_utf16, &host_utf8); if (conversion_result != 0) { EMSG2("utf16_to_utf8 failed: %d", conversion_result); return; } xstrlcpy(hostname, host_utf8, size); xfree(host_utf8);#else EMSG("os_get_hostname failed: missing uname()"); *hostname = '/0';#endif}
开发者ID:phodge,项目名称:neovim,代码行数:38,
示例8: swkbdMessageCallbackstatic void swkbdMessageCallback(void* user, NS_APPID sender, void* msg, size_t msgsize){ SwkbdExtra* extra = (SwkbdExtra*)user; SwkbdState* swkbd = (SwkbdState*)msg; if (sender != APPID_SOFTWARE_KEYBOARD || msgsize != sizeof(SwkbdState)) return; u16* text16 = (u16*)(swkbdSharedMem + swkbd->text_offset); ssize_t units = utf16_to_utf8(NULL, text16, 0); if (units < 0) svcBreak(USERBREAK_PANIC); // Shouldn't happen. char* text8 = (char*)malloc(units+1); if (!text8) svcBreak(USERBREAK_PANIC); // Shouldn't happen. swkbdConvertToUTF8(text8, text16, units); const char* retmsg = NULL; swkbd->callback_result = extra->callback(extra->callback_user, &retmsg, text8, units); if (swkbd->callback_result > SWKBD_CALLBACK_OK) swkbdConvertToUTF16(swkbd->callback_msg, retmsg, SWKBD_MAX_CALLBACK_MSG_LEN); else swkbd->callback_msg[0] = 0; free(text8); APT_SendParameter(envGetAptAppId(), sender, APTCMD_MESSAGE, swkbd, sizeof(*swkbd), 0);}
开发者ID:Caboosium,项目名称:ctrulib,代码行数:25,
示例9: SQR_CATCHvoid CRenderFont::DrawText( const RenderTextParam& param ){ if (wcslen(param.GetText())==0) return; this->realFont->SetAlignToPixel(m_bAlignToPixel); this->realFont->Resize(param.GetSize()); this->Begin();#ifdef CATCH_DRAWTEXT_EXCEPTION SQR_TRY { this->realFont->DrawText(param); } SQR_CATCH(exp) { exp.AppendMsg(" - realFont->DrawText(param) евакрЛЁё/n"); const wstring drawText = param.GetText(); const string u8drawText = utf16_to_utf8(drawText.c_str()); exp.AppendMsg(u8drawText.c_str()); GfkLogExp(exp); } SQR_TRY_END#else this->realFont->DrawText(param);#endif this->End();}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:28,
示例10: read_usecstatic int read_usec(sd_id128_t vendor, const char *name, usec_t *u) { _cleanup_free_ void *i = NULL; _cleanup_free_ char *j = NULL; size_t is; int r; uint64_t x; assert(name); assert(u); r = efi_get_variable(EFI_VENDOR_LOADER, name, NULL, &i, &is); if (r < 0) return r; j = utf16_to_utf8(i, is); if (!j) return -ENOMEM; r = safe_atou64(j, &x); if (r < 0) return r; *u = x; return 0;}
开发者ID:cee1,项目名称:systemd,代码行数:25,
示例11: efi_get_loader_device_part_uuidint efi_get_loader_device_part_uuid(sd_id128_t *u) { _cleanup_free_ void *s = NULL; _cleanup_free_ char *p = NULL; size_t ss; int r, parsed[16]; unsigned i; assert(u); r = efi_get_variable(EFI_VENDOR_LOADER, "LoaderDevicePartUUID", NULL, &s, &ss); if (r < 0) return r; p = utf16_to_utf8(s, ss); if (!p) return -ENOMEM; if (sscanf(p, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", &parsed[0], &parsed[1], &parsed[2], &parsed[3], &parsed[4], &parsed[5], &parsed[6], &parsed[7], &parsed[8], &parsed[9], &parsed[10], &parsed[11], &parsed[12], &parsed[13], &parsed[14], &parsed[15]) != 16) return -EIO; for (i = 0; i < ELEMENTSOF(parsed); i++) u->bytes[i] = parsed[i]; return 0;}
开发者ID:cee1,项目名称:systemd,代码行数:29,
示例12: OnBnClickedStyleOkvoid CWndStyleEditor::OnBnClickedStyleOk(){ // TODO: Add your control notification handler code here CString str; m_StylesList.GetWindowText(str); SQRGUIStyle* pStyle = SQRGUIStyleManager::GetInst()->ActiveStyle(utf16_to_utf8(str.GetBuffer()).c_str()); ( ( ::CButton* )GetDlgItem( IDC_ABUTTON ) ) ->SetCheck( 0 ) ; ( ( ::CButton* )GetDlgItem( IDC_ACHECKBUTTON ) )->SetCheck( 0 ) ; ( ( ::CButton* )GetDlgItem( IDC_ACOMBOBOX ) ) ->SetCheck( 0 ) ; ( ( ::CButton* )GetDlgItem( IDC_AEDIT ) ) ->SetCheck( 0 ) ; ( ( ::CButton* )GetDlgItem( IDC_ARICHTEXT ) ) ->SetCheck( 0 ) ; ( ( ::CButton* )GetDlgItem( IDC_APROGRESS ) ) ->SetCheck( 0 ) ; ( ( ::CButton* )GetDlgItem( IDC_ASCROLLBAR ) ) ->SetCheck( 0 ) ; ( ( ::CButton* )GetDlgItem( IDC_ASPIN ) ) ->SetCheck( 0 ) ; ( ( ::CButton* )GetDlgItem( IDC_ASTATIC ) ) ->SetCheck( 0 ) ; ( ( ::CButton* )GetDlgItem( IDC_ALISTCTRL ) ) ->SetCheck( 0 ) ; ( ( ::CButton* )GetDlgItem( IDC_ATREECTRL ) ) ->SetCheck( 0 ) ; ( ( ::CButton* )GetDlgItem( IDC_AWNDMOVE ) ) ->SetCheck( 0 ) ; ( ( ::CButton* )GetDlgItem( IDC_CLOCK ) ) ->SetCheck( 0 ) ; ( ( ::CButton* )GetDlgItem( IDC_CHART ) ) ->SetCheck( 0 ) ; ( ( ::CButton* )GetDlgItem( IDC_AICON2 ) ) ->SetCheck( 0 ) ; ( ( ::CButton* )GetDlgItem( IDC_CWnd ) ) ->SetCheck( 1 ) ; OnBnClickedCWnd(); RefreshMaskList();}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:25,
示例13: LoadCfgFilevoid CBaseScriptApp::ConfigSearchPath(){ const char DEFAULT_SEARCH_PATH_NODE[128] = "default"; // 加载搜索路径配置文件 CXmlConfig* pXmlDirectory = LoadCfgFile( "etc/common/Directory.xml", "directory" ); string setting_path = pXmlDirectory->Get<string>(DEFAULT_SEARCH_PATH_NODE, "setting_path"); string xml_path = pXmlDirectory->Get<string>(DEFAULT_SEARCH_PATH_NODE, "xml_path"); string gui_path = pXmlDirectory->Get<string>(DEFAULT_SEARCH_PATH_NODE, "gui_path"); string lang_path = pXmlDirectory->Get<string>(DEFAULT_SEARCH_PATH_NODE, "lang_path"); string res_path = pXmlDirectory->Get<string>(DEFAULT_SEARCH_PATH_NODE, "res_path"); AddLoadPath("cfg", setting_path, true); AddLoadPath("gui", gui_path, false); AddLoadPath("res", res_path, false); AddLoadPath("lan", lang_path, false); AddLoadPath("shd", utf16_to_utf8(m_pRootPathMgr->GetRootPath()).c_str(), false); // 创建各路径管理器 m_pCfgPathMgr = new CPathMgr( setting_path.c_str() ); m_pXMLPathMgr = new CPathMgr( xml_path.c_str() ); m_pGUIPathMgr = new CPathMgr( gui_path.c_str() ); m_pLangPathMgr = new CPathMgr( lang_path.c_str() ); m_pResPathMgr = new CPathMgr(); m_pResPathMgr->SetCurPath( utf8_to_utf16(res_path).c_str() ); SafeDelete(pXmlDirectory); }
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:28,
示例14: ComputeHash_FromTextbool ComputeHash_FromText(const int hashType, const TCHAR *const textData, TCHAR *const hashOut, const size_t hashOutSize){ const size_t hashSize = GetHashSize(hashType); if((hashSize == SIZE_MAX) || (hashSize >= (hashOutSize / 2))) { if(hashSize != SIZE_MAX) ERROR_MSG(T("Output buffer is too small to hold the hash value!")); return false; } hash_ctx ctx; if(!HashFunction_Init(hashType, &ctx)) { return false; }#ifdef UNICODE const char *const textUtf8 = utf16_to_utf8(textData); if(textUtf8 == NULL) { return false; } HashFunction_Update(&ctx, (BYTE*)textUtf8, strlen(textUtf8)); delete [] textUtf8;#else HashFunction_Update(&ctx, (BYTE*)textData, strlen(textData));#endif BYTE hashValue[128]; HashFunction_Final(&ctx, hashValue); ConvertHashToHex(hashSize, hashValue, hashOut); return true;};
开发者ID:EasyIME,项目名称:PIME,代码行数:32,
示例15: _vd3deNamestatic const char* _vd3deName(struct VDirEntry* vde) { struct VDirEntry3DS* vd3de = (struct VDirEntry3DS*) vde; if (!vd3de->utf8Name[0]) { utf16_to_utf8((uint8_t*) vd3de->utf8Name, vd3de->ent.name, sizeof(vd3de->utf8Name)); } return vd3de->utf8Name;}
开发者ID:nagitsu,项目名称:mgba,代码行数:7,
示例16: udf_error/* Strings, CS0 (UDF 2.1.1) */static char *_cs0_to_utf8(const uint8_t *cs0, size_t size){ size_t out_pos = 0; size_t out_size = size; size_t i; uint8_t *out = (uint8_t *)malloc(size); if (!out) { udf_error("out of memory/n"); return NULL; } switch (cs0[0]) { case 8: /*udf_trace("string in utf-8/n");*/ for (i = 1; i < size; i++) { utf16lo_to_utf8(out, out_pos, out_size, cs0[i]); } break; case 16: for (i = 1; i < size; i+=2) { uint16_t ch = cs0[i + 1] | (cs0[i] << 8); utf16_to_utf8(out, out_pos, out_size, ch); } break; default: udf_error("unregonized string encoding %u/n", cs0[0]); free(out); return NULL; } out[out_pos] = 0; return (char*)out;}
开发者ID:jshattoc,项目名称:mythtv,代码行数:35,
示例17: OnBnClickedStyleDelvoid CWndStyleEditor::OnBnClickedStyleDel(){ // TODO: Add your control notification handler code here CString str; m_StylesList.GetWindowText(str); SQRGUIStyleManager::GetInst()->DelStyle(utf16_to_utf8(str.GetBuffer()).c_str()); RefreshList();}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:8,
示例18: _wchdirvoid CBaseScriptApp::ChangeCurPathToRes(){#ifdef _WIN32 _wchdir(m_pResPathMgr->GetCurPath());#else chdir( utf16_to_utf8(m_pResPathMgr->GetCurPath()).c_str() );#endif}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:8,
示例19: wstr_to_filestatic Value wstr_to_file(RefStr *base_dir, const wchar_t *wp, int size){ int fname_len = utf16_to_utf8(NULL, wp, size); int basedir_last_sep = (base_dir->c[base_dir->size - 1] == SEP_C); int total_len = base_dir->size + (basedir_last_sep ? 0 : 1) + fname_len; RefStr *rs_name = fs->refstr_new_n(fs->cls_file, total_len); char *dst = rs_name->c; memcpy(dst, base_dir->c, base_dir->size); dst += base_dir->size; if (!basedir_last_sep) { *dst++ = SEP_C; } utf16_to_utf8(dst, wp, size); return vp_Value(rs_name);}
开发者ID:x768,项目名称:fox-lang,代码行数:17,
示例20: strings_to_strings //-----------------------------------------------------------------// inline strings strings_to_strings(const wstrings& src) noexcept { strings dst; for(const auto& ws : src) { auto tmp = utf16_to_utf8(ws); dst.push_back(tmp); } return dst; }
开发者ID:hirakuni45,项目名称:R8C,代码行数:9,
示例21: task_populate_files_compare_directory_entriesstatic int task_populate_files_compare_directory_entries(const void* e1, const void* e2) { FS_DirectoryEntry* ent1 = (FS_DirectoryEntry*) e1; FS_DirectoryEntry* ent2 = (FS_DirectoryEntry*) e2; if((ent1->attributes & FS_ATTRIBUTE_DIRECTORY) && !(ent2->attributes & FS_ATTRIBUTE_DIRECTORY)) { return -1; } else if(!(ent1->attributes & FS_ATTRIBUTE_DIRECTORY) && (ent2->attributes & FS_ATTRIBUTE_DIRECTORY)) { return 1; } else { char entryName1[0x213] = {'/0'}; utf16_to_utf8((uint8_t*) entryName1, ent1->name, sizeof(entryName1) - 1); char entryName2[0x213] = {'/0'}; utf16_to_utf8((uint8_t*) entryName2, ent2->name, sizeof(entryName2) - 1); return strcasecmp(entryName1, entryName2); }}
开发者ID:rychenga,项目名称:FBI,代码行数:18,
示例22: get_string_from_utf16static std::string get_string_from_utf16(const char16_t* input, int input_len) { ssize_t utf8_length = utf16_to_utf8_length(input, input_len); if (utf8_length <= 0) { return {}; } std::string utf8; utf8.resize(utf8_length); utf16_to_utf8(input, input_len, &*utf8.begin(), utf8_length + 1); return utf8;}
开发者ID:MoKee,项目名称:android_system_core,代码行数:10,
示例23: udsGetNodeInfoUsernameResult udsGetNodeInfoUsername(const udsNodeInfo *nodeinfo, char *username){ ssize_t units=0; size_t len = 10; units = utf16_to_utf8((uint8_t*)username, (uint16_t*)nodeinfo->username, len); if(units < 0 || units > len)return -2; return 0;}
开发者ID:Caboosium,项目名称:ctrulib,代码行数:10,
示例24: vcard_get_previewstatic GtkWidget *vcard_get_preview (EImport *ei, EImportTarget *target, EImportImporter *im){ GtkWidget *preview; GSList *contacts; gchar *contents; VCardEncoding encoding; EImportTargetURI *s = (EImportTargetURI *) target; gchar *filename; filename = g_filename_from_uri (s->uri_src, NULL, NULL); if (filename == NULL) { g_message (G_STRLOC ": Couldn't get filename from URI '%s'", s->uri_src); return NULL; } encoding = guess_vcard_encoding (filename); if (encoding == VCARD_ENCODING_NONE) { g_free (filename); return NULL; } if (!g_file_get_contents (filename, &contents, NULL, NULL)) { g_message (G_STRLOC ": Couldn't read file."); g_free (filename); return NULL; } g_free (filename); if (encoding == VCARD_ENCODING_UTF16) { gchar *tmp; gunichar2 *contents_utf16 = (gunichar2 *) contents; tmp = utf16_to_utf8 (contents_utf16); g_free (contents); contents = tmp; } else if (encoding == VCARD_ENCODING_LOCALE) { gchar *tmp; tmp = g_locale_to_utf8 (contents, -1, NULL, NULL, NULL); g_free (contents); contents = tmp; } contacts = eab_contact_list_from_string (contents); g_free (contents); preview = evolution_contact_importer_get_preview_widget (contacts); e_client_util_free_object_slist (contacts); return preview;}
开发者ID:jdapena,项目名称:evolution,代码行数:55,
示例25: test_utf16_to_utf8static void test_utf16_to_utf8(void) { char *a = NULL; const uint16_t utf16[] = { htole16('a'), htole16(0xd800), htole16('b'), htole16(0xdc00), htole16('c'), htole16(0xd801), htole16(0xdc37) }; const char utf8[] = { 'a', 'b', 'c', 0xf0, 0x90, 0x90, 0xb7, 0 }; a = utf16_to_utf8(utf16, 14); assert_se(a); assert_se(streq(a, utf8)); free(a);}
开发者ID:josephgbr,项目名称:systemd,代码行数:11,
示例26: utf16ToUtf8std::string utf16ToUtf8(const StringPiece16& utf16) { ssize_t utf8Length = utf16_to_utf8_length(utf16.data(), utf16.length()); if (utf8Length <= 0) { return {}; } std::string utf8; utf8.resize(utf8Length); utf16_to_utf8(utf16.data(), utf16.length(), &*utf8.begin()); return utf8;}
开发者ID:OchSept,项目名称:platform_frameworks_base,代码行数:11,
示例27: OnBnClickedStyleAddvoid CWndStyleEditor::OnBnClickedStyleAdd(){ // TODO: Add your control notification handler code here CString str; m_StylesList.GetWindowText(str); SQRGUIStyleManager::GetInst()->AddStyle(utf16_to_utf8(str.GetBuffer()).c_str()); CString path = L"..//gui//style//" + str; _wmkdir(path.GetBuffer()); RefreshList();}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:11,
注:本文中的utf16_to_utf8函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ utf8函数代码示例 C++ utarray_push_back函数代码示例 |