本文整理汇总了C++中wstring_to_utf8str函数的典型用法代码示例。如果您正苦于以下问题:C++ wstring_to_utf8str函数的具体用法?C++ wstring_to_utf8str怎么用?C++ wstring_to_utf8str使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wstring_to_utf8str函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
// If input of the form "/20foo" or "/20 foo", returns "foo" and channel 20.
// Otherwise returns input and channel 0.
LLWString LLChatBar::stripChannelNumber(const LLWString &mesg, S32* channel)
{
if (mesg[0] == '/'
&& mesg[1] == '/')
{
// This is a "repeat channel send"
*channel = mLastSpecialChatChannel;
return mesg.substr(2, mesg.length() - 2);
}
else if (mesg[0] == '/'
&& mesg[1]
&& ( LLStringOps::isDigit(mesg[1])
|| mesg[1] == '-' ))
{
// This a special "/20" speak on a channel
S32 pos = 0;
if(mesg[1] == '-')
pos++;
// Copy the channel number into a string
LLWString channel_string;
llwchar c;
do
{
c = mesg[pos+1];
channel_string.push_back(c);
pos++;
}
while(c && pos < 64 && LLStringOps::isDigit(c));
// Move the pointer forward to the first non-whitespace char
// Check isspace before looping, so we can handle "/33foo"
// as well as "/33 foo"
while(c && iswspace(c))
{
c = mesg[pos+1];
pos++;
}
mLastSpecialChatChannel = strtol(wstring_to_utf8str(channel_string).c_str(), NULL, 10);
if(mesg[1] == '-')
mLastSpecialChatChannel = -mLastSpecialChatChannel;
*channel = mLastSpecialChatChannel;
return mesg.substr(pos, mesg.length() - pos);
}
else
{
// This is normal chat.
*channel = 0;
return mesg;
}
}
示例2: stripChannelNumber
// <dogmode>
void LLChatBar::sendChat( EChatType type )
{
if (mInputEditor)
{
LLWString text = mInputEditor->getConvertedText();
if (!text.empty())
{
// store sent line in history, duplicates will get filtered
if (mInputEditor) mInputEditor->updateHistory();
S32 channel = 0;
stripChannelNumber(text, &channel);
std::string utf8text = wstring_to_utf8str(text);//+" and read is "+llformat("%f",readChan)+" and undone is "+llformat("%d",undoneChan)+" but actualy channel is "+llformat("%d",channel);
// Try to trigger a gesture, if not chat to a script.
std::string utf8_revised_text;
if (0 == channel)
{
convert_roleplay_text(utf8text);
// discard returned "found" boolean
LLGestureMgr::instance().triggerAndReviseString(utf8text, &utf8_revised_text);
}
else
{
utf8_revised_text = utf8text;
}
utf8_revised_text = utf8str_trim(utf8_revised_text);
EChatType nType(type == CHAT_TYPE_OOC ? CHAT_TYPE_NORMAL : type);
if (!utf8_revised_text.empty() && cmd_line_chat(utf8_revised_text, nType))
{
// Chat with animation
#if SHY_MOD //Command handler
if(!SHCommandHandler::handleCommand(true, utf8_revised_text, gAgentID, (LLViewerObject*)gAgentAvatarp))//returns true if handled
#endif //shy_mod
sendChatFromViewer(utf8_revised_text, nType, TRUE);
}
}
}
childSetValue("Chat Editor", LLStringUtil::null);
gAgent.stopTyping();
// If the user wants to stop chatting on hitting return, lose focus
// and go out of chat mode.
if (gChatBar == this && gSavedSettings.getBOOL("CloseChatOnReturn"))
{
stopChat();
}
}
示例3: getChildList
BOOL LLViewerTextEditor::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen)
{
for (child_list_const_iter_t child_iter = getChildList()->begin();
child_iter != getChildList()->end(); ++child_iter)
{
LLView *viewp = *child_iter;
S32 local_x = x - viewp->getRect().mLeft;
S32 local_y = y - viewp->getRect().mBottom;
if( viewp->pointInView(local_x, local_y)
&& viewp->getVisible()
&& viewp->getEnabled()
&& viewp->handleToolTip(local_x, local_y, msg, sticky_rect_screen ) )
{
return TRUE;
}
}
if( mSegments.empty() )
{
return TRUE;
}
const LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y );
if( cur_segment )
{
BOOL has_tool_tip = FALSE;
if( cur_segment->getStyle()->getIsEmbeddedItem() )
{
LLWString wtip;
has_tool_tip = getEmbeddedItemToolTipAtPos(cur_segment->getStart(), wtip);
msg = wstring_to_utf8str(wtip);
}
else
{
has_tool_tip = cur_segment->getToolTip( msg );
}
if( has_tool_tip )
{
// Just use a slop area around the cursor
// Convert rect local to screen coordinates
S32 SLOP = 8;
localPointToScreen(
x - SLOP, y - SLOP,
&(sticky_rect_screen->mLeft), &(sticky_rect_screen->mBottom) );
sticky_rect_screen->mRight = sticky_rect_screen->mLeft + 2 * SLOP;
sticky_rect_screen->mTop = sticky_rect_screen->mBottom + 2 * SLOP;
}
}
return TRUE;
}
示例4: stripChannelNumber
void LLNearbyChatBar::sendChat( EChatType type )
{
if (mChatBox)
{
LLWString text = mChatBox->getConvertedText();
if (!text.empty())
{
// store sent line in history, duplicates will get filtered
mChatBox->updateHistory();
// Check if this is destined for another channel
S32 channel = 0;
stripChannelNumber(text, &channel);
std::string utf8text = wstring_to_utf8str(text);
// Try to trigger a gesture, if not chat to a script.
std::string utf8_revised_text;
if (0 == channel)
{
// discard returned "found" boolean
LLGestureMgr::instance().triggerAndReviseString(utf8text, &utf8_revised_text);
}
else
{
utf8_revised_text = utf8text;
}
utf8_revised_text = utf8str_trim(utf8_revised_text);
type = processChatTypeTriggers(type, utf8_revised_text);
if (!utf8_revised_text.empty())
{
// Chat with animation
sendChatFromViewer(utf8_revised_text, type, TRUE);
}
}
mChatBox->setText(LLStringExplicit(""));
}
gAgent.stopTyping();
// If the user wants to stop chatting on hitting return, lose focus
// and go out of chat mode.
if (gSavedSettings.getBOOL("CloseChatOnReturn"))
{
stopChat();
}
}
示例5: LL_DEBUGS
void LLFloaterAutoReplaceSettings::onSaveEntry()
{
LL_DEBUGS("AutoReplace")<<"called"<<LL_ENDL;
if ( ! mPreviousKeyword.empty() )
{
// delete any existing value for the key that was editted
LL_INFOS("AutoReplace")
<< "list '" << mSelectedListName << "' "
<< "removed '" << mPreviousKeyword
<< "'" << LL_ENDL;
mSettings.removeEntryFromList( mPreviousKeyword, mSelectedListName );
}
LLWString keyword = mKeyword->getWText();
LLWString replacement = mReplacement->getWText();
if ( mSettings.addEntryToList(keyword, replacement, mSelectedListName) )
{
// insert the new keyword->replacement pair
LL_INFOS("AutoReplace")
<< "list '" << mSelectedListName << "' "
<< "added '" << wstring_to_utf8str(keyword)
<< "' -> '" << wstring_to_utf8str(replacement)
<< "'" << LL_ENDL;
updateReplacementsList();
}
else
{
LLNotificationsUtil::add("InvalidAutoReplaceEntry");
LL_WARNS("AutoReplace")<<"invalid entry "
<< "keyword '" << wstring_to_utf8str(keyword)
<< "' replacement '" << wstring_to_utf8str(replacement)
<< "'" << LL_ENDL;
}
}
示例6: llmin
// Copies escaped URL to clipboard
void LLURLLineEditor::copyEscapedURLToClipboard()
{
S32 left_pos = llmin( mSelectionStart, mSelectionEnd );
S32 length = llabs( mSelectionStart - mSelectionEnd );
const std::string unescaped_text = wstring_to_utf8str(mText.getWString().substr(left_pos, length));
LLWString text_to_copy;
// *HACK: Because LLSLURL is currently broken we cannot use it to check if unescaped_text is a valid SLURL (see EXT-8335).
if (LLStringUtil::startsWith(unescaped_text, "http://")) // SLURL
text_to_copy = utf8str_to_wstring(LLWeb::escapeURL(unescaped_text));
else // human-readable location
text_to_copy = utf8str_to_wstring(unescaped_text);
gClipboard.copyFromString( text_to_copy );
}
示例7: stripChannelNumber
void LLChatBar::sendChat( EChatType type )
{
if (mInputEditor)
{
LLWString text = mInputEditor->getConvertedText();
if (!text.empty())
{
// store sent line in history, duplicates will get filtered
if (mInputEditor) mInputEditor->updateHistory();
// Check if this is destined for another channel
S32 channel = mChanCtrlEnabled ? (S32)(mChannelControl->get()) : 0;
stripChannelNumber(text, &channel);
std::string utf8text = wstring_to_utf8str(text);
// Try to trigger a gesture, if not chat to a script.
std::string utf8_revised_text;
if (0 == channel)
{
// discard returned "found" boolean
gGestureManager.triggerAndReviseString(utf8text, &utf8_revised_text);
}
else
{
utf8_revised_text = utf8text;
}
utf8_revised_text = utf8str_trim(utf8_revised_text);
if (!utf8_revised_text.empty())
{
// Chat with animation
sendChatFromViewer(utf8_revised_text, type, TRUE);
}
}
}
childSetValue("Chat Editor", LLStringUtil::null);
gAgent.stopTyping();
// If the user wants to stop chatting on hitting return, lose focus
// and go out of chat mode.
if (gChatBar == this && gSavedSettings.getBOOL("CloseChatOnReturn"))
{
stopChat();
}
}
示例8: if
bool GrowlManager::onLLNotification(const LLSD& notice)
{
if(notice["sigtype"].asString() != "add")
return false;
LLNotificationPtr notification = LLNotifications::instance().find(notice["id"].asUUID());
std::string name = notification->getName();
LLSD substitutions = notification->getSubstitutions();
if(gGrowlManager->mNotifications.find(name) != gGrowlManager->mNotifications.end())
{
GrowlNotification* growl_notification = &gGrowlManager->mNotifications[name];
std::string body = "";
std::string title = "";
if(growl_notification->useDefaultTextForTitle)
title = notification->getMessage();
else if(growl_notification->growlTitle != "")
{
title = growl_notification->growlTitle;
LLStringUtil::format(title, substitutions);
}
if(growl_notification->useDefaultTextForBody)
body = notification->getMessage();
else if(growl_notification->growlBody != "")
{
body = growl_notification->growlBody;
LLStringUtil::format(body, substitutions);
}
//TM:FS no need to log whats sent to growl
//LL_INFOS("GrowlLLNotification") << "Notice: " << title << ": " << body << LL_ENDL;
if(name == "ObjectGiveItem" || name == "ObjectGiveItemUnknownUser" || name == "UserGiveItem" || name == "SystemMessageTip")
{
LLUrlMatch urlMatch;
LLWString newLine = utf8str_to_wstring(body);
LLWString workLine = utf8str_to_wstring(body);
while (LLUrlRegistry::instance().findUrl(workLine, urlMatch) && !urlMatch.getUrl().empty())
{
LLWStringUtil::replaceString(newLine, utf8str_to_wstring(urlMatch.getUrl()), utf8str_to_wstring(urlMatch.getLabel()));
// Remove the URL from the work line so we don't end in a loop in case of regular URLs!
// findUrl will always return the very first URL in a string
workLine = workLine.erase(0, urlMatch.getEnd() + 1);
}
body = wstring_to_utf8str(newLine);
}
gGrowlManager->notify(title, body, growl_notification->growlName);
}
return false;
}
示例9: wstring_to_utf8str
void LLFloaterIMPanel::sendMsg()
{
if (!gAgent.isGodlike()
&& (mDialog == IM_NOTHING_SPECIAL)
&& mOtherParticipantUUID.isNull())
{
llinfos << "Cannot send IM to everyone unless you're a god." << llendl;
return;
}
if (mInputEditor)
{
LLWString text = mInputEditor->getConvertedText();
if(!text.empty())
{
// store sent line in history, duplicates will get filtered
if (mInputEditor) mInputEditor->updateHistory();
// Truncate and convert to UTF8 for transport
std::string utf8_text = wstring_to_utf8str(text);
utf8_text = utf8str_truncate(utf8_text, MAX_MSG_BUF_SIZE - 1);
if ( mSessionInitialized )
{
LLIMModel::sendMessage(utf8_text,
mSessionUUID,
mOtherParticipantUUID,
mDialog);
}
else
{
//queue up the message to send once the session is
//initialized
mQueuedMsgsForInit.append(utf8_text);
}
}
LLViewerStats::getInstance()->incStat(LLViewerStats::ST_IM_COUNT);
mInputEditor->setText(LLStringUtil::null);
}
// Don't need to actually send the typing stop message, the other
// client will infer it from receiving the message.
mTyping = FALSE;
mSentTypingState = TRUE;
}
示例10: handleUnicodeCharHere
bool LLViewerMediaImpl::handleUnicodeCharHere(llwchar uni_char)
{
bool result = false;
if (mMediaSource)
{
// only accept 'printable' characters, sigh...
if (uni_char >= 32 // discard 'control' characters
&& uni_char != 127) // SDL thinks this is 'delete' - yuck.
{
LLSD native_key_data;
mMediaSource->textInput(wstring_to_utf8str(LLWString(1, uni_char)), gKeyboard->currentMask(FALSE), native_key_data);
}
}
return result;
}
示例11: utf8str_to_wstring
void LLTextBox::setWrappedText(const LLStringExplicit& in_text, F32 max_width)
{
if (max_width < 0.0)
{
max_width = (F32)getRect().getWidth();
}
LLWString wtext = utf8str_to_wstring(in_text);
LLWString final_wtext;
LLWString::size_type cur = 0;;
LLWString::size_type len = wtext.size();
while (cur < len)
{
LLWString::size_type end = wtext.find('\n', cur);
if (end == LLWString::npos)
{
end = len;
}
LLWString::size_type runLen = end - cur;
if (runLen > 0)
{
LLWString run(wtext, cur, runLen);
LLWString::size_type useLen =
mFontGL->maxDrawableChars(run.c_str(), max_width, runLen, TRUE);
final_wtext.append(wtext, cur, useLen);
cur += useLen;
}
if (cur < len)
{
if (wtext[cur] == '\n')
{
cur += 1;
}
final_wtext += '\n';
}
}
std::string final_text = wstring_to_utf8str(final_wtext);
setText(final_text);
}
示例12: apply
void LLPanelEmerald::apply()
{
LLTextEditor* im = sInstance->getChild<LLTextEditor>("im_response");
LLWString im_response;
if (im) im_response = im->getWText();
LLWStringUtil::replaceTabsWithSpaces(im_response, 4);
LLWStringUtil::replaceChar(im_response, '\n', '^');
LLWStringUtil::replaceChar(im_response, ' ', '%');
glggHunSpell->setNewHighlightSetting(gSavedSettings.getBOOL("EmeraldSpellDisplay"));
gSavedPerAccountSettings.setString("EmeraldInstantMessageResponse", std::string(wstring_to_utf8str(im_response)));
//gSavedPerAccountSettings.setString(
gSavedPerAccountSettings.setBOOL("EmeraldInstantMessageResponseMuted", childGetValue("EmeraldInstantMessageResponseMuted").asBoolean());
gSavedPerAccountSettings.setBOOL("EmeraldInstantMessageResponseFriends", childGetValue("EmeraldInstantMessageResponseFriends").asBoolean());
gSavedPerAccountSettings.setBOOL("EmeraldInstantMessageResponseMuted", childGetValue("EmeraldInstantMessageResponseMuted").asBoolean());
gSavedPerAccountSettings.setBOOL("EmeraldInstantMessageResponseAnyone", childGetValue("EmeraldInstantMessageResponseAnyone").asBoolean());
gSavedPerAccountSettings.setBOOL("EmeraldInstantMessageShowResponded", childGetValue("EmeraldInstantMessageShowResponded").asBoolean());
gSavedPerAccountSettings.setBOOL("EmeraldInstantMessageShowOnTyping", childGetValue("EmeraldInstantMessageShowOnTyping").asBoolean());
gSavedPerAccountSettings.setBOOL("EmeraldInstantMessageResponseRepeat", childGetValue("EmeraldInstantMessageResponseRepeat").asBoolean());
gSavedPerAccountSettings.setBOOL("EmeraldInstantMessageResponseItem", childGetValue("EmeraldInstantMessageResponseItem").asBoolean());
gSavedPerAccountSettings.setBOOL("EmeraldInstantMessageAnnounceIncoming", childGetValue("EmeraldInstantMessageAnnounceIncoming").asBoolean());
gSavedPerAccountSettings.setBOOL("EmeraldInstantMessageAnnounceStealFocus", childGetValue("EmeraldInstantMessageAnnounceStealFocus").asBoolean());
if(((gSavedSettings.getU32("RenderQualityPerformance")>=3) && gSavedSettings.getBOOL("WindLightUseAtmosShaders") && gSavedSettings.getBOOL("VertexShaderEnable")) && childGetValue("EmeraldShadowsON").asBoolean())
{
gSavedSettings.setBOOL("RenderUseFBO", childGetValue("EmeraldShadowsON").asBoolean());
gSavedSettings.setBOOL("RenderDeferred", childGetValue("EmeraldShadowsON").asBoolean());
}
else if(!childGetValue("EmeraldShadowsON").asBoolean())
{
if(gSavedSettings.getBOOL("RenderDeferred"))
{
gSavedSettings.setBOOL("RenderDeferred", childGetValue("EmeraldShadowsON").asBoolean());
gSavedSettings.setBOOL("RenderUseFBO", childGetValue("EmeraldShadowsON").asBoolean());
}
}
else if(((gSavedSettings.getU32("RenderQualityPerformance")<3) && !gSavedSettings.getBOOL("WindLightUseAtmosShaders") && !gSavedSettings.getBOOL("VertexShaderEnable")) && childGetValue("EmeraldShadowsON").asBoolean())
{
childSetValue("EmeraldShadowsON",false);
LLNotifications::instance().add("NoShadows");
llwarns<<"Attempt to enable shadow rendering while graphics settings not on ultra!"<<llendl;
}
gSavedSettings.setBOOL("EmeraldShadowsToggle", childGetValue("EmeraldShadowsON").asBoolean());
gSavedSettings.setU32("EmeraldUseOTR", (U32)childGetValue("EmeraldUseOTR").asReal());
gLggBeamMaps.forceUpdate();
}
示例13: wstring_to_utf8str
void LLIMFloater::sendMsg()
{
if (!gAgent.isGodlike()
&& (mDialog == IM_NOTHING_SPECIAL)
&& mOtherParticipantUUID.isNull())
{
llinfos << "Cannot send IM to everyone unless you're a god." << llendl;
return;
}
if (mInputEditor)
{
LLWString text = mInputEditor->getConvertedText();
if(!text.empty())
{
// Truncate and convert to UTF8 for transport
std::string utf8_text = wstring_to_utf8str(text);
utf8_text = utf8str_truncate(utf8_text, MAX_MSG_BUF_SIZE - 1);
if (mSessionInitialized)
{
LLIMModel::sendMessage(utf8_text, mSessionID,
mOtherParticipantUUID,mDialog);
}
else
{
//queue up the message to send once the session is initialized
mQueuedMsgsForInit.append(utf8_text);
}
mInputEditor->setText(LLStringUtil::null);
updateMessages();
}
else if (gSavedSettings.getBOOL("CloseIMOnEmptyReturn"))
{
// Close if we're the child of a floater
closeFloater();
}
}
}
示例14: wstring_to_utf8str
void DOHexEditor::paste()
{
if(!canPaste()) return;
std::string clipstr = wstring_to_utf8str(gClipboard.getPasteWString());
const char* clip = clipstr.c_str();
std::vector<U8> new_data;
if(mInData)
{
int len = strlen(clip);
for(int i = 0; (i + 1) < len; i += 2)
{
int c = 0;
if(sscanf(&(clip[i]), "%02X", &c) != 1) break;
new_data.push_back(U8(c));
}
}
else
{
int len = strlen(clip);
for(int i = 0; i < len; i++)
{
U8 c = 0;
if(sscanf(&(clip[i]), "%c", &c) != 1) break;
new_data.push_back(c);
}
}
U32 start = mCursorPos;
if(!mHasSelection)
insert(start, new_data, TRUE);
else
{
start = getProperSelectionStart();
overwrite(start, getProperSelectionEnd() - 1, new_data, TRUE);
}
moveCursor(start + new_data.size(), FALSE);
}
示例15: getWChar
std::string LLViewerTextEditor::getEmbeddedText()
{
#if 1
// New version (Version 2)
mEmbeddedItemList->copyUsedCharsToIndexed();
LLWString outtextw;
for (S32 i=0; i<(S32)getWText().size(); i++)
{
llwchar wch = getWChar(i);
if( wch >= FIRST_EMBEDDED_CHAR && wch <= LAST_EMBEDDED_CHAR )
{
S32 index = mEmbeddedItemList->getIndexFromEmbeddedChar(wch);
wch = FIRST_EMBEDDED_CHAR + index;
}
outtextw.push_back(wch);
}
std::string outtext = wstring_to_utf8str(outtextw);
return outtext;
#else
// Old version (Version 1)
mEmbeddedItemList->copyUsedCharsToIndexed();
std::string outtext;
for (S32 i=0; i<(S32)mWText.size(); i++)
{
llwchar wch = mWText[i];
if( wch >= FIRST_EMBEDDED_CHAR && wch <= LAST_EMBEDDED_CHAR )
{
S32 index = mEmbeddedItemList->getIndexFromEmbeddedChar(wch);
wch = 0x80 | index % 128;
}
else if (wch >= 0x80)
{
wch = LL_UNKNOWN_CHAR;
}
outtext.push_back((U8)wch);
}
return outtext;
#endif
}