-1

Is there a way to make windows 7 to support 12000(UTF-32) code page or 1200(UTF-16) code page?

Mgetz
  • 5,108
  • 2
  • 33
  • 51
shaohu
  • 49
  • 1
  • What is the problem? Why do you think reason of this problem is OS configuration? – Ilya Nov 20 '13 at 11:39
  • as far as MS is concerned all forms of Unicode are the same and are not ANSI code pages, they choose to use the UTF-16 encoding for their APIs and have no plans to support anything else at this time. – Mgetz Nov 20 '13 at 13:00

1 Answers1

1

No. Those codepages cannot be set as the current MBCS codepage. (That is, the codepage used by the "ANSI" API, such as Windows functions named with a terminal A such as CreateWindowA, or the codepage used by a C locale in the C or C++ runtime).

  • UTF-32 cannot be supported because windows MBCS codepage support only allows characters which occupy either one or two bytes.

  • UTF-16 cannot be supported for the same reason - characters outside the BMP require four bytes to represent.

  • In addition, UTF-8 is not supported, because again some characters require four bytes to represent.

You can use UTF-16 (Little-endian variety) natively by using the UNICODE API (that is the W variants e.g. CreateWindowW, and the wide-char C and C++ library functions). In addition, you can use MultiByteToWideChar and WideCharToMultiByte to convert between UTF-32, UTF-8, UTF-16BE and UTF-16LE.

If you are writing a windows-only program, you should use only the UNICODE API. If you are writing a program for the C runtime which you wish to make portable, you may wish to build a UNICODE version for windows and a UTF-8 version for Unix/Linux.

Ben
  • 34,935
  • 6
  • 74
  • 113
  • a set of simple `widen` and `narrow` conversion functions is quite easy to achieve using `std::codecvt_utf8_utf16` and `std::wstring_convert`, I've been using those together for a UTF-8 wrapper of WIN32 I've been in the process of writing. – Mgetz Nov 20 '13 at 12:58
  • @Mgetz you can even write simple wrappers using the Win32 API `MultiByteToWideChar` and `WideCharToMultiByte` functions. – rubenvb Nov 20 '13 at 13:19
  • @Mgetz, indeed I have used such wrappers I wrote myself, and also the ones like A2W found here http://msdn.microsoft.com/en-us/library/87zae4a3(v=vs.90).aspx ... Based on those it is easy to write a U82W W2U8 macro etc. – Ben Nov 20 '13 at 13:22
  • @rubenvb you can... but those are actually much heavier weight than the way I'm doing it, also that method requires allocating temporary buffers explicitly most of which don't need to be at all. – Mgetz Nov 20 '13 at 13:23
  • `MultiByteToWideChar()` and `WideCharToMultiByte()` do not support UTF-16 input/output, respectively (codepage 1200 for LE, 1201 for BE), or UTF-32 conversions at all (codepage 12000 for LE, 12001 for BE). They do support UTF-8, though. – Remy Lebeau Mar 14 '15 at 22:39