中文翻譯韓文

 

馬賽克

bool WordFilter(  const std::wstring &Input翻譯社 std::wstring &Output, 
 const std::wstring &ReplaceString )
{
bool bHasReplaced = false;
std::wstring::size_type uPos = 0;
std::wstring wsInputString = Input

if ( wsInputString.size() != 0 && m_vFilteredWord.size() != 0 )
{
std::vector::iterator it;
for (it = m_vFilteredWord.begin(); it != m_vFilteredWord.end(); it++)
{
if ( wsInputString.length() >= (*it).length() )
{
uPos = wsInputString.find(*it);
while ( uPos != std::wstring::npos )
{
wsInputString.replace(  uPos, (*it).length(), 
ReplaceString );
uPos = wsInputString.find(*it);

if ( !bHasReplaced )
bHasReplaced = true;
}
}
}
}
if ( bHasReplaced )
{
Output.assign( wsInputString );
}
return bHasReplaced;
}

 

  根基上,只要事前準備一份需要過濾的文字檔案,就可以使用上面的方法了。在有需要過濾的字眼泛起時會回傳 true ,不然回傳 false 。

  一起頭的輸入參數依序為:玩家輸入的字串,替代後的字串,準備拿來替代過濾字眼的字串,在函式裡的 m_vFilteredWord 是一入手下手就要建樹好的需要被過濾的文字 vector ( std::vector<std::wstring> )。

  底下就是一段能把需要過濾的文字替代掉的一個函式:

  一般網路遊戲為了不讓玩家說一些敏感話題,或是避免玩家罵髒話讓他人感應不悅,亦或是假裝遊戲治理者進行詐騙,都邑把許多字元設定成需要過濾的文字翻譯



本篇文章引用自此: http://marsray.pixnet.net/blog/post/50303476-%5Bc%2B%2B%5D-%E4%B8%80%E8%88%AC%E7%B6%B2%E8%B7%AF%E9%8有關各國語文翻譯公證的問題歡迎諮詢天成翻譯公司02-77260931

arrow
arrow
    文章標籤
    翻譯社
    全站熱搜
    創作者介紹
    創作者 rodriqpn8jb 的頭像
    rodriqpn8jb

    rodriqpn8jb@outlook.com

    rodriqpn8jb 發表在 痞客邦 留言(0) 人氣()