一、wxWidgets wxString字符串

#include <wx/string.h>
#include <wx/crt.h>
#include <iostream>
#include <wx/intl.h>
using namespace std;

int main(int argc,char **argv)
{

    printf("\n\rlocale is %s",setlocale(LC_ALL,NULL));//必须加的,否则中文不会正常显示
    setlocale(LC_ALL, "");
//    setlocale(LC_ALL, "zh_CN.UTF-8");
//    setlocale(LC_ALL, "zh_CN.GBK");
//    setlocale(LC_ALL, "");
//    setlocale(LC_CTYPE, "");

    wxString str1 = wxT("Linux");
    wxString str2 = wxT("操作");
    wxString str3 = wxT("系统");

    wxString str = str1 + wxT(" ") + str2  + str3;

    printf("\n\rlocale is %s",setlocale(LC_ALL,NULL));
    wprintf("\n\r1.printf=" + str);
    wxPrintf("\n\r3.wxPrintf=%s" , str.ToStdWstring());
    wxPuts("\n\r4.wxPuts=" + str.ToStdWstring());//推荐用ToStdWstring,不出错。
    cout<<"\n\r5.cout="<<str<<endl;
    cout<<"\n\rSystemEncodingName="<<wxLocale::GetSystemEncodingName()<<endl;

    //包含函数测试
    if(str.Contains(_("Linux"))){
        wxPuts(_("字符串中包含了Linux"));
    }else{
        wxPuts(_("不包含!"));
    }

    //字符串长度
    long iCount = str.Len();
    wxPrintf("len = %lld\n",str.Len());
    wxPrintf("len = %zu\n",str.Len());
    wxPrintf("len = %lld\n",sizeof(str.Len()));

    //大小写
    wxPuts(str.MakeLower());
    wxPuts(str.MakeUpper());
    wxPuts(str.Lower());

    system("pause");//暂停

}
 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值