title: SetThreadLocale for the entire Delphi application
body: <p>My Delphi (XE 10) program uses nonunicode (single byte) legacy Firebird database (character set NONE) and therefore its data (that are read from or saved into database) depends on the windows Locale for the nonunicode programs. Depending on this Windows setting the same database character can be displayed in the program as \u0101 (that is correct) or \u0432 (that is not correct). IBX serves as DB access technology.</p>
  
  <p>My program works only for the specificed local for nonunicode programs and that is acceptable for the client. The question is - <strong>how can I make program to feel the specific predefined locale regardless of the Windows settings?</strong></p>
  
  <p>I guess that I should use <code>SetThreadLocale</code> for this. But <strong>where to put this call?</strong> Is it sufficient to call this function in the initialization section of the Main form or should I call it in the project source file (where application is initialized) or maybe I should call it in the initialization sections of each module?</p>
  
  <p>Owing to comments I was made aware of <a href="https://stackoverflow.com/questions/1767946/getthreadlocale-returns-different-value-than-getuserdefaultlcid">GetThreadLocale returns different value than GetUserDefaultLCID?</a>
  I now see that I should write a bit more code:</p>
  
  <pre><code>SetThreadLocale(my_preferred_locale_id); 
  SysLocale.DefaultLCID := my_preferred_locale_id; 
  GetFormatSettings;
  </code></pre>
  
  <p>But the main question still remains - where to put this code - should I put it into multiple places. I have WebSnap application and I guess that it can have automatic and complex tread management under the hood. Where code should go?</p>
  
  <p>Nothing helps:</p>
  
  <ul>
  <li>adding lc_ctype=WIN1257 to TIBDatabase.Params</li>
  <li>setting SetThreadLocale... here, there and everywhere</li>
  <li>setting Project Options - Version Info - Language - Locale ID</li>
  </ul>
  
  <p><a href="https://github.com/xupefei/Locale-Emulator" rel="nofollow noreferrer">https://github.com/xupefei/Locale-Emulator</a> Locale Emulator is the only tool that solves the problem but why Delphi does not allow to do this without external tool?</p>