峰溢下载站:专为(Android)安卓手机用户量身打造的安卓游戏、APK游戏下载平台!
网站地图
你的位置: 首页 > 游戏资讯 > 操作系统

linux控制台显示中文

  • 2024-04-20 05:12:58
  • 来源:网络
  • 在手机上看

    扫一扫立即进入手机端

  #include

  #include

  #include

  int main()

  {

  #ifdef _WIN32

  setlocale(LC_ALL, “chs“);

  #else

  setlocale(LC_ALL, “zh_CN.UTF-8“);

  #endif

  wchar_t KZg[] = {0x6211, 0};

  char buf[10] = {0};

  wcstombs(buf,KZg,10);

  printf(“_%s_\n“,buf);

  }

  wchar_t 在linux上是4个字节, 在win32上是2个字节, MinGW也是2个字节.

  一般会节省空间使用utf-16.

  #ifdef _WIN32

  typedef wchar_t uchar;

  #else

  typedef unsigned short uchar; // 就不能使用string.h提供的宽字符串方法了.

  #endif

  linux上使用string常量只能用{}.

游戏推荐

linux控制台显示中文
更多

手机游戏排行榜