本文整理汇总了C++中TextBreakIterator类的典型用法代码示例。如果您正苦于以下问题:C++ TextBreakIterator类的具体用法?C++ TextBreakIterator怎么用?C++ TextBreakIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextBreakIterator类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: acquireLineBreakIterator
TextBreakIterator* acquireLineBreakIterator(const LChar* string, int length, const AtomicString& locale, const UChar* priorContext, unsigned priorContextLength)
{
TextBreakIterator* iterator = LineBreakIteratorPool::sharedPool().take(locale);
if (!iterator)
return 0;
UTextWithBuffer textLocal;
textLocal.text = emptyText;
textLocal.text.extraSize = sizeof(textLocal.buffer);
textLocal.text.pExtra = textLocal.buffer;
UErrorCode openStatus = U_ZERO_ERROR;
UText* text = textOpenLatin1(&textLocal, string, length, priorContext, priorContextLength, &openStatus);
if (U_FAILURE(openStatus)) {
WTF_LOG_ERROR("textOpenLatin1 failed with status %d", openStatus);
return 0;
}
UErrorCode setTextStatus = U_ZERO_ERROR;
iterator->setText(text, setTextStatus);
if (U_FAILURE(setTextStatus)) {
WTF_LOG_ERROR("ubrk_setUText failed with status %d", setTextStatus);
return 0;
}
utext_close(text);
return iterator;
}
开发者ID:darktears,项目名称:blink-crosswalk,代码行数:29,代码来源:TextBreakIteratorICU.cpp
示例2: findNextWordFromIndex
int findNextWordFromIndex(const UChar* chars, int len, int position, bool forward)
{
TextBreakIterator* it = wordBreakIterator(chars, len);
if (forward) {
position = it->following(position);
while (position != TextBreakDone) {
// We stop searching when the character preceeding the break
// is alphanumeric.
if (position < len && isAlphanumeric(chars[position - 1]))
return position;
position = it->following(position);
}
return len;
} else {
position = it->preceding(position);
while (position != TextBreakDone) {
// We stop searching when the character following the break
// is alphanumeric.
if (position > 0 && isAlphanumeric(chars[position]))
return position;
position = it->preceding(position);
}
return 0;
}
}
开发者ID:dstockwell,项目名称:blink,代码行数:30,代码来源:TextBoundaries.cpp
示例3: findMisspellings
static void findMisspellings(TextCheckerClient& client, const UChar* text, int start, int length, Vector<TextCheckingResult>& results)
{
TextBreakIterator* iterator = wordBreakIterator(text + start, length);
if (!iterator)
return;
int wordStart = iterator->current();
while (0 <= wordStart) {
int wordEnd = iterator->next();
if (wordEnd < 0)
break;
int wordLength = wordEnd - wordStart;
int misspellingLocation = -1;
int misspellingLength = 0;
client.checkSpellingOfString(String(text + start + wordStart, wordLength), &misspellingLocation, &misspellingLength);
if (0 < misspellingLength) {
ASSERT(0 <= misspellingLocation && misspellingLocation <= wordLength);
ASSERT(0 < misspellingLength && misspellingLocation + misspellingLength <= wordLength);
TextCheckingResult misspelling;
misspelling.decoration = TextDecorationTypeSpelling;
misspelling.location = start + wordStart + misspellingLocation;
misspelling.length = misspellingLength;
results.append(misspelling);
}
wordStart = wordEnd;
}
}
开发者ID:astojilj,项目名称:chromium-crosswalk,代码行数:27,代码来源:TextCheckingHelper.cpp
示例4: toRenderText
Dart_Handle Paragraph::getWordBoundary(unsigned offset) {
String text;
int start = 0, end = 0;
for (RenderObject* object = m_renderView.get(); object;
object = object->nextInPreOrder()) {
if (!object->isText())
continue;
RenderText* renderText = toRenderText(object);
text.append(renderText->text());
}
TextBreakIterator* it = wordBreakIterator(text, 0, text.length());
if (it) {
end = it->following(offset);
if (end < 0)
end = it->last();
start = it->previous();
}
Dart_Handle result = Dart_NewList(2);
Dart_ListSetAt(result, 0, ToDart(start));
Dart_ListSetAt(result, 1, ToDart(end));
return result;
}
开发者ID:rmacnak-google,项目名称:engine,代码行数:25,代码来源:Paragraph.cpp
示例5: findWordBoundary
void findWordBoundary(const UChar* chars, int len, int position, int* start, int* end)
{
TextBreakIterator* it = wordBreakIterator(chars, len);
*end = it->following(position);
if (*end < 0)
*end = it->last();
*start = it->previous();
}
开发者ID:dstockwell,项目名称:blink,代码行数:8,代码来源:TextBoundaries.cpp
示例6: countGraphemesInCluster
static inline unsigned countGraphemesInCluster(const UChar* str,
unsigned strLength, uint16_t startIndex, uint16_t endIndex)
{
if (startIndex > endIndex) {
uint16_t tempIndex = startIndex;
startIndex = endIndex;
endIndex = tempIndex;
}
uint16_t length = endIndex - startIndex;
ASSERT(static_cast<unsigned>(startIndex + length) <= strLength);
TextBreakIterator* cursorPosIterator = cursorMovementIterator(&str[startIndex], length);
int cursorPos = cursorPosIterator->current();
int numGraphemes = -1;
while (0 <= cursorPos) {
cursorPos = cursorPosIterator->next();
numGraphemes++;
}
return std::max(0, numGraphemes);
}
开发者ID:shaoboyan,项目名称:chromium-crosswalk,代码行数:20,代码来源:ShapeResult.cpp
示例7: wordBreakIterator
void AbstractInlineTextBox::wordBoundaries(Vector<WordBoundaries>& words) const
{
if (!m_inlineTextBox)
return;
String text = this->text();
int len = text.length();
TextBreakIterator* iterator = wordBreakIterator(text, 0, len);
// FIXME: When http://crbug.com/411764 is fixed, replace this with an ASSERT.
if (!iterator)
return;
int pos = iterator->first();
while (pos >= 0 && pos < len) {
int next = iterator->next();
if (isWordTextBreak(iterator))
words.append(WordBoundaries(pos, next));
pos = next;
}
}
开发者ID:kjthegod,项目名称:WebKit,代码行数:21,代码来源:AbstractInlineTextBox.cpp
示例8: findWordEndBoundary
int findWordEndBoundary(const UChar* chars, int len, int position)
{
TextBreakIterator* it = wordBreakIterator(chars, len);
int end = it->following(position);
return end < 0 ? it->last() : end;
}
开发者ID:dstockwell,项目名称:blink,代码行数:6,代码来源:TextBoundaries.cpp
示例9: isASingleWord
// Helper function to determine whether text is a single word.
static bool isASingleWord(const String& text)
{
TextBreakIterator* it = wordBreakIterator(text, 0, text.length());
return it && it->next() == static_cast<int>(text.length());
}
开发者ID:ewilligers,项目名称:blink,代码行数:6,代码来源:ContextMenuClientImpl.cpp
注:本文中的TextBreakIterator类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论