string UTF8s[7] = {"石","墨","全","硬","司","筒","女"};/*会出现乱码的文字(不齐全)*/
/*判断是否有会出现乱码的文字*/
bool isUseUTF8Text(string str)
{
for (int i = 0; i < 7; ++i)
if (strstr(str.c_str(), UTF8s[i].c_str()))
return true;
return false;
}
int main()
{
//从node中获取某些中文会出现乱码
string n_value_param = node->GetColumnDisplayText(2).getLocaleText();
if (isUseUTF8Text(node->GetColumnDisplayText(2).GetUTF8Text()))
n_value_param = node->GetColumnDisplayText(2).GetUTF8Text();//存在乱码文字时,使用GetUTF8Text()获取数据
//uc1601打印不出,用nxopen打印方式打印
//方法1(NXMessageBox)
NXMessageBox *mb = UI::GetUI()->NXMessageBox();
mb->Show("HelloTitle", NXOpen::NXMessageBox::DialogTypeInformation, n_value_param);
//方法2(ListingWindow)
NXOpen::Session *theSession = NXOpen::Session::GetSession();
ListingWindow *lw = theSession->ListingWindow();
lw->Open();
lw->WriteLine(n_value_param);
}
【UG\NX二次开发】从树列表节点获取文本,存在部分中文乱码(石墨司筒全硬女)
于 2024-01-24 19:15:31 首次发布