Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>AFAIK <code>SetThreadLocale</code> does not change the current system Code Page, so won't affect the <code>widestring</code> to <code>ansistring</code> conversion in Delphi 7, which rely on <code>GetACP</code> API call, i.e. the system Code Page.</p> <p>The system Code Page is set e.g. in Windows Seven in the Control Panel, then Region Languages / Administrative tab / Code Page for non Unicode Applications. This needs a system restart.</p> <p>Delphi 7 uses this system Code Page, supplying 0 to all conversion API calls. So AFAIR <code>SetThreadLocale</code> won't affect the <code>widestring</code> to <code>ansistring</code> conversion in Delphi 7. It will change the locale (e.g. date/time and currency formatting), not the code page used by the system for its Ansi &lt;-> Unicode conversion.</p> <p>Newer versions of Delphi have a <code>SetMultiByteConversionCodePage()</code> function, able to set the code page to be used for all <code>AnsiString</code> handling. </p> <p>But API calls (i.e. all <code>....A()</code> functions in <em>Windows.pas</em> which are mapped by <code>...()</code> in Delphi 7) will use this system code page. So you will have to call the <code>...W()</code> wide API after a conversion to Unicode if you want to handle another code page. That is, the Delphi 7 VCL will work only with the system code page, not the value specified by <code>SetThreadLocale</code>.</p> <p>Under Delphi 7, my advice is:</p> <ul> <li>Use <code>WideString</code> everywhere, and specific "Wide" API calls - there are several set of components for Delphi 7 which handle <code>WideString</code>;</li> <li>Use your own types, with a dedicated charset, but you'll need an explicit conversion before using the VCL/RTL or "Ansi" API calls - e.g. <code>MyString = type AnsiString</code> (this is what we do in mORMot, by defining a custom <code>RawUTF8</code> type for internal UTF-8 process).</li> </ul> <p>This is much better handled with Delphi 2009 and up, since you can specify a code page to every <code>AnsiString</code> type, and properly handle conversion to/from Unicode, for API calls or VCL process.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload