这篇教程C++ ucnv_open函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ucnv_open函数的典型用法代码示例。如果您正苦于以下问题:C++ ucnv_open函数的具体用法?C++ ucnv_open怎么用?C++ ucnv_open使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了ucnv_open函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: GKASSERTGKbool GKTextEncoding::Convert( GKbyte* target, GKint32& nTargetLen, const GKbyte* source, GKint32 nSourceLen ){ GKASSERT(target != NULL && source != NULL); UErrorCode ErrorCode = U_ZERO_ERROR; m_dstConverter = ucnv_open(m_dstCharset.Cstr(), &ErrorCode); if(U_FAILURE(ErrorCode)){ GKFPRINTF(stdout, "%s/n",u_errorName(ErrorCode)); ucnv_close(m_dstConverter); return false; } m_srcConverter = ucnv_open(m_srcCharset.Cstr(), &ErrorCode); if(U_FAILURE(ErrorCode)){ GKFPRINTF(stdout, "%s/n",u_errorName(ErrorCode)); ucnv_close(m_srcConverter); return false; } ucnv_convert(m_dstCharset.Cstr(), m_srcCharset.Cstr(), (char*)target, nTargetLen, (char*)source, nSourceLen,&ErrorCode); if(U_FAILURE(ErrorCode)){ GKFPRINTF(stdout, "%s/n",u_errorName(ErrorCode)); ucnv_close(m_dstConverter); ucnv_close(m_srcConverter); return false; } ucnv_close(m_dstConverter); ucnv_close(m_srcConverter); return true;}
开发者ID:GisKook,项目名称:Gis,代码行数:30,
示例2: mod_websocket_conv_initmod_websocket_conv_t *mod_websocket_conv_init(const char *locale) { mod_websocket_conv_t *cnv; UErrorCode err = U_ZERO_ERROR; if (!locale) { return NULL; } cnv = (mod_websocket_conv_t *)malloc(sizeof(mod_websocket_conv_t)); if (!cnv) { return NULL; } if (strcasecmp(MOD_WEBSOCKET_UTF8_STR, locale) == 0) { cnv->cli = NULL; cnv->srv = NULL; } else { cnv->cli = ucnv_open(MOD_WEBSOCKET_UTF8_STR, &err); if (U_FAILURE(err)) { free(cnv); return NULL; } cnv->srv = ucnv_open(locale, &err); if (U_FAILURE(err)) { ucnv_close(cnv->cli); free(cnv); return NULL; } } return cnv;}
开发者ID:Fomich,项目名称:mod_websocket,代码行数:30,
示例3: fprintfvoidXeTeXFontMgr_FC::initialize(){ if (FcInit() == FcFalse) { fprintf(stderr, "fontconfig initialization failed!/n"); exit(9); } if (gFreeTypeLibrary == 0 && FT_Init_FreeType(&gFreeTypeLibrary) != 0) { fprintf(stderr, "FreeType initialization failed!/n"); exit(9); } UErrorCode err = U_ZERO_ERROR; macRomanConv = ucnv_open("macintosh", &err); utf16beConv = ucnv_open("UTF16BE", &err); utf8Conv = ucnv_open("UTF8", &err); if (err != 0) { fprintf(stderr, "internal error; cannot read font names/n"); exit(3); } FcPattern* pat = FcNameParse((const FcChar8*)":outline=true"); FcObjectSet* os = FcObjectSetBuild(FC_FAMILY, FC_STYLE, FC_FILE, FC_INDEX, FC_FULLNAME, FC_WEIGHT, FC_WIDTH, FC_SLANT, NULL); allFonts = FcFontList(FcConfigGetCurrent(), pat, os); FcObjectSetDestroy(os); FcPatternDestroy(pat); cachedAll = false;}
开发者ID:luigiScarso,项目名称:mflua,代码行数:31,
示例4: ucnv_openUConverter *QIcuCodec::getConverter(QTextCodec::ConverterState *state) const{ UConverter *conv = 0; if (state) { if (!state->d) { // first time state->flags |= QTextCodec::FreeFunction; QTextCodecUnalignedPointer::encode(state->state_data, qIcuCodecStateFree); UErrorCode error = U_ZERO_ERROR; state->d = ucnv_open(m_name, &error); ucnv_setSubstChars(static_cast<UConverter *>(state->d), state->flags & QTextCodec::ConvertInvalidToNull ? "/0" : "?", 1, &error); if (U_FAILURE(error)) qDebug() << "getConverter(state) ucnv_open failed" << m_name << u_errorName(error); } conv = static_cast<UConverter *>(state->d); } if (!conv) { // stateless conversion UErrorCode error = U_ZERO_ERROR; conv = ucnv_open(m_name, &error); ucnv_setSubstChars(conv, "?", 1, &error); if (U_FAILURE(error)) qDebug() << "getConverter(no state) ucnv_open failed" << m_name << u_errorName(error); } return conv;}
开发者ID:3163504123,项目名称:phantomjs,代码行数:27,
示例5: initTxtint initTxt(struct doc_descriptor *desc) { UErrorCode err; char *encoding = NULL; int len, BOMlength = 0; char buf[BUFSIZE]; UChar outbuf[4*BUFSIZE]; lseek(desc->fd, 0, SEEK_SET); len = read(desc->fd, buf, BUFSIZE); /* detect BOM */ err = U_ZERO_ERROR; encoding = ucnv_detectUnicodeSignature(buf, BUFSIZE, &BOMlength, &err); if(encoding != NULL) { lseek(desc->fd, BOMlength, SEEK_SET); /* initialize converter to encoding */ err = U_ZERO_ERROR; desc->conv = ucnv_open(encoding, &err); if (U_FAILURE(err)) { fprintf(stderr, "unable to open ICU converter/n"); return ERR_ICU; } } else { /* initialize converter to UTF-8 */ err = U_ZERO_ERROR; desc->conv = ucnv_open("utf8", &err); if (U_FAILURE(err)) { fprintf(stderr, "unable to open ICU converter/n"); return ERR_ICU; } /* check the first 2048 bytes */ err = U_ZERO_ERROR; ucnv_setToUCallBack(desc->conv, UCNV_TO_U_CALLBACK_STOP, NULL, NULL, NULL, &err); if (U_FAILURE(err)) { fprintf(stderr, "error setToUCallback/n"); return ERR_ICU; } err = U_ZERO_ERROR; ucnv_toUChars(desc->conv, outbuf, 4 * BUFSIZE, buf, len, &err); if (U_FAILURE(err)) { fprintf(stderr, "Unknown encoding/n"); return ERR_ICU; } lseek(desc->fd, 0, SEEK_SET); } return OK;}
开发者ID:BackupTheBerlios,项目名称:libany2uni-svn,代码行数:52,
示例6: m_fromcharsetFilteredOutputStream_icu::charsetFilteredOutputStream_icu (const charset& source, const charset& dest, outputStream* os, const charsetConverterOptions& opts) : m_from(NULL), m_to(NULL), m_sourceCharset(source), m_destCharset(dest), m_stream(*os), m_options(opts){ UErrorCode err = U_ZERO_ERROR; m_from = ucnv_open(source.getName().c_str(), &err); if (!U_SUCCESS(err)) { throw exceptions::charset_conv_error ("Cannot initialize ICU converter for source charset '" + source.getName() + "' (error code: " + u_errorName(err) + "."); } m_to = ucnv_open(dest.getName().c_str(), &err); if (!U_SUCCESS(err)) { throw exceptions::charset_conv_error ("Cannot initialize ICU converter for destination charset '" + dest.getName() + "' (error code: " + u_errorName(err) + "."); } // Tell ICU what to do when encountering an illegal byte sequence if (m_options.silentlyReplaceInvalidSequences) { // Set replacement chars for when converting from Unicode to codepage icu::UnicodeString substString(m_options.invalidSequence.c_str()); ucnv_setSubstString(m_to, substString.getTerminatedBuffer(), -1, &err); if (U_FAILURE(err)) throw exceptions::charset_conv_error("[ICU] Error when setting substitution string."); } else { // Tell ICU top stop (and return an error) on illegal byte sequences ucnv_setToUCallBack (m_to, UCNV_TO_U_CALLBACK_STOP, UCNV_SUB_STOP_ON_ILLEGAL, NULL, NULL, &err); if (U_FAILURE(err)) throw exceptions::charset_conv_error("[ICU] Error when setting ToU callback."); ucnv_setFromUCallBack (m_to, UCNV_FROM_U_CALLBACK_STOP, UCNV_SUB_STOP_ON_ILLEGAL, NULL, NULL, &err); if (U_FAILURE(err)) throw exceptions::charset_conv_error("[ICU] Error when setting FromU callback."); }}
开发者ID:0xd34df00d,项目名称:vmime,代码行数:49,
示例7: ucnv_openchar *aescstrdup(const UChar* unichars,int32_t length){ char *newString,*targetLimit,*target; UConverterFromUCallback cb; const void *p; UErrorCode errorCode = U_ZERO_ERROR;#if U_CHARSET_FAMILY==U_EBCDIC_FAMILY# if U_PLATFORM == U_PF_OS390 static const char convName[] = "ibm-1047";# else static const char convName[] = "ibm-37";# endif#else static const char convName[] = "US-ASCII";#endif UConverter* conv = ucnv_open(convName, &errorCode); if(length==-1){ length = u_strlen( unichars); } newString = (char*)ctst_malloc ( sizeof(char) * 8 * (length +1)); target = newString; targetLimit = newString+sizeof(char) * 8 * (length +1); ucnv_setFromUCallBack(conv, UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_C, &cb, &p, &errorCode); ucnv_fromUnicode(conv,&target,targetLimit, &unichars, (UChar*)(unichars+length),NULL,TRUE,&errorCode); ucnv_close(conv); *target = '/0'; return newString;}
开发者ID:icu-project,项目名称:icu4c,代码行数:27,
示例8: convsample_50void convsample_50() { printf("/n/n==============================================/n" "Sample 50: C: ucnv_detectUnicodeSignature/n"); //! [ucnv_detectUnicodeSignature] UErrorCode err = U_ZERO_ERROR; UBool discardSignature = TRUE; /* set to TRUE to throw away the initial U+FEFF */ char input[] = { '/xEF','/xBB', '/xBF','/x41','/x42','/x43' }; int32_t signatureLength = 0; const char *encoding = ucnv_detectUnicodeSignature(input,sizeof(input),&signatureLength,&err); UConverter *conv = NULL; UChar output[100]; UChar *target = output, *out; const char *source = input; if(encoding!=NULL && U_SUCCESS(err)){ // should signature be discarded ? conv = ucnv_open(encoding, &err); // do the conversion ucnv_toUnicode(conv, &target, output + UPRV_LENGTHOF(output), &source, input + sizeof(input), NULL, TRUE, &err); out = output; if (discardSignature){ ++out; // ignore initial U+FEFF } while(out != target) { printf("%04x ", *out++); } puts(""); } //! [ucnv_detectUnicodeSignature] puts("");}
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:34,
示例9: CSICU_charset_initbool CSICU_charset_init(charset* cs, const ASCII* charSetName){ UErrorCode status = U_ZERO_ERROR; UConverter* conv = ucnv_open(charSetName, &status); if (U_SUCCESS(status)) { // charSetName comes from stack. Copy it. ASCII* p = new ASCII[strlen(charSetName) + 1]; cs->charset_name = p; strcpy(p, charSetName); cs->charset_version = CHARSET_VERSION_1; cs->charset_flags |= CHARSET_ASCII_BASED; cs->charset_min_bytes_per_char = ucnv_getMinCharSize(conv); cs->charset_max_bytes_per_char = ucnv_getMaxCharSize(conv); cs->charset_fn_destroy = charset_destroy; cs->charset_fn_well_formed = NULL; const UChar unicodeSpace = 32; BYTE* p2 = new BYTE[cs->charset_max_bytes_per_char]; cs->charset_space_character = p2; cs->charset_space_length = ucnv_fromUChars(conv, reinterpret_cast<char*>(p2), cs->charset_max_bytes_per_char, &unicodeSpace, 1, &status); fb_assert(U_SUCCESS(status)); ucnv_close(conv); CVICU_convert_init(cs); } return U_SUCCESS(status);}
开发者ID:AsylumCorp,项目名称:dsploit,代码行数:35,
示例10: _HZOpenU_CDECL_BEGINstatic void U_CALLCONV_HZOpen(UConverter *cnv, UConverterLoadArgs *pArgs, UErrorCode *errorCode){ UConverter *gbConverter; if(pArgs->onlyTestIsLoadable) { ucnv_canCreateConverter("GBK", errorCode); /* errorCode carries result */ return; } gbConverter = ucnv_open("GBK", errorCode); if(U_FAILURE(*errorCode)) { return; } cnv->toUnicodeStatus = 0; cnv->fromUnicodeStatus= 0; cnv->mode=0; cnv->fromUChar32=0x0000; cnv->extraInfo = uprv_calloc(1, sizeof(UConverterDataHZ)); if(cnv->extraInfo != NULL){ ((UConverterDataHZ*)cnv->extraInfo)->gbConverter = gbConverter; } else { ucnv_close(gbConverter); *errorCode = U_MEMORY_ALLOCATION_ERROR; return; }}
开发者ID:winlibs,项目名称:icu4c,代码行数:26,
示例11: ASSERTvoid TextCodecICU::createICUConverter() const{ ASSERT(!m_converterICU); UErrorCode err; m_needsGBKFallbacks = !strcmp(m_encodingName, "GBK"); UConverter*& cachedConverter = cachedConverterICU(); if (cachedConverter) { err = U_ZERO_ERROR; const char* cachedConverterName = ucnv_getName(cachedConverter, &err); if (U_SUCCESS(err) && !strcmp(m_canonicalConverterName, cachedConverterName)) { m_converterICU = cachedConverter; cachedConverter = 0; return; } } err = U_ZERO_ERROR; m_converterICU = ucnv_open(m_canonicalConverterName, &err); ASSERT(U_SUCCESS(err)); if (m_converterICU) ucnv_setFallback(m_converterICU, TRUE);}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:25,
示例12: ICUConverter FStringConverter::FStringConverter() : ICUConverter(nullptr) { UErrorCode ICUStatus = U_ZERO_ERROR; ICUConverter = ucnv_open(FPlatformString::GetEncodingName(), &ICUStatus); check(U_SUCCESS(ICUStatus)); }
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:7,
示例13: ppb_char_set_utf16_to_char_setchar *ppb_char_set_utf16_to_char_set(PP_Instance instance, const uint16_t *utf16, uint32_t utf16_len, const char *output_char_set, enum PP_CharSet_ConversionError on_error, uint32_t *output_length){ // each character could take up to 4 bytes in UTF-8; with additional zero-terminator byte const uint32_t output_buffer_length = (utf16_len + 1) * 4 + 1; char *output = ppb_memory_mem_alloc(output_buffer_length); if (!output) { trace_error("%s, can't allocate memory, %u bytes/n", __func__, output_buffer_length); goto err; } const char *charset = encoding_alias_get_canonical_name(output_char_set); const UChar subst = '?'; UErrorCode st = U_ZERO_ERROR; UConverter *u = ucnv_open(charset, &st); if (!U_SUCCESS(st)) { trace_error("%s, wrong charset %s/n", __func__, output_char_set); goto err; } switch (on_error) { default: case PP_CHARSET_CONVERSIONERROR_FAIL: st = U_ZERO_ERROR; ucnv_setFromUCallBack(u, UCNV_FROM_U_CALLBACK_STOP, NULL, NULL, NULL, &st); break; case PP_CHARSET_CONVERSIONERROR_SKIP: st = U_ZERO_ERROR; ucnv_setFromUCallBack(u, UCNV_FROM_U_CALLBACK_SKIP, NULL, NULL, NULL, &st); break; case PP_CHARSET_CONVERSIONERROR_SUBSTITUTE: st = U_ZERO_ERROR; ucnv_setFromUCallBack(u, UCNV_FROM_U_CALLBACK_SUBSTITUTE, NULL, NULL, NULL, &st); st = U_ZERO_ERROR; ucnv_setSubstString(u, &subst, 1, &st); break; } *output_length = ucnv_fromUChars(u, output, output_buffer_length, utf16, utf16_len, &st); if (st != U_BUFFER_OVERFLOW_ERROR && !U_SUCCESS(st)) goto err; ucnv_close(u); return output;err: *output_length = 0; ppb_memory_mem_free(output); if (u) ucnv_close(u); return NULL;}
开发者ID:Happy-Ferret,项目名称:freshplayerplugin,代码行数:60,
示例14: convsample_12UErrorCode convsample_12(){ printf("/n/n==============================================/n" "Sample 12: C: simple sjis -> unicode conversion/n"); // **************************** START SAMPLE ******************* char source[] = { 0x63, 0x61, 0x74, (char)0x94, 0x4C, (char)0x82, 0x6E, (char)0x82, 0x6A, 0x00 }; UChar target[100]; UErrorCode status = U_ZERO_ERROR; UConverter *conv; int32_t len; // set up the converter conv = ucnv_open("shift_jis", &status); assert(U_SUCCESS(status)); // convert to Unicode // Note: we can use strlen, we know it's an 8 bit null terminated codepage target[6] = 0xFDCA; len = ucnv_toUChars(conv, target, 100, source, strlen(source), &status); U_ASSERT(status); // close the converter ucnv_close(conv); // ***************************** END SAMPLE ******************** // Print it out printBytes("src", source, strlen(source) ); printf("/n"); printUChars("targ", target, len); return U_ZERO_ERROR;}
开发者ID:ACSOP,项目名称:android_external_icu4c,代码行数:35,
示例15: ucnv_open UConverter* ICUUnicodeSupport::_openConverter<1>(ConstStringHolder<1> _encoding) { UErrorCode errorCode = U_ZERO_ERROR; UConverter* cnv = ucnv_open( char_cast<const char*>( _encoding.c_str() ), &errorCode); CHECK_ICU_ERROR_CODE(errorCode); return cnv; }
开发者ID:raduetsya,项目名称:GothOgre,代码行数:7,
示例16: Write//------------------------------------------size_t CFS_Sqlite::WriteUTF8(const wchar* string, FSFILE *fp){ if (!string || !*string) return 0; // if not unicode#ifndef UNICODE return Write(string, 1, strlen(string), fp);#else unsigned int inputLen = wstrlen(string); unsigned char *target; target = new unsigned char[inputLen*4+1]; // make buffer long enough UErrorCode status = U_ZERO_ERROR; int32_t len; //// set up the converter UConverter *conv = ucnv_open("utf-8", &status); assertd(U_SUCCESS(status)!=0, "Failed to open utf-8 converter!"); //// convert len = ucnv_fromUChars(conv, (char*)target, inputLen*4, string, -1, &status); assertd(U_SUCCESS(status)!=0, "Failed to convert string to utf-8!"); //// write to file size_t wrlen = Write(target, 1, len, fp); //// close and clean delete[] target; ucnv_close(conv); return wrlen;#endif}
开发者ID:k3a,项目名称:Panther3D-2,代码行数:34,
示例17: mainextern intmain(int argc, const char *argv[]) { UErrorCode errorCode=U_ZERO_ERROR; // Note: Using a global variable for any object is not exactly thread-safe... // You can change this call to e.g. ucnv_open("UTF-8", &errorCode) if you pipe // the output to a file and look at it with a Unicode-capable editor. // This will currently affect only the printUString() function, see the code above. // printUnicodeString() could use this, too, by changing to an extract() overload // that takes a UConverter argument. cnv=ucnv_open(NULL, &errorCode); if(U_FAILURE(errorCode)) { fprintf(stderr, "error %s opening the default converter/n", u_errorName(errorCode)); return errorCode; } ucnv_setFromUCallBack(cnv, UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_C, NULL, NULL, &errorCode); if(U_FAILURE(errorCode)) { fprintf(stderr, "error %s setting the escape callback in the default converter/n", u_errorName(errorCode)); ucnv_close(cnv); return errorCode; } demo_utf_h_macros(); demo_C_Unicode_strings(); demoCaseMapInC(); demoCaseMapInCPlusPlus(); demoUnicodeStringStorage(); demoUnicodeStringInit(); ucnv_close(cnv); return 0;}
开发者ID:icu-project,项目名称:icu4c,代码行数:34,
示例18: GSStringOpenConverterstatic UConverter *GSStringOpenConverter (CFStringEncoding encoding, char lossByte){ const char *converterName; UConverter *cnv; UErrorCode err = U_ZERO_ERROR; converterName = CFStringICUConverterName (encoding); cnv = ucnv_open (converterName, &err); if (U_FAILURE (err)) cnv = NULL; if (lossByte) { /* FIXME: for some reason this is returning U_ILLEGAL_ARGUMENTS_ERROR */ ucnv_setSubstChars (cnv, &lossByte, 1, &err); } else { ucnv_setToUCallBack (cnv, UCNV_TO_U_CALLBACK_STOP, NULL, NULL, NULL, &err); ucnv_setFromUCallBack (cnv, UCNV_FROM_U_CALLBACK_STOP, NULL, NULL, NULL, &err); } return cnv;}
开发者ID:1053948334,项目名称:myos.frameworks,代码行数:28,
示例19: convsample_02UErrorCode convsample_02(){ printf("/n/n==============================================/n" "Sample 02: C: simple Unicode -> koi8-r conversion/n"); // **************************** START SAMPLE ******************* // "cat<cat>OK" UChar source[] = { 0x041C, 0x043E, 0x0441, 0x043A, 0x0432, 0x0430, 0x0021, 0x0000 }; char target[100]; UErrorCode status = U_ZERO_ERROR; UConverter *conv; int32_t len; // set up the converter conv = ucnv_open("koi8-r", &status); assert(U_SUCCESS(status)); // convert to koi8-r len = ucnv_fromUChars(conv, target, 100, source, -1, &status); assert(U_SUCCESS(status)); // close the converter ucnv_close(conv); // ***************************** END SAMPLE ******************** // Print it out printUChars("src", source); printf("/n"); printBytes("targ", target, len); return U_ZERO_ERROR;}
开发者ID:ACSOP,项目名称:android_external_icu4c,代码行数:35,
示例20: initPlugin/* params : desc : the document descriptor * return : an error code * * initializes the plugin by creating an xmlreader and * storing it in desc * This function also positions the meatreader at the beginning * of the metadata */int initPlugin(struct doc_descriptor *desc) { UErrorCode err; desc->myState = (struct ParserState *) malloc(sizeof(struct ParserState)); desc->fd = open(desc->filename, O_RDONLY); desc->parser = XML_ParserCreate(NULL); XML_SetUserData(desc->parser, desc->myState); XML_SetElementHandler(desc->parser, startElement, endElement); XML_SetCharacterDataHandler(desc->parser, characters); ((struct ParserState *)(desc->myState))->isTextContent = 0; ((struct ParserState *)(desc->myState))->suspended = 0; ((struct ParserState *)(desc->myState))->meta_suspended = 0; ((struct ParserState *)(desc->myState))->meta = NULL; ((struct ParserState *)(desc->myState))->pparser = &(desc->parser); ((struct ParserState *)(desc->myState))->size_adjusted = 0; /* initialize converter ( content is utf8 ) */ err = U_ZERO_ERROR; desc->conv = ucnv_open("utf8", &err); if (U_FAILURE(err)) { free(desc->myState); desc->myState = NULL; XML_ParserFree(desc->parser); desc->parser = NULL; close(desc->fd); fprintf(stderr, "unable to open ICU converter/n"); return ERR_ICU; } ((struct ParserState *)(desc->myState))->cnv = desc->conv; return OK;}
开发者ID:BackupTheBerlios,项目名称:libany2uni-svn,代码行数:41,
示例21: CodeSet_IsEncodingSupportedBoolCodeSet_IsEncodingSupported(const char *name) // IN{ UConverter *cv; UErrorCode uerr; /* * Fallback if necessary. */ if (dontUseIcu) { return CodeSetOld_IsEncodingSupported(name); } /* * Try to open the encoding. */ uerr = U_ZERO_ERROR; cv = ucnv_open(name, &uerr); if (cv) { ucnv_close(cv); return TRUE; } return FALSE;}
开发者ID:dontsueme,项目名称:vmware-view-open-client,代码行数:25,
示例22: u_getDefaultConverterU_CAPI UConverter* U_EXPORT2u_getDefaultConverter(UErrorCode *status){ UConverter *converter = NULL; if (gDefaultConverter != NULL) { umtx_lock(NULL); /* need to check to make sure it wasn't taken out from under us */ if (gDefaultConverter != NULL) { converter = gDefaultConverter; gDefaultConverter = NULL; } umtx_unlock(NULL); } /* if the cache was empty, create a converter */ if(converter == NULL) { converter = ucnv_open(NULL, status); if(U_FAILURE(*status)) { ucnv_close(converter); converter = NULL; } } return converter;}
开发者ID:Andproject,项目名称:platform_external_icu4c,代码行数:27,
示例23: ucnv_openU/*Extracts the UChar* to a char* and calls through createConverter */UConverter* ucnv_openU (const UChar * name, UErrorCode * err){ char asciiName[MAX_CONVERTER_NAME_LENGTH]; if (U_FAILURE (*err)) return NULL; if (name == NULL) return ucnv_open (NULL, err); if (u_strlen (name) > MAX_CONVERTER_NAME_LENGTH) { *err = U_ILLEGAL_ARGUMENT_ERROR; return NULL; } return ucnv_open (u_austrcpy (asciiName, name), err);}
开发者ID:brock7,项目名称:TianLong,代码行数:17,
示例24: ASSERTvoid TextCodecICU::createICUConverter() const{ ASSERT(!m_converterICU);#if defined(USING_SYSTEM_ICU) const char* name = m_encoding.name(); m_needsGBKFallbacks = name[0] == 'G' && name[1] == 'B' && name[2] == 'K' && !name[3];#endif UErrorCode err; UConverter*& cachedConverter = cachedConverterICU(); if (cachedConverter) { err = U_ZERO_ERROR; const char* cachedName = ucnv_getName(cachedConverter, &err); if (U_SUCCESS(err) && m_encoding == cachedName) { m_converterICU = cachedConverter; cachedConverter = 0; return; } } err = U_ZERO_ERROR; m_converterICU = ucnv_open(m_encoding.name(), &err);#if !LOG_DISABLED if (err == U_AMBIGUOUS_ALIAS_WARNING) WTF_LOG_ERROR("ICU ambiguous alias warning for encoding: %s", m_encoding.name());#endif if (m_converterICU) ucnv_setFallback(m_converterICU, TRUE);}
开发者ID:astojilj,项目名称:chromium-crosswalk,代码行数:31,
示例25: printMatch//------------------------------------------------------------------------------------------//// printMatch Called when a matching line has been located.// Print out the line from the file with the match, after// converting it back to the default code page.////------------------------------------------------------------------------------------------void printMatch() { char buf[2000]; UErrorCode status = U_ZERO_ERROR; // If we haven't already created a converter for output, do it now. if (outConverter == 0) { outConverter = ucnv_open(NULL, &status); if (U_FAILURE(status)) { fprintf(stderr, "ugrep: Error opening default converter: /"%s/"/n", u_errorName(status)); exit(-1); } }; // Convert the line to be printed back to the default 8 bit code page. // If the line is too long for our buffer, just truncate it. ucnv_fromUChars(outConverter, buf, // destination buffer for conversion sizeof(buf), // capacity of destination buffer &ucharBuf[lineStart], // Input to conversion lineEnd-lineStart, // number of UChars to convert &status); buf[sizeof(buf)-1] = 0; // Add null for use in case of too long lines. // The converter null-terminates its output unless // the buffer completely fills. if (displayFileName) { printf("%s:", fileName); } if (displayLineNum) { printf("%d:", lineNum); } printf("%s", buf);}
开发者ID:icu-project,项目名称:icu4c,代码行数:41,
示例26: CFStringEncodingStreamIDFromMaskCF_INLINE UConverter *__CFStringEncodingConverterCreateICUConverter(const char *icuName, uint32_t flags, bool toUnicode) { UConverter *converter; UErrorCode errorCode = U_ZERO_ERROR; uint8_t streamID = CFStringEncodingStreamIDFromMask(flags); if (0 != streamID) { // this is a part of streaming previously created __CFICUThreadData *data = __CFStringEncodingICUGetThreadData(); --streamID; // map to array index if ((streamID < data->_numSlots) && (NULL != data->_converters[streamID])) return data->_converters[streamID]; } converter = ucnv_open(icuName, &errorCode); if (NULL != converter) { char lossyByte = CFStringEncodingMaskToLossyByte(flags); if ((0 == lossyByte) && (0 != (flags & kCFStringEncodingAllowLossyConversion))) lossyByte = '?'; if (0 ==lossyByte) { if (toUnicode) { ucnv_setToUCallBack(converter, &UCNV_TO_U_CALLBACK_STOP, NULL, NULL, NULL, &errorCode); } else { ucnv_setFromUCallBack(converter, &UCNV_FROM_U_CALLBACK_STOP, NULL, NULL, NULL, &errorCode); } } else { ucnv_setSubstChars(converter, &lossyByte, 1, &errorCode); } } return converter;}
开发者ID:Gamecharger,项目名称:Foundation,代码行数:33,
示例27: ucnv_open_emojiU_STABLE UConverter* U_EXPORT2ucnv_open_emoji(const char *converterName, UErrorCode *err) { if (EmojiFont::IsAvailable()) { if (strcmp(converterName, "Shift_JIS") == 0) converterName = "docomo-emoji"; } return ucnv_open(converterName, err);}
开发者ID:Androtos,项目名称:toolchain_benchmark,代码行数:8,
示例28: make_uconvstd::unique_ptr<UConverter, UConverterDeleter> make_uconv(const std::string& encoding) { icu::ErrorCode ec{}; UConverter* conv_ptr = ucnv_open(encoding.c_str(), ec); if (!ec.isSuccess()) throw IcuUtilsException(TRACEMSG(std::string() + "Error creating converter for encoding: [" + encoding + "]," " error: [" + ec.errorName() + "]")); return std::unique_ptr<UConverter, UConverterDeleter>{conv_ptr, UConverterDeleter{}};}
开发者ID:staticlibs,项目名称:staticlib_icu,代码行数:8,
示例29: ucnv_openPackagestatic UConverter *my_ucnv_open(const char *cnv, UErrorCode *err){ if(cnv && cnv[0] == '@') { return ucnv_openPackage("testdata", cnv+1, err); } else { return ucnv_open(cnv, err); }}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:8,
示例30: ok_transcoder::transcoder (std::string const& encoding) : ok_(false), conv_(0){ UErrorCode err = U_ZERO_ERROR; conv_ = ucnv_open(encoding.c_str(),&err); if (U_SUCCESS(err)) ok_ = true; // TODO ??}
开发者ID:h4ck3rm1k3,项目名称:MapNickAutotools,代码行数:9,
注:本文中的ucnv_open函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ ucol_close函数代码示例 C++ ucnv_close函数代码示例 |