コード例 #1
0
ファイル: ext_icu_timezone.cpp プロジェクト: Debug-Orz/hhvm
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;
}
コード例 #2
0
ファイル: icu.cpp プロジェクト: BiggDaddy/hhvm
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;
}