<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<br>
<blockquote type="cite"
cite="mid:9ab68d30-a52d-9a9a-ddf8-d24b37bd9db8@googlemail.com">
<blockquote type="cite">Hi *,
<br>
<br>
I would like to have source file in Windows-1250 encoding, where
are stored literal strings like 'áéíóčž' in Windows-1250
encoding (I share this one file between FPC/Lazarus and Delphi
7). Windows-1250 is also ANSI code page of my Windows OS. In
source file I have:
<br>
<br>
{$IFDEF FPC}
<br>
{$CODEPAGE cp1250}
<br>
{$ENDIF}
<br>
</blockquote>
A pure string constant will still have CP_ACP as code page (which
in Lazarus will by default mean UTF-8) also when you declare it as
a typed String constant. The $CodePage directive will only
influence the binary encoding of the string. </blockquote>
<p><b>and probably this is something non intuitive for me. Also
after reading
<a class="moz-txt-link-freetext" href="https://wiki.freepascal.org/FPC_Unicode_support#String_constants">https://wiki.freepascal.org/FPC_Unicode_support#String_constants</a>
it is hard to understand for me. After reading "The compiler has
to know the code page according to which it should interpret
string constants, as it may have to convert them at compile
time." my expectation is, that when I explicitly define encoding
of source file by using </b><b>{$CODEPAGE cp1250} then compiler
will be aware of string encoding in that file and will handle it
appropriate. Now it works in another way which is not clear to
me ... can it be better explained in wiki (any example)?</b></p>
<p><b><br>
</b></p>
<blockquote type="cite"
cite="mid:9ab68d30-a52d-9a9a-ddf8-d24b37bd9db8@googlemail.com">What
you need to do is the following:
<br>
<br>
type
<br>
String1250 = type String(1250);
<br>
<br>
const
<br>
MyString: String1250 = 'áéíóčž';
<br>
<br>
This way the string itself will have code page 1250 and if you
assign to a normal String or a UnicodeString the compiler will
insert the appropriate conversions.
<br>
</blockquote>
<p><b>yes, this I can understand, but it will not work in Delphi 7
...</b></p>
<p><b>TIA</b></p>
<p><b>L.</b></p>
<br>
</body>
</html>