linux控制台显示中文
时间:2024-04-20 05:12:58 点击:188

  #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常量只能用{}.

展开 ↓

最新游戏更多

最新软件更多

  • 玩家推荐
  • 游戏攻略

峰溢下载站 Copyright(C) 2008- ytdonghua.net All Rights Reserved!

闽ICP备2023006282号-2| 免责声明