{"id":112,"date":"2018-02-10T10:48:00","date_gmt":"2018-02-10T10:48:00","guid":{"rendered":"http:\/\/basicwebsitesolutions.com\/blog\/?p=112"},"modified":"2018-02-10T10:48:00","modified_gmt":"2018-02-10T10:48:00","slug":"delphi-set-system-locale-information","status":"publish","type":"post","link":"https:\/\/basicwebsitesolutions.com\/blog\/2018\/02\/10\/delphi-set-system-locale-information\/","title":{"rendered":"Delphi : Set system locale information"},"content":{"rendered":"<p>So far this is what i had dig up on the topic. It made sense to post this one here since i am pretty sure somebody&#8217;s also looking for this info. Hehehe<\/p>\n<p>Enjoy<\/p>\n<p>Coffee Cup<\/p>\n<p>procedure SetLocaleInfoSample;<br \/>\nvar number, ds, lz;<br \/>\nbegin<br \/>\nnumber := 0.7;<\/p>\n<p>\/\/ Remember default number settings<br \/>\nds := GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL);<br \/>\nlz := GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ILZERO);<\/p>\n<p>\/\/ Log a number using default settings<br \/>\nLog.Message( FloatToStr(number) );<\/p>\n<p>\/\/ Log a number using a different decimal separator<br \/>\nSetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, &#8216;,&#8217;);<br \/>\nLog.Message( FloatToStr(number) );<\/p>\n<p>\/\/ Log a number without the leading zero<br \/>\nSetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ILZERO, &#8216;0&#8217;);<br \/>\nLog.Message( FloatToStr(number) );<\/p>\n<p>\/\/ Restore original settings<br \/>\nSetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, ds);<br \/>\nSetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ILZERO, lz);<br \/>\nend;<\/p>\n<p>{<br \/>\nThe function produces the following output for US English locale:<\/p>\n<p>0.7<br \/>\n0,7<br \/>\n,7<br \/>\n}<\/p>\n<p>procedure ChangeShortDate;<br \/>\nvar strOldShortDate;<br \/>\nbegin<br \/>\n\/\/ Get current short date format<br \/>\nstrOldShortDate := GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE);<\/p>\n<p>if not SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, &#8216;yyyy\/MM\/dd&#8217;) then<br \/>\nLog.Error(&#8216;Could not change short date format.&#8217;);<\/p>\n<p>\/\/ Restore original short date format<br \/>\nif not SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, strOldShortDate) then<br \/>\nLog.Error(&#8216;Could not restore original short date format.&#8217;);<br \/>\nend;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So far this is what i had dig up on the topic. It made sense to post this one here since i am pretty sure somebody&#8217;s also looking for this info. Hehehe Enjoy Coffee Cup procedure SetLocaleInfoSample; var number, ds, lz; begin number := 0.7; \/\/ Remember default number settings ds := GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL); lz &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/basicwebsitesolutions.com\/blog\/2018\/02\/10\/delphi-set-system-locale-information\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Delphi : Set system locale information&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,1,2],"tags":[],"class_list":["post-112","post","type-post","status-publish","format-standard","hentry","category-delphi-and-interbase","category-life-as-a-programmer","category-windows-and-beyond"],"_links":{"self":[{"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/posts\/112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=112"}],"version-history":[{"count":2,"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/posts\/112\/revisions"}],"predecessor-version":[{"id":119,"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/posts\/112\/revisions\/119"}],"wp:attachment":[{"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}