本文整理汇总了C++中WideString类的典型用法代码示例。如果您正苦于以下问题:C++ WideString类的具体用法?C++ WideString怎么用?C++ WideString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WideString类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GetString
WideString CFX_BreakPiece::GetString() const {
WideString ret;
ret.Reserve(m_iChars);
for (int32_t i = m_iStartChar; i < m_iStartChar + m_iChars; i++)
ret += static_cast<wchar_t>((*m_pChars)[i].char_code());
return ret;
}
开发者ID:,项目名称:,代码行数:7,代码来源:
示例2: WideString
WideString CPDF_TextPage::GetTextByPredicate(
const std::function<bool(const PAGECHAR_INFO&)>& predicate) const {
if (!m_bIsParsed)
return WideString();
float posy = 0;
bool IsContainPreChar = false;
bool IsAddLineFeed = false;
WideString strText;
for (const auto& charinfo : m_CharList) {
if (predicate(charinfo)) {
if (fabs(posy - charinfo.m_Origin.y) > 0 && !IsContainPreChar &&
IsAddLineFeed) {
posy = charinfo.m_Origin.y;
if (!strText.IsEmpty())
strText += L"\r\n";
}
IsContainPreChar = true;
IsAddLineFeed = false;
if (charinfo.m_Unicode)
strText += charinfo.m_Unicode;
} else if (charinfo.m_Unicode == L' ') {
if (IsContainPreChar) {
strText += L' ';
IsContainPreChar = false;
IsAddLineFeed = false;
}
} else {
IsContainPreChar = false;
IsAddLineFeed = true;
}
}
return strText;
}
开发者ID:,项目名称:,代码行数:34,代码来源:
示例3:
PyObject *
PyIMEngine::py_get_surrounding_text (PyIMEngineObject *self, PyObject *args)
{
PyObject *tuple;
int maxlen_before = -1;
int maxlen_after = -1;
if (!PyArg_ParseTuple (args, "|ii:get_surrounding_text", &maxlen_before, &maxlen_after))
return NULL;
WideString text;
int cursor;
int provided = self->engine.get_surrounding_text(text, cursor, maxlen_before, maxlen_after);
tuple = PyTuple_New (2);
if (!provided) {
text = L"";
cursor = 0;
}
#if Py_UNICODE_SIZE == 4
PyTuple_SET_ITEM (tuple, 0, PyUnicode_FromUnicode ((Py_UNICODE *)text.c_str(), text.length()));
#else
gunichar2 *utf16_str = g_ucs4_to_utf16 (text.c_str(), -1, NULL, NULL, NULL);
PyTuple_SET_ITEM (tuple, 0, PyUnicode_FromUnicode ((Py_UNICODE *)utf16_str, text.length()));
#endif
PyTuple_SET_ITEM (tuple, 1, PyInt_FromLong ((long) cursor));
return tuple;
}
开发者ID:Alwnikrotikz,项目名称:scim-python,代码行数:32,代码来源:scim-python-engine.cpp
示例4: if
ScValue *SXString::scGetProperty(const Common::String &name) {
_scValue->setNULL();
//////////////////////////////////////////////////////////////////////////
// Type (RO)
//////////////////////////////////////////////////////////////////////////
if (name == "Type") {
_scValue->setString("string");
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// Length (RO)
//////////////////////////////////////////////////////////////////////////
else if (name == "Length") {
if (_gameRef->_textEncoding == TEXT_UTF8) {
WideString wstr = StringUtil::utf8ToWide(_string);
_scValue->setInt(wstr.size());
} else {
_scValue->setInt(strlen(_string));
}
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// Capacity
//////////////////////////////////////////////////////////////////////////
else if (name == "Capacity") {
_scValue->setInt(_capacity);
return _scValue;
} else {
return _scValue;
}
}
开发者ID:CatalystG,项目名称:scummvm,代码行数:33,代码来源:script_ext_string.cpp
示例5: TEST_F
TEST_F(CFGAS_FormatStringTest, DateTimeFormat) {
struct {
const wchar_t* locale;
const wchar_t* input;
const wchar_t* pattern;
const wchar_t* output;
} tests[] = {
{L"en", L"1999-07-16T10:30Z",
L"'At' time{HH:MM Z} 'on' date{MMM DD, YYYY}",
L"At 10:30 GMT on Jul 16, 1999"},
{L"en", L"1999-07-16T10:30", L"'At' time{HH:MM} 'on' date{MMM DD, YYYY}",
L"At 10:30 on Jul 16, 1999"},
{L"en", L"1999-07-16T10:30Z",
L"time{'At' HH:MM Z} date{'on' MMM DD, YYYY}",
L"At 10:30 GMT on Jul 16, 1999"},
{L"en", L"1999-07-16T10:30Z",
L"time{'At 'HH:MM Z}date{' on 'MMM DD, YYYY}",
L"At 10:30 GMT on Jul 16, 1999"}};
for (size_t i = 0; i < FX_ArraySize(tests); ++i) {
WideString result;
EXPECT_TRUE(fmt(tests[i].locale)
->FormatDateTime(tests[i].input, tests[i].pattern,
FX_DATETIMETYPE_TimeDate, &result));
EXPECT_STREQ(tests[i].output, result.c_str()) << " TEST: " << i;
}
}
开发者ID:,项目名称:,代码行数:27,代码来源:
示例6: Render
void CRespawn::Render()
{
position2d<s32> pos;
for ( int i = 0; i < points.size(); i++ )
{
WideString wstr = "(S) ";
wstr += points[i]->getActorName().c_str();
pos = IRR.smgr->getSceneCollisionManager()->getScreenCoordinatesFrom3DPosition( points[i]->getPosition(), IRR.smgr->getActiveCamera() );
IRR.gui->getBuiltInFont()->draw( wstr.c_str(), core::rect<s32>( pos.X, pos.Y, pos.X + 100, pos.Y + 50 ), irr::video::SColor( 255, 15, 85, 10 ), false, true );
}
// draw 3d stuff
IRR.video->setTransform( ETS_WORLD, matrix4() );
SMaterial m;
m.Lighting = false;
m.BackfaceCulling = false;
IRR.video->setMaterial( m );
vector3df vP;
for ( int i = 0; i < points.size(); i++ )
{
vP = points[i]->getPosition();
IRR.video->draw3DBox( aabbox3df( vP - vector3df( points[i]->radius, points[i]->radius, points[i]->radius ), vP + vector3df( points[i]->radius, points[i]->radius, points[i]->radius ) ), SColor( 255, 105, 22, 90 ) );
}
}
开发者ID:master4523,项目名称:crimsonglory,代码行数:25,代码来源:respawn.cpp
示例7: TEST
TEST(cpdf_nametree, GetUnicodeNameWithBOM) {
// Set up the root dictionary with a Names array.
auto pRootDict = pdfium::MakeUnique<CPDF_Dictionary>();
CPDF_Array* pNames = pRootDict->SetNewFor<CPDF_Array>("Names");
// Add the key "1" (with BOM) and value 100 into the array.
std::ostringstream buf;
constexpr char kData[] = "\xFE\xFF\x00\x31";
for (size_t i = 0; i < sizeof(kData); ++i)
buf.put(kData[i]);
pNames->AddNew<CPDF_String>(ByteString(buf), true);
pNames->AddNew<CPDF_Number>(100);
// Check that the key is as expected.
CPDF_NameTree nameTree(pRootDict.get());
WideString storedName;
nameTree.LookupValueAndName(0, &storedName);
EXPECT_STREQ(L"1", storedName.c_str());
// Check that the correct value object can be obtained by looking up "1".
WideString matchName = L"1";
CPDF_Object* pObj = nameTree.LookupValue(matchName);
ASSERT_TRUE(pObj->IsNumber());
EXPECT_EQ(100, pObj->AsNumber()->GetInteger());
}
开发者ID:,项目名称:,代码行数:25,代码来源:
示例8:
CScValue *CScValue::GetProp(char *Name) {
if (m_Type == VAL_VARIABLE_REF) return m_ValRef->GetProp(Name);
if (m_Type == VAL_STRING && strcmp(Name, "Length") == 0) {
Game->m_ScValue->m_Type = VAL_INT;
if (Game->m_TextEncoding == TEXT_ANSI) {
Game->m_ScValue->SetInt(strlen(m_ValString));
} else {
WideString wstr = StringUtil::Utf8ToWide(m_ValString);
Game->m_ScValue->SetInt(wstr.length());
}
return Game->m_ScValue;
}
CScValue *ret = NULL;
if (m_Type == VAL_NATIVE && m_ValNative) ret = m_ValNative->ScGetProperty(Name);
if (ret == NULL) {
m_ValIter = m_ValObject.find(Name);
if (m_ValIter != m_ValObject.end()) ret = m_ValIter->second;
}
return ret;
}
开发者ID:somaen,项目名称:Wintermute-git,代码行数:26,代码来源:ScValue.cpp
示例9: if
WideString CPDF_FileSpec::GetFileName() const {
WideString csFileName;
if (const CPDF_Dictionary* pDict = m_pObj->AsDictionary()) {
csFileName = pDict->GetUnicodeTextFor("UF");
if (csFileName.IsEmpty()) {
csFileName = WideString::FromDefANSI(
pDict->GetStringFor(pdfium::stream::kF).AsStringView());
}
if (pDict->GetStringFor("FS") == "URL")
return csFileName;
if (csFileName.IsEmpty()) {
constexpr const char* keys[] = {"DOS", "Mac", "Unix"};
for (const auto* key : keys) {
if (pDict->KeyExist(key)) {
csFileName =
WideString::FromDefANSI(pDict->GetStringFor(key).AsStringView());
break;
}
}
}
} else if (m_pObj->IsString()) {
csFileName = WideString::FromDefANSI(m_pObj->GetString().AsStringView());
}
return DecodeFileName(csFileName);
}
开发者ID:,项目名称:,代码行数:26,代码来源:
示例10: TextFieldKeyPressed
bool LodDistanceControl::TextFieldKeyPressed(UITextField * textField, int32 replacementLocation, int32 replacementLength, const WideString & replacementString)
{
if (replacementLength < 0)
{
return true;
}
WideString newText = textField->GetAppliedChanges(replacementLocation, replacementLength, replacementString);
bool allOk;
int pointsCount = 0;
for (int i = 0; i < newText.length(); i++)
{
allOk = false;
if (newText[i] == L'-' && i == 0)
{
allOk = true;
}
else if(newText[i] >= L'0' && newText[i] <= L'9')
{
allOk = true;
}
else if(newText[i] == L'.' && pointsCount == 0)
{
allOk = true;
pointsCount++;
}
if (!allOk)
{
return false;
}
}
return true;
};
开发者ID:,项目名称:,代码行数:33,代码来源:
示例11: GetUnicodeFromCharCode
WideString CPDF_CIDFont::UnicodeFromCharCode(uint32_t charcode) const {
WideString str = CPDF_Font::UnicodeFromCharCode(charcode);
if (!str.IsEmpty())
return str;
wchar_t ret = GetUnicodeFromCharCode(charcode);
return ret ? ret : WideString();
}
开发者ID:,项目名称:,代码行数:7,代码来源:
示例12: ASSERT
void ButtonBuildStructure::onRender( RenderContext & context, const RectInt & window )
{
WindowButton::onRender( context, window );
if ( enabled() && m_Build.valid() )
{
DisplayDevice * pDisplay = context.display();
ASSERT( pDisplay );
// draw the eta to build this structure
Font * pFont = windowStyle()->font();
if ( pFont != NULL )
{
WideString eta;
GameDocument * pDoc = (GameDocument *)document();
if ( pDoc != NULL )
{
NounShip::Ref pShip = pDoc->ship();
if ( pShip.valid() )
{
int buildTime = m_Build->buildTime()* pShip->calculateModifier(MT_BUILD_SPEED,true);
eta.format( "%d:%2.2d", buildTime / 60, buildTime % 60);
SizeInt etaSize( pFont->size( eta ) );
PointInt etaPos( window.right - etaSize.width, window.bottom - etaSize.height );
Font::push( context.display(), pFont, etaPos, eta, WHITE );
}
}
}
}
}
开发者ID:BlackYoup,项目名称:darkspace,代码行数:32,代码来源:ButtonBuildStructure.cpp
示例13:
ScValue *ScValue::getProp(const char *name) {
if (_type == VAL_VARIABLE_REF) {
return _valRef->getProp(name);
}
if (_type == VAL_STRING && strcmp(name, "Length") == 0) {
_gameRef->_scValue->_type = VAL_INT;
if (_gameRef->_textEncoding == TEXT_ANSI) {
_gameRef->_scValue->setInt(strlen(_valString));
} else {
WideString wstr = StringUtil::utf8ToWide(_valString);
_gameRef->_scValue->setInt(wstr.size());
}
return _gameRef->_scValue;
}
ScValue *ret = nullptr;
if (_type == VAL_NATIVE && _valNative) {
ret = _valNative->scGetProperty(name);
}
if (ret == nullptr) {
_valIter = _valObject.find(name);
if (_valIter != _valObject.end()) {
ret = _valIter->_value;
}
}
return ret;
}
开发者ID:MaddTheSane,项目名称:scummvm,代码行数:32,代码来源:script_value.cpp
示例14: WideString2QStrint
QString WideString2QStrint(const WideString& str)
{
#ifdef __DAVAENGINE_MACOS__
return QString::fromStdWString(str);
#else
return QString((const QChar*)str.c_str(), str.length());
#endif
}
开发者ID:,项目名称:,代码行数:8,代码来源:
示例15: GetOnedCode39Writer
bool CBC_Code39::RenderDevice(CFX_RenderDevice* device,
const CFX_Matrix* matrix) {
auto* pWriter = GetOnedCode39Writer();
WideString renderCon;
if (!pWriter->encodedContents(m_renderContents.AsStringView(), &renderCon))
return false;
return pWriter->RenderDeviceResult(device, matrix, renderCon.AsStringView());
}
开发者ID:,项目名称:,代码行数:8,代码来源:
示例16: indexOf
int StringUtil::indexOf(const WideString &str, const WideString &toFind, size_t startFrom) {
const char *index = strstr(str.c_str(), toFind.c_str());
if (index == nullptr) {
return -1;
} else {
return index - str.c_str();
}
}
开发者ID:,项目名称:,代码行数:8,代码来源:
示例17: get_preedit_string
void
HangulInstance::update_candidates ()
{
m_lookup_table.clear ();
m_candidate_comments.clear ();
HanjaList* list = NULL;
// search for symbol character
// key string for symbol character is like:
// 'ㄱ', 'ㄴ', 'ㄷ', etc
WideString preeditw = get_preedit_string();
if (preeditw.length() == 1) {
String key = utf8_wcstombs(preeditw);
list = hanja_table_match_suffix(m_factory->m_symbol_table, key.c_str());
}
// search for hanja
if (list == NULL) {
String str = get_candidate_string();
SCIM_DEBUG_IMENGINE(1) << "candidate string: " << str << "\n";
if (str.length() > 0) {
if (is_hanja_mode() || m_factory->m_commit_by_word) {
list = hanja_table_match_prefix(m_factory->m_hanja_table,
str.c_str());
} else {
list = hanja_table_match_suffix(m_factory->m_hanja_table,
str.c_str());
}
}
}
if (list != NULL) {
int n = hanja_list_get_size(list);
for (int i = 0; i < n; ++i) {
const char* value = hanja_list_get_nth_value(list, i);
const char* comment = hanja_list_get_nth_comment(list, i);
WideString candidate = utf8_mbstowcs(value, -1);
m_lookup_table.append_candidate(candidate);
m_candidate_comments.push_back(String(comment));
}
m_lookup_table.set_page_size (9);
m_lookup_table.show_cursor ();
update_lookup_table (m_lookup_table);
show_lookup_table ();
hangul_update_aux_string ();
hanja_list_delete(list);
}
if (m_lookup_table.number_of_candidates() <= 0) {
delete_candidates();
}
}
开发者ID:tzhuan,项目名称:scim-hangul,代码行数:58,代码来源:scim_hangul_imengine.cpp
示例18: PreMarkedContent
FPDFText_MarkedContent CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) {
CPDF_TextObject* pTextObj = Obj.m_pTextObj.Get();
size_t nContentMarks = pTextObj->m_ContentMarks.CountItems();
if (nContentMarks == 0)
return FPDFText_MarkedContent::Pass;
WideString actText;
bool bExist = false;
const CPDF_Dictionary* pDict = nullptr;
for (size_t i = 0; i < nContentMarks; ++i) {
const CPDF_ContentMarkItem* item = pTextObj->m_ContentMarks.GetItem(i);
pDict = item->GetParam();
if (!pDict)
continue;
const CPDF_String* temp = ToString(pDict->GetObjectFor("ActualText"));
if (temp) {
bExist = true;
actText = temp->GetUnicodeText();
}
}
if (!bExist)
return FPDFText_MarkedContent::Pass;
if (m_pPreTextObj) {
const CPDF_ContentMarks& marks = m_pPreTextObj->m_ContentMarks;
if (marks.CountItems() == nContentMarks &&
marks.GetItem(nContentMarks - 1)->GetParam() == pDict) {
return FPDFText_MarkedContent::Done;
}
}
if (actText.IsEmpty())
return FPDFText_MarkedContent::Pass;
CPDF_Font* pFont = pTextObj->GetFont();
bExist = false;
for (size_t i = 0; i < actText.GetLength(); ++i) {
if (pFont->CharCodeFromUnicode(actText[i]) != CPDF_Font::kInvalidCharCode) {
bExist = true;
break;
}
}
if (!bExist)
return FPDFText_MarkedContent::Pass;
bExist = false;
for (size_t i = 0; i < actText.GetLength(); ++i) {
wchar_t wChar = actText[i];
if ((wChar > 0x80 && wChar < 0xFFFD) || (wChar <= 0x80 && isprint(wChar))) {
bExist = true;
break;
}
}
if (!bExist)
return FPDFText_MarkedContent::Done;
return FPDFText_MarkedContent::Delay;
}
开发者ID:,项目名称:,代码行数:58,代码来源:
示例19: toString
//=====================================================================================
String IC_StrConv::toString( const WideString str )
{
int len = str.size() + 1;
c8* buf = new c8[len];
::wcstombs( buf, str.c_str(), len );
String wstr = buf;
delete[] buf;
return wstr;
}
开发者ID:master4523,项目名称:crimsonglory,代码行数:10,代码来源:console_utils.cpp
示例20: printf
/*!\brief Formatierten Text ausgeben
*
* \desc
* Mit dieser Funktion wird zunächst ein Text anhand des Formatstrings
* \p fmt erstellt und dann auf der Grafik an den
* Koordinaten \p x und \p y unter Verwendeung des Fonts \p font ausgegeben.
*
* @param font Zu verwendende Font-Parameter
* @param x X-Koordinate
* @param y Y-Koordinate
* @param fmt Formatstring
* @param ... optionale Parameter für den Formatstring
*/
void Drawable::printf(const Font &font, int x, int y, const char *fmt, ...)
{
WideString s;
va_list args;
va_start(args, fmt);
s.vasprintf(fmt,args);
va_end(args);
print(font,x,y,s);
}
开发者ID:pfedick,项目名称:pplib,代码行数:22,代码来源:Fonts.cpp
注:本文中的WideString类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论