예제 #1
0
void strings_test() {
	ustr("hello");
	ustr("world");
	ustr("world");
	data *d;
	RB_FOREACH(d, tree, &head) puts(d->s);
}
예제 #2
0
inline FTPoint FTTextureFont::RenderI(const T* string, const int len,
                                      FTPoint position, FTPoint spacing)
{
    if (!FTTextureFont::custom_shader) {
        Render::set_effect(Render::FONT);
    }
    // for multibyte - we can't rely on sizeof(T) == character
    FTUnicodeStringItr<T> ustr(string);

    for(int i = 0; (len < 0 && *ustr) || (len >= 0 && i < len); i++) {
        unsigned int thisChar = *ustr++;
        unsigned int nextChar = *ustr;

        if (CheckGlyph(thisChar)) {
            position += glyphList->Render(thisChar, nextChar,
                                          position);
        }

        if (nextChar) {
            position += spacing;
        }
    }

    if (!FTTextureFont::custom_shader) {
        Render::disable_effect();
    }

    return position;
}
예제 #3
0
inline FTPoint FTFontImpl::RenderI(const T* string, const int len,
                                   FTPoint position, FTPoint spacing,
                                   int renderMode)
{
    // for multibyte - we can't rely on sizeof(T) == character
    FTUnicodeStringItr<T> ustr(string);

    for(int i = 0; (len < 0 && *ustr) || (len >= 0 && i < len); i++)
    {
        unsigned int thisChar = *ustr++;
        unsigned int nextChar = *ustr;

        if(CheckGlyph(thisChar))
        {
            position += glyphList->Render(thisChar, nextChar,
                                          position, renderMode);
        }

        if(nextChar)
        {
            position += spacing;
        }
    }

    return position;
}
예제 #4
0
std::string std_string_from_jstring(JNIEnv *env, jstring jstr) {
    std::string str;

    if (jstr == nullptr) {
        if (env->ThrowNew(nullPointerExceptionClass, "String cannot be null.") < 0) {
            env->ExceptionDescribe();
            return str;
        }

        return str;
    }

    jsize len = env->GetStringLength(jstr);
    if (len < 0) {
        env->ExceptionDescribe();
        return str;
    }

    const jchar *chars = env->GetStringChars(jstr, nullptr);
    if (chars == nullptr) {
        env->ExceptionDescribe();
        return str;
    }

    std::u16string ustr(reinterpret_cast<const char16_t *>(chars), len);
    env->ReleaseStringChars(jstr, chars);
    chars = nullptr;
    str = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(ustr);
    return str;
}
예제 #5
0
Messages::Messages(GuiWidgets* _gw) : gw(*_gw)
{
  messages.addAttr(UOrient::vertical + UFont::small + utop());
  messages.add(uhbox(UFont::bold + UColor::orange + "Have fun with VREng ;-)"));
  history.push_back(ustr(""));
  history_pos = 0;
}
std::string pf_Frag_Text::toString() const
{
    PT_BufIndex startidx = getBufIndex();
    const UT_UCSChar* ucsstart = m_pPieceTable->getPointer( startidx );
	UT_UTF8String ustr( ucsstart, getLength() );
    return ustr.utf8_str();
}
예제 #7
0
파일: test_emul.cpp 프로젝트: OPSF/uClinux
void test_mbs(void) {
  wchar_t wstr1[256] = {
                         L'e',
                         0xE8, // latin small letter e with grave
                         0xE9, // latin small letter e with acute
                         L'a',
                         0xE0, // latin small letter a with grave
                         0x20AC, // euro sign
                         L'b',
                         0 };
  wchar_t wstr2[256];
  char    astr[256];
  extern int global_use_utf16_conversion;

  global_use_utf16_conversion = 1;

  size_t len1 = wcslen(wstr1);

  printf("wstr1 - %d - '%ls'\n",(int)len1,wstr1);

  size_t len0 = wcstombs(astr,wstr1,sizeof(astr));
  printf("astr - %d - '%s'\n",(int)len0,astr);

  size_t len2 = mbstowcs(wstr2,astr,sizeof(wstr2)/sizeof(*wstr2));
  printf("wstr - %d - '%ls'\n",(int)len2,wstr2);

  if (wcscmp(wstr1,wstr2) != 0) {
    printf("ERROR during conversions wcs -> mbs -> wcs\n");
    exit(EXIT_FAILURE);
  }

  char *ptr = astr;
  size_t len = 0;
  while (*ptr) {
    ptr = CharNextA(ptr);
    len += 1;
  }
  if (len != len1) {
    printf("ERROR CharNextA : len=%d, len1=%d\n",(int)len,(int)len1);
    exit(EXIT_FAILURE);
  }

  UString ustr(wstr1);
  assert(ustr.Length() == (int)len1);

  AString  ansistr(astr);
  assert(ansistr.Length() == (int)len0);

  ansistr = UnicodeStringToMultiByte(ustr);
  assert(ansistr.Length() == (int)len0);

  assert(strcmp(ansistr,astr) == 0);
  assert(wcscmp(ustr,wstr1) == 0);

  UString ustr2 = MultiByteToUnicodeString(astr);
  assert(ustr2.Length() == (int)len1);
  assert(wcscmp(ustr2,wstr1) == 0);
}
예제 #8
0
  string toLower(const string& str) {// {{{
	  string ustr (str.size(),' ');
	  string::iterator it2=ustr.begin();
	  for ( string::const_iterator it1=str.begin();
		  it1!=str.end(); ++it1, ++it2) 
		  *it2 = tolower(*it1);
	  //transform(str.begin(), str.end(), ustr.begin(), toupper);
	  return ustr;
  }// }}
예제 #9
0
void Messages::convertTextToLink(const std::string& text, char **listeObjets, int size)
{
  UElem* allmsgs = new UElem();
  bool found = false;
  char* mess = strdup(text.c_str());

  if (size < 1) {
    cerr << "convertTextToLink not implemented" << endl;
    messages.add(uhbox(ugroup(mess)));
  }
  char *brkt = null;
  char *temp = strtok_r(mess, " ", &brkt);

  while (temp) {
    found = false;
    for (int i=0; i<size ; i=i+3) {

      if (! listeObjets[i])
        break;
      if ((!strcasecmp(listeObjets[i], temp)) && (listeObjets[i+1])) {
        UIma& uimg = uima(listeObjets[i+1]);	// loads image
        uimg.rescale(0.25);
        ULinkbutton& ulinkb =
        ulinkbutton(listeObjets[i]
                    + UColor::green + UFont::bold
                    + umenu(ulabel(uimg))
                    + UOn::doubleClick / ucall((char*)listeObjets[i+2], moveSatCamera)
                    );
        allmsgs->add(ulinkb);
        allmsgs->add(ustr(" "));
        found = true;
        unlink(listeObjets[i+1]);	// unlink temp file
        break;
      }
    }
    if (!found) {
      allmsgs->add(ugroup(temp));
      allmsgs->add(ustr(" "));
    }
    temp = strtok_r(NULL, " ", &brkt);
  }
  messages.add(uhbox(ustr("augmented msg>") + allmsgs));
  free(mess);
}
예제 #10
0
mapnik::value_unicode_string transcoder::transcode(const char* data, std::int32_t length) const
{
    UErrorCode err = U_ZERO_ERROR;

    mapnik::value_unicode_string ustr(data,length,conv_,err);
    if (ustr.isBogus())
    {
        ustr.remove();
    }
    return ustr;
}
예제 #11
0
UnicodeString transcoder::transcode(const char* data, boost::int32_t length) const
{
    UErrorCode err = U_ZERO_ERROR;
    
    UnicodeString ustr(data,length,conv_,err); 
    if (ustr.isBogus())
    {
        ustr.remove();
    }
    return ustr;
}
예제 #12
0
/* write to console buffer*/
void Console::writeln(std::string str){
	std::wstring ustr(str.length(), L' ');
	std::copy(str.begin(), str.end(), ustr.begin());
	//str.append(1, 0);
	Uint16 * line = new Uint16[ustr.size()];
	std::copy(ustr.begin(), ustr.end(), line);
	//Uint16 * line = (Uint16 *)ustr.data();
	
	this->m_lines.push_back(line);
//	writeText((const Uint16 *)ustr.data(), 14, this->color);
}
예제 #13
0
static Variant HHVM_METHOD(MessageFormatter, parse, const String& value) {
  FETCH_MFMT(data, this_);
  UErrorCode error = U_ZERO_ERROR;
  icu::UnicodeString ustr(u16(value, error));
  if (U_FAILURE(error)) {
    data->setError(error, "Error converting string to UTF-16");
    return false;
  }

  int32_t count;
  error = U_ZERO_ERROR;
  auto fargs = data->formatterObj()->parse(ustr, count, error);
  SCOPE_EXIT{ if (fargs) delete[] fargs; };
  if (U_FAILURE(error)) {
    data->setError(error, "Failed parsing value");
    return false;
  }

  Array ret = Array::Create();
  for (int i = 0; i < count; ++i) {
    switch (fargs[i].getType()) {
      case icu::Formattable::kDate:
        ret.append((double)fargs[i].getDate() / U_MILLIS_PER_SECOND);
        break;
      case icu::Formattable::kDouble:
        ret.append((double)fargs[i].getDouble());
        break;
      case icu::Formattable::kLong:
        ret.append((int64_t)fargs[i].getLong());
        break;
      case icu::Formattable::kInt64:
        ret.append((int64_t)fargs[i].getInt64());
        break;
      case icu::Formattable::kString: {
        icu::UnicodeString tmp;
        fargs[i].getString(tmp);
        error = U_ZERO_ERROR;
        String str(u8(tmp, error));
        if (U_FAILURE(error)) {
          data->setError(error, "Unable to convert to utf-8");
          return false;
        }
        ret.append(str);
        break;
      }
      case icu::Formattable::kObject:
      case icu::Formattable::kArray:
        data->setError(U_ILLEGAL_ARGUMENT_ERROR);
        break;
    }
  }
  return ret;
}
예제 #14
0
bool Transliteration::Transliterate(std::string const & str, int8_t langCode, std::string & out) const
{
  if (m_mode != Mode::Enabled)
    return false;

  if (str.empty() || strings::IsASCIIString(str))
    return false;

  std::string transliteratorId(StringUtf8Multilang::GetTransliteratorIdByCode(langCode));

  if (transliteratorId.empty())
    return false;

  auto it = m_transliterators.find(transliteratorId);
  if (it == m_transliterators.end())
  {
    LOG(LWARNING, ("Transliteration failed, unknown transliterator \"", transliteratorId, "\""));
    return false;
  }

  if (!it->second->m_initialized)
  {
    std::lock_guard<std::mutex> lock(it->second->m_mutex);
    if (!it->second->m_initialized)
    {
      UErrorCode status = U_ZERO_ERROR;

      std::string const removeDiacriticRule = ";NFD;[\u02B9-\u02D3\u0301-\u0358\u00B7\u0027]Remove;NFC";
      transliteratorId.append(removeDiacriticRule);

      UnicodeString translitId(transliteratorId.c_str());

      it->second->m_transliterator.reset(Transliterator::createInstance(translitId, UTRANS_FORWARD, status));

      if (it->second->m_transliterator == nullptr)
        LOG(LWARNING, ("Cannot create transliterator \"", transliteratorId, "\", icu error =", status));

      it->second->m_initialized = true;
    }
  }

  if (it->second->m_transliterator == nullptr)
    return false;

  UnicodeString ustr(str.c_str());
  it->second->m_transliterator->transliterate(ustr);

  if (ustr.isEmpty())
    return false;

  ustr.toUTF8String(out);
  return true;
}
예제 #15
0
UnicodeString transcoder::transcode(const char* data) const
{
    
    UErrorCode err = U_ZERO_ERROR;
    
    UnicodeString ustr(data,-1,conv_,err); 
    if (ustr.isBogus())
    {
	ustr.remove();
    }
    return ustr;
   }
예제 #16
0
inline obj eval_symbol(obj exp){	//assuming a symbol
	obj rr = find_var(exp);
	if(rr) return rr;
	rr = search_assoc(curr_interp->types, exp);	//type id
	if(rr) return rr;
	if(strcmp(ustr(exp), "glist")==0) return retain(curr_interp->gl_vars);
	obj (*func)(obj) = searchFunc(exp, specials);
	if(func) return tag(tSpecial, func);
	print(exp);
	myPrintf(" ");
	error(":undefined identifer");
	return nil;
}
예제 #17
0
java::lang::Object *toJava(const QoreString &str, ExceptionSink *xsink) {
   if (str.getEncoding() == QCS_UTF8)
      return JvNewStringUTF(str.getBuffer());
   
   if (str.getEncoding() == QCS_ISO_8859_1)
      return JvNewStringLatin1(str.getBuffer());

   TempEncodingHelper ustr(str, QCS_UTF8, xsink);
   if (!ustr)
      return 0;

   return JvNewStringUTF(ustr->getBuffer());
}
예제 #18
0
/* ACString ConvertUTF8toACE (in AUTF8String input); */
NS_IMETHODIMP nsIDNService::ConvertUTF8toACE(const nsACString & input, nsACString & ace)
{
  // protect against bogus input
  NS_ENSURE_TRUE(IsUTF8(input), NS_ERROR_UNEXPECTED);

  nsresult rv;
  NS_ConvertUTF8toUCS2 ustr(input);

  // map ideographic period to ASCII period etc.
  normalizeFullStops(ustr);


  PRUint32 len, offset;
  len = 0;
  offset = 0;
  nsCAutoString encodedBuf;

  nsAString::const_iterator start, end;
  ustr.BeginReading(start); 
  ustr.EndReading(end); 
  ace.Truncate();

  // encode nodes if non ASCII
  while (start != end) {
    len++;
    if (*start++ == (PRUnichar)'.') {
      rv = stringPrepAndACE(Substring(ustr, offset, len - 1), encodedBuf);
      NS_ENSURE_SUCCESS(rv, rv);

      ace.Append(encodedBuf);
      ace.Append('.');
      offset += len;
      len = 0;
    }
  }

  // add extra node for multilingual test bed
  if (mMultilingualTestBed)
    ace.AppendLiteral("mltbd.");
  // encode the last node if non ASCII
  if (len) {
    rv = stringPrepAndACE(Substring(ustr, offset, len), encodedBuf);
    NS_ENSURE_SUCCESS(rv, rv);

    ace.Append(encodedBuf);
  }

  return NS_OK;
}
예제 #19
0
nsresult nsIDNService::UTF8toACE(const nsACString & input, nsACString & ace, bool allowUnassigned)
{
  nsresult rv;
  NS_ConvertUTF8toUTF16 ustr(input);

  // map ideographic period to ASCII period etc.
  normalizeFullStops(ustr);


  uint32_t len, offset;
  len = 0;
  offset = 0;
  nsAutoCString encodedBuf;

  nsAString::const_iterator start, end;
  ustr.BeginReading(start); 
  ustr.EndReading(end); 
  ace.Truncate();

  // encode nodes if non ASCII
  while (start != end) {
    len++;
    if (*start++ == (PRUnichar)'.') {
      rv = stringPrepAndACE(Substring(ustr, offset, len - 1), encodedBuf,
                            allowUnassigned);
      NS_ENSURE_SUCCESS(rv, rv);

      ace.Append(encodedBuf);
      ace.Append('.');
      offset += len;
      len = 0;
    }
  }

  // add extra node for multilingual test bed
  if (mMultilingualTestBed)
    ace.AppendLiteral("mltbd.");
  // encode the last node if non ASCII
  if (len) {
    rv = stringPrepAndACE(Substring(ustr, offset, len), encodedBuf,
                          allowUnassigned);
    NS_ENSURE_SUCCESS(rv, rv);

    ace.Append(encodedBuf);
  }

  return NS_OK;
}
예제 #20
0
static bool xml_read_enum(ustring *str, ShaderEnum& enm, pugi::xml_node node, const char *name)
{
	pugi::xml_attribute attr = node.attribute(name);

	if(attr) {
		ustring ustr(attr.value());

		if(enm.exists(ustr)) {
			*str = ustr;
			return true;
		}
		else
			fprintf(stderr, "Unknown value \"%s\" for attribute \"%s\".\n", ustr.c_str(), name);
	}

	return false;
}
예제 #21
0
nsresult
nsJSONListener::ConsumeConverted(const char* aBuffer, PRUint32 aByteLength)
{
  nsresult rv;
  PRInt32 unicharLength = 0;
  PRInt32 srcLen = aByteLength;

  rv = mDecoder->GetMaxLength(aBuffer, srcLen, &unicharLength);
  NS_ENSURE_SUCCESS(rv, rv);
  nsAutoArrayPtr<PRUnichar> ustr(new PRUnichar[unicharLength]);
  NS_ENSURE_TRUE(ustr, NS_ERROR_OUT_OF_MEMORY);
  rv = mDecoder->Convert(aBuffer, &srcLen, ustr, &unicharLength);
  NS_ENSURE_SUCCESS(rv, rv);

  rv = Consume(ustr.get(), unicharLength);

  return rv;
}
예제 #22
0
inline FTBBox FTFontImpl::BBoxI(const T* string, const int len,
                                FTPoint position, FTPoint spacing)
{
    FTBBox totalBBox;

    /* Only compute the bounds if string is non-empty. */
    if(string && ('\0' != string[0]))
    {
        // for multibyte - we can't rely on sizeof(T) == character
        FTUnicodeStringItr<T> ustr(string);
        unsigned int thisChar = *ustr++;
        unsigned int nextChar = *ustr;

        if(CheckGlyph(thisChar))
        {
            totalBBox = glyphList->BBox(thisChar);
            totalBBox += position;

            position += FTPoint(glyphList->Advance(thisChar, nextChar), 0.0);
        }

        /* Expand totalBox by each glyph in string */
        for(int i = 1; (len < 0 && *ustr) || (len >= 0 && i < len); i++)
        {
            thisChar = *ustr++;
            nextChar = *ustr;

            if(CheckGlyph(thisChar))
            {
                position += spacing;

                FTBBox tempBBox = glyphList->BBox(thisChar);
                tempBBox += position;
                totalBBox |= tempBBox;

                position += FTPoint(glyphList->Advance(thisChar, nextChar),
                                    0.0);
            }
        }
    }

    return totalBBox;
}
예제 #23
0
inline float FTTextureFont::AdvanceI(const T* string, const int len,
                                     FTPoint spacing)
{
    float advance = 0.0f;
    FTUnicodeStringItr<T> ustr(string);

    for (int i = 0; (len < 0 && *ustr) || (len >= 0 && i < len); i++) {
        unsigned int thisChar = *ustr++;
        unsigned int nextChar = *ustr;

        if (CheckGlyph(thisChar)) {
            advance += glyphList->Advance(thisChar, nextChar);
        }

        if (nextChar) {
            advance += spacing.Xf();
        }
    }

    return advance;
}
static nsresult 
ToUTF8(const nsACString &aString, const char *aCharset,
       bool aAllowSubstitution, nsACString &aResult)
{
  nsresult rv;
  if (!aCharset || !*aCharset)
    return NS_ERROR_INVALID_ARG;

  nsCOMPtr<nsICharsetConverterManager> ccm;

  ccm = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIUnicodeDecoder> unicodeDecoder;
  rv = ccm->GetUnicodeDecoder(aCharset,
                              getter_AddRefs(unicodeDecoder));
  NS_ENSURE_SUCCESS(rv, rv);

  if (!aAllowSubstitution)
    unicodeDecoder->SetInputErrorBehavior(nsIUnicodeDecoder::kOnError_Signal);

  int32_t srcLen = aString.Length();
  int32_t dstLen;
  const nsAFlatCString& inStr = PromiseFlatCString(aString);
  rv = unicodeDecoder->GetMaxLength(inStr.get(), srcLen, &dstLen);
  NS_ENSURE_SUCCESS(rv, rv);

  nsAutoArrayPtr<PRUnichar> ustr(new PRUnichar[dstLen]);
  NS_ENSURE_TRUE(ustr, NS_ERROR_OUT_OF_MEMORY);

  rv = unicodeDecoder->Convert(inStr.get(), &srcLen, ustr, &dstLen);
  if (NS_SUCCEEDED(rv)){
    // Tru64 Cxx needs an explicit get()
    CopyUTF16toUTF8(Substring(ustr.get(), ustr + dstLen), aResult);
  }
  return rv;
}
예제 #25
0
UString &UString::operator+=(const std::string &str) {
	UString ustr(str);

	return *this += ustr;
}
예제 #26
0
 void encodeTest()
 {
   cxxtools::String ustr(L"Hi \xe4 there");
   std::string bstr = cxxtools::Iso8859_1Codec::encode(ustr);
   CXXTOOLS_UNIT_ASSERT_EQUALS(bstr, "Hi \xe4 there");
 }
예제 #27
0
/* Blind write no store */
void Console::write(std::string str){
	std::wstring ustr(str.length(), L' ');
	std::copy(str.begin(), str.end(), ustr.begin());

	writeText((const Uint16 *)ustr.data(), 14, this->color);
}
예제 #28
0
bool MessageFormatter::mapArgs(std::vector<icu::Formattable>& types,
                               std::vector<icu::UnicodeString>& names,
                               const Array& args) {
  int32_t count = args.size(), arg_num = 0;
  types.resize(count);
  names.resize(count);
  auto idx_limit = args->iter_end();
  for (auto idx = args->iter_begin(); idx != idx_limit;
       idx = args->iter_advance(idx), ++arg_num) {
    auto key = args->getKey(idx);
    icu::Formattable::Type type = icu::Formattable::kObject; // unknown
    if (key.isString()) {
      UErrorCode error = U_ZERO_ERROR;
      icu::UnicodeString key16(u16(key.toString(), error));
      if (U_FAILURE(error)) {
        setError(U_ILLEGAL_ARGUMENT_ERROR,
                 "Invalid UTF-8 data in argument key: '%s'",
                 key.toString().c_str());
        return false;
      }
      if (m_namedParts.find(key16) != m_namedParts.end()) {
        type = m_namedParts[key16];
      }
      names[arg_num] = key16;
    } else {
      auto num = key.toInt64();
      if (m_numericParts.find(num) != m_numericParts.end()) {
        type = m_numericParts[num];
      }
      char buffer[12];
      int32_t len = snprintf(buffer, sizeof(buffer), "%d", (int)num);
      UErrorCode error = U_ZERO_ERROR;
      icu::UnicodeString numName(u16(String(buffer, len, CopyString), error));
      names[arg_num] = numName;
    }

    auto val = args->getValue(idx);
    icu::Formattable formattable;
    switch(type) {
      case icu::Formattable::kString: {
string_val:
        UErrorCode error = U_ZERO_ERROR;
        icu::UnicodeString ustr(u16(val.toString(), error));
        if (U_FAILURE(error)) {
          setError(error, "Invalid UTF-8 data in string argument: '%s'",
                          val.toString().c_str());
          return false;
        }
        formattable.adoptString(new icu::UnicodeString(ustr));
        break;
      }
      case icu::Formattable::kDouble:
        formattable.setDouble(val.toDouble());
        break;
      case icu::Formattable::kLong:
        formattable.setLong(val.toInt64());
        break;
      case icu::Formattable::kInt64:
        formattable.setInt64(val.toInt64());
        break;
      case icu::Formattable::kDate:
        formattable.setDate(VariantToMilliseconds(val));
        break;
      default:
        // No context for arg, so make assupmtion based on value
        if (val.isDouble()) {
          formattable.setDouble(val.toDouble());
        } else if (val.isNull() || val.isBoolean() || val.isInteger()) {
          formattable.setInt64(val.toInt64());
        } else if (val.isString() || val.isObject()) {
          goto string_val;
        } else {
          setError(U_ILLEGAL_ARGUMENT_ERROR,
                   "No strategy to convert the "
                   "value given for the argument with key '%s' "
                   "is available", val.toString().c_str());
          return false;
        }
    }
    types[arg_num] = formattable;
  }
  return true;
}
예제 #29
0
void get_unicode_info(const char* text, const icu::UnicodeString& us, Sqlite::Statement& insert) {
    bool allokay = true;
    for (const char* t = text; *t; ++t) {
        if (!(std::isalnum(*t) || *t == '_' || *t == ':' || *t == ' ' || *t == '.' || *t == '-')) {
            allokay = false;
            break;
        }
    }

    if (allokay) {
        return;
    }

    bool unusual = false;
    for (icu::StringCharacterIterator it(us); it.hasNext(); it.next()) {
        UChar32 codepoint = it.current32();
        int8_t chartype = u_charType(codepoint);
        if (! u_isprint(codepoint)) {
            unusual = true;
            break;
        }
        if (u_charDirection(codepoint) != 0) {
            unusual = true;
            break;
        }
        if (chartype !=  1 && // UPPERCASE_LETTER
            chartype !=  2 && // LOWERCASE_LETTER
            chartype !=  9 && // DECIMAL_DIGIT_NUMBER
            chartype != 12 && // SPACE_SEPARATOR
            chartype != 19 && // DASH_PUNCTUATION
            chartype != 22 && // CONNECTOR_PUNCTUATION
            chartype != 23) { // OTHER_PUNCTUATION
            unusual = true;
            break;
        }
    }

    if (unusual) {
        int num = 0;
        for (icu::StringCharacterIterator it(us); it.hasNext(); it.next(), ++num) {
            UChar32 codepoint = it.current32();

            int8_t chartype = u_charType(codepoint);

            char buffer[100];
            UErrorCode errorCode = U_ZERO_ERROR;
            u_charName(codepoint, U_UNICODE_CHAR_NAME, buffer, sizeof(buffer), &errorCode);

            UCharDirection direction = u_charDirection(codepoint);
            int32_t block = u_getIntPropertyValue(codepoint, UCHAR_BLOCK);

            icu::UnicodeString ustr(codepoint);
            std::string str;
            ustr.toUTF8String(str);

            char uplus[10];
            snprintf(uplus, 10, "U+%04x", codepoint);

            insert.
                bind_text(text).
                bind_int(num).
                bind_text(str.c_str()).
                bind_text(uplus).
                bind_int(block).
                bind_text(category_to_string(chartype)).
                bind_int(direction).
                bind_text(buffer).
                execute();
        }
    }
}
예제 #30
0
UString &UString::operator+=(const char *str) {
	UString ustr(str);

	return *this += ustr;
}