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


C++ icu::UnicodeString类代码示例

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


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

示例1: ConvertString

	void FStringConverter::ConvertString(const TCHAR* Source, const int32 SourceStartIndex, const int32 SourceLen, icu::UnicodeString& Destination, const bool ShouldNullTerminate)
	{
		if (SourceLen > 0)
		{
			UErrorCode ICUStatus = U_ZERO_ERROR;

			ucnv_reset(ICUConverter);

			// Get the internal buffer of the string, we're going to use it as scratch space
			const int32_t DestinationCapacityUChars = SourceLen * 2;
			UChar* InternalStringBuffer = Destination.getBuffer(DestinationCapacityUChars);

			// Perform the conversion into the string buffer
			const int32_t SourceSizeBytes = SourceLen * sizeof(TCHAR);
			const int32_t DestinationLength = ucnv_toUChars(ICUConverter, InternalStringBuffer, DestinationCapacityUChars, reinterpret_cast<const char*>(Source + SourceStartIndex), SourceSizeBytes, &ICUStatus);

			// Optionally null terminate the string
			if (ShouldNullTerminate)
			{
				InternalStringBuffer[DestinationLength] = 0;
			}

			// Size it back down to the correct size and release our lock on the string buffer
			Destination.releaseBuffer(DestinationLength);

			check(U_SUCCESS(ICUStatus));
		}
		else
		{
			Destination.remove();
		}
	}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:32,代码来源:ICUUtilities.cpp

示例2: uspoof_checkUnicodeString

U_CAPI int32_t U_EXPORT2
uspoof_checkUnicodeString(const USpoofChecker *sc,
                          const icu::UnicodeString &text, 
                          int32_t *position,
                          UErrorCode *status) {
    int32_t result = uspoof_check(sc, text.getBuffer(), text.length(), position, status);
    return result;
}
开发者ID:BrunoReX,项目名称:palemoon,代码行数:8,代码来源:uspoof.cpp

示例3: GetUnicodeStringLengthImpl

	int32 GetUnicodeStringLengthImpl(const TCHAR* Source, const int32 InSourceStartIndex, const int32 InSourceLength)
	{
		if (InSourceLength > 0)
		{
			const icu::UnicodeString TmpStr = ConvertString(Source, InSourceStartIndex, InSourceLength);
			return TmpStr.length();
		}
		return 0;
	}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:9,代码来源:ICUUtilities.cpp

示例4: WriteUnicodeUnitexFile

/**
 * Write an Unitex file content (to system filesystem or filespace)
 * it write from two buffer (prefix and suffix). This is useful for writing both header and footer (or BOM and text...)
 */
    UNITEX_FUNC int UNITEX_CALL WriteUnicodeUnitexFile(const char*filename, icu::UnicodeString const& uString)
    {
        UChar uBom = 0xfeff;

        const UChar * uBuffer = uString.getBuffer();
        int32_t uLength = uString.length();

        bool result = WriteUnitexFile(filename, &uBom, sizeof(UChar), uBuffer, uLength * sizeof(UChar)) == 0;

        return result;
    }
开发者ID:UnitexGramLab,项目名称:unitex-core,代码行数:15,代码来源:UnitexLibIO_ICU.cpp

示例5: uspoof_areConfusableUnicodeString

U_CAPI int32_t U_EXPORT2
uspoof_areConfusableUnicodeString(const USpoofChecker *sc,
                                  const icu::UnicodeString &s1,
                                  const icu::UnicodeString &s2,
                                  UErrorCode *status) {

    const UChar *u1  = s1.getBuffer();
    int32_t  length1 = s1.length();
    const UChar *u2  = s2.getBuffer();
    int32_t  length2 = s2.length();

    int32_t results  = uspoof_areConfusable(sc, u1, length1, u2, length2, status);
    return results;
}
开发者ID:BrunoReX,项目名称:palemoon,代码行数:14,代码来源:uspoof.cpp

示例6: ustring_from_char

bool ustring_from_char(icu::UnicodeString& ret,
                       const String& str,
                       UErrorCode &error) {
  int32_t capacity = str.size() + 1;
  UChar *utf16 = ret.getBuffer(capacity);
  int32_t utf16_len = 0;
  error = U_ZERO_ERROR;
  u_strFromUTF8WithSub(utf16, ret.getCapacity(), &utf16_len,
                       str.c_str(), str.size(),
                       U_SENTINEL /* no substitution */,
                       nullptr, &error);
  ret.releaseBuffer(utf16_len);
  if (U_FAILURE(error)) {
    ret.setToBogus();
    return false;
  }
  return true;
}
开发者ID:BiggDaddy,项目名称:hhvm,代码行数:18,代码来源:icu.cpp

示例7: semantic_error

// --------------------------------------------------------------------------
void
processor::on_start_tag_type (
 icu::UnicodeString const& type
)
// --------------------------------------------------------------------------
{
  element_info info;
  
  if (!m_character_data.isEmpty())
  {
    character_data(m_character_data);
    m_character_data.remove();
  }

  info.type = type;
  info.child_counter = 0;
  
  if (m_element_info.empty())
  {
    if (m_validating
     && !m_document_type.m_root_type.isEmpty()
     && type != m_document_type.m_root_type)
    {
      std::string msg;

      msg += "Root element type does not match the document type.\n";
      msg += "Document type name: ";
      m_document_type.m_root_type.toUTF8String(msg);
      msg += "\nRoot element type: ";
      type.toUTF8String(msg);

      throw semantic_error(msg);
    }

    info.xmlns[""] = uri();
    info.base = m_base_iri;
    info.space = false;
  }
  else
  {
    if (m_validating)
    {
      throw not_implemented("Element validity checking.");
    }

    ++m_element_info.top().child_counter;
    
    info.xmlns = m_element_info.top().xmlns;
    info.base = m_element_info.top().base;
    info.lang = m_element_info.top().lang;
    info.space = m_element_info.top().space;
  }

  m_element_info.push(info);
  m_sax_attrs.clear();
}
开发者ID:fumu-no-kagomeko,项目名称:libkueea-xml,代码行数:57,代码来源:processor.cpp

示例8: ustring_from_char

static bool ustring_from_char(icu::UnicodeString& ret,
                              const String& str,
                              UErrorCode &error) {
  error = U_ZERO_ERROR;
  ret = u16(str, error, U_SENTINEL);
  if (U_FAILURE(error)) {
    ret.setToBogus();
    return false;
  }
  return true;
}
开发者ID:Debug-Orz,项目名称:hhvm,代码行数:11,代码来源:ext_icu_timezone.cpp

示例9: printLine

static void
printLine(UChar32 start, UChar32 end, Status status, const icu::UnicodeString &mapping) {
    if(start==end) {
        printf("%04lX          ", (long)start);
    } else {
        printf("%04lX..%04lX    ", (long)start, (long)end);
    }
    printf("; %s", statusNames[status]);
    if(status==MAPPED || status==DEVIATION || !mapping.isEmpty()) {
        printf(" ;");
        const UChar *buffer=mapping.getBuffer();
        int32_t length=mapping.length();
        int32_t i=0;
        UChar32 c;
        while(i<length) {
            U16_NEXT(buffer, i, length, c);
            printf(" %04lX", (long)c);
        }
    }
    puts("");
}
开发者ID:icu-project,项目名称:icu-tools,代码行数:21,代码来源:genuts46.cpp

示例10: toIDNA2003

static int
toIDNA2003(const UStringPrepProfile *prep, UChar32 c, icu::UnicodeString &destString) {
    UChar src[2];
    int32_t srcLength=0;
    U16_APPEND_UNSAFE(src, srcLength, c);
    UChar *dest;
    int32_t destLength;
    dest=destString.getBuffer(32);
    if(dest==NULL) {
        return FALSE;
    }
    UErrorCode errorCode=U_ZERO_ERROR;
    destLength=usprep_prepare(prep, src, srcLength,
                              dest, destString.getCapacity(),
                              USPREP_DEFAULT, NULL, &errorCode);
    destString.releaseBuffer(destLength);
    if(errorCode==U_STRINGPREP_PROHIBITED_ERROR) {
        return -1;
    } else {
        // Returns FALSE=0 for U_STRINGPREP_UNASSIGNED_ERROR and processing errors,
        // TRUE=1 if c is valid or mapped.
        return U_SUCCESS(errorCode);
    }
}
开发者ID:icu-project,项目名称:icu-tools,代码行数:24,代码来源:genuts46.cpp

示例11: alignedNormalizeUnicodeString

void alignedNormalizeUnicodeString(icu::UnicodeString const& u, IcuNormalizer2Ptr normalizer,
                                   ITakeAlignedChars& out) {
    // TODO: test
    Position start = 0;
    int32 len = u.length(), pos;
    UErrorCode err = U_ZERO_ERROR;
    int nfcPrefixLen = normalizer->spanQuickCheckYes(u, err);
    assert(U_SUCCESS(err));
    assert(len >= 0 && nfcPrefixLen >= 0);
    TokenSpan span;
    span.first = 0;
    icu::StringCharacterIterator it(u);
    while ((pos = it.getIndex()) < nfcPrefixLen) {
        assert(it.hasNext());
        Unicode c = it.next32PostInc();
        span.second = span.first + 1;
        out.takeWithSpan(c, span);
        ++span.first;
    }
    icu::UnicodeString remainder(u.tempSubString(nfcPrefixLen)), normalized;
    CharsFromUnicodeStringImpl chars(remainder);  // TODO: docs say normalizeSecondAndAppend
    IcuNormalizeByChunks<CharsFromUnicodeStringImpl> norm(chars, normalizer);
    norm.takeAllWithSpan(out);
}
开发者ID:ryancotterell,项目名称:hyp,代码行数:24,代码来源:AlignedChars.cpp

示例12:

// --------------------------------------------------------------------------
icu::UnicodeString
processor::normalize_enum (
 icu::UnicodeString const& value
)
// --------------------------------------------------------------------------
{
  icu::UnicodeString normalized;
  int32_t pos;
  bool space_before = false;
  bool leading = true;

  for (pos=0; pos<value.length(); ++pos)
  {
    if (value[pos] == ' ')
    {
      space_before = true;
    }
    else
    {
      if (space_before)
      {
        if (leading)
        {
          leading = false;
        }
        else
        {
          normalized += ' ';
        }

        space_before = false;
      }

      normalized += value[pos];
    }
  }

  return normalized;
}
开发者ID:fumu-no-kagomeko,项目名称:libkueea-xml,代码行数:40,代码来源:processor.cpp

示例13: operator

	jobject operator()(icu::UnicodeString const& value) const {
		return env->NewString(value.getBuffer(), value.length());
	}
开发者ID:Daniel58,项目名称:mapnik-jni,代码行数:3,代码来源:class_featureset.cpp

示例14: end

 inline
 cxxopts::UnicodeStringIterator
 end(const icu::UnicodeString& s)
 {
   return cxxopts::UnicodeStringIterator(&s, s.length());
 }
开发者ID:Kitware,项目名称:kwiver,代码行数:6,代码来源:cxxopts.hpp

示例15: QString

QString
EnabledLocalesModel::unicodeStringToQString( const icu::UnicodeString& sourceStr )
{
    return QString( reinterpret_cast<const QChar*>( sourceStr.getBuffer() ),
                    sourceStr.length() );
}
开发者ID:KaOSx,项目名称:user-kcm,代码行数:6,代码来源:EnabledLocalesModel.cpp


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