GetConsoleOutputCP SetConsoleOutputCP

http://www.cplusplus.com/forum/windows/9797/


After a bit of googling I came across the following:

http://msdn.microsoft.com/en-us/library/ms686036(VS.85).aspx -- SetConsoleOutputCP
http://msdn.microsoft.com/en-us/library/dd317756(VS.85).aspx -- code page ids
http://msdn.microsoft.com/en-us/library/ms683169(VS.85).aspx -- GetConsoleOutputCP

I suppose the way to do this would be:

1
2
3
4
5
6
7
8
9
10
11
12
13
int main()
{
  UINT oldcodepage = GetConsoleOutputCP();
  SetConsoleOutputCP(65001);  // for UTF-8 ... or use ?1251? for cyrillic
    // -- there appear to
    //  be many different cyrillic options -- not sure which one is desired.
    // UTF-8, at least, is always consistent

  // ... output crap here

  SetConsoleOutputCP(oldcodepage);
  return 0;
}


UTF-8 is probably more easily portable, but then you have to make sure your text is UTF-8 encoded (and since cyrillic characters are multi-byte in UTF-8... things like std::string::length() and strlen() will return values higher than the actual number of characters).

Apparently you might also need to worry about SetConsoleCP, too for the input -- so you might have to look that up as well.

blech. Hope that works for you.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值