The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,224 other subscribers

Archive for June 20th, 2017

How can I get the default code page for a locale? – The Old New Thing

Posted by jpluimers on 2017/06/20

Ask GetLocaleInfo (example function GetAnsiCodePageForLocale included): [WayBackHow can I get the default code page for a locale? – The Old New Thing

UINT GetAnsiCodePageForLocale(LCID lcid)
{
  UINT acp;
  int sizeInChars = sizeof(acp) / sizeof(TCHAR);
  if (GetLocaleInfo(lcid,
                    LOCALE_IDEFAULTANSICODEPAGE |
                    LOCALE_RETURN_NUMBER,
                    reinterpret_cast<LPTSTR>(&acp),
                    sizeInChars) != sizeInChars) {
    // Oops - something went wrong
  }
  return acp;
}

And even though you didn’t ask, you can use LOCALE_IDEFAULT­CODE­PAGE to get the OEM code page for a locale.

Bonus gotchaThere are a number of locales that are Unicode-only. If you ask the Get­Locale­Info function and ask for their ANSI and OEM code pages, the answer is “Um, I don’t have one.” (You get zero back.)

Related:

–jeroen

Posted in Development, Encoding, internatiolanization (i18n) and localization (l10), Software Development, The Old New Thing, Windows Development, Windows-1252 | 2 Comments »

Mac OS X – need to research this one day: How do I Check DHCP Lease info in terminal – via Ars Technica OpenForum

Posted by jpluimers on 2017/06/20

One day I need to research how to get the conversions right for this: How do I Check DHCP Lease info in terminal – Ars Technica OpenForum as I think that ipconfig getoption en0 lease_time gives me the value in a different format than date -r expects.

Also:

At T1 seconds (typically set to 0.5*lease_time) after the last successful renewal, the DHCP client attempts to renew it’s lease with the DHCP server that granted it’s current address via unicast. If unsuccessful, at T2 seconds (typically set to 0.875*lease_time) after the last renewal, the DHCP client attempts to rebind with any DHCP server via multicast.

–jeroen

Posted in Apple, bash, Development, Mac, Mac OS X / OS X / MacOS, OS X 10.10 Yosemite, OS X 10.11 El Capitan, OS X 10.9 Mavericks, Power User, Scripting, Software Development | Leave a Comment »

 
%d bloggers like this: