win_lcid.cpp 966 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright 2013 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #include <windows.h>
  8. #include <stdio.h>
  9. #define BUFFER_SIZE 512
  10. BOOL CALLBACK MyFuncLocaleEx(LPWSTR pStr, DWORD dwFlags, LPARAM lparam) {
  11. WCHAR wcBuffer[BUFFER_SIZE];
  12. int bufferSize;
  13. bufferSize = GetLocaleInfoEx(pStr, LOCALE_SENGLANGUAGE, wcBuffer, BUFFER_SIZE);
  14. if (bufferSize == 0) {
  15. wprintf(L"Locale %s had error %d\n", pStr, GetLastError());
  16. return (TRUE);
  17. }
  18. LCID lcid = LocaleNameToLCID(pStr, nullptr);
  19. if (lcid == 0) {
  20. wprintf(L"Error %d getting LCID\n", GetLastError());
  21. return (TRUE);
  22. }
  23. if (lcid > 0x8000) {
  24. wprintf(L"//");
  25. }
  26. wprintf(L" { 0x%.4x, \"%s\" }, //%s\n", lcid, pStr, wcBuffer);
  27. return (TRUE);
  28. }
  29. int main(int argc, wchar_t* argv[]) {
  30. EnumSystemLocalesEx(MyFuncLocaleEx, LOCALE_ALL, nullptr, nullptr);
  31. }