String EncodeToString(String strEncode)
{
wchar_t w;
WideString strResult;
strEncode = StringReplace(strEncode, "\\u", "\r\n0x", TReplaceFlags() << rfReplaceAll);
TStringList *lst = new TStringList;
lst->Text = strEncode;
for (int i = 0; i < lst->Count; i++)
{
if (lst->Strings[i].Trim().Length() > 0)
{
w = lst->Strings[i].ToIntDef(0);
strResult += WideString(w);
}
}
delete lst;
return String(strResult);
}
测试:
C/C++ code
?
1
2
3
4
String str = "{\"name\":\"\\u52c7\\u4e0d\\u53ef\\u6321\"";
String reinfo = FXsrc(str, "\"name\":\"", NULL, "\"", 0);
Caption = EncodeToString(reinfo);