On 21 Oct 2008, at 17:37, Zaher Dirkey wrote:
Thanks for your answers, and just another few questions :)
1- Is "fpc .... -FcUTF-8" same as {$codepage utf-8}?
Yes.
2- If i put {$codepage utf-8} in my unit and i have string A variable,
that variable will be widestring and any ansistring assigned to it
will converted to it?
No, A will be a shortstring (in {$h-} mode) or ansistring (in {$h+}
mode). Only *constant* strings containing non-ASCII characters will be
converted into a widestring at compile time if a codepage is set, so
they can be converted to the current code page at run time (since ansi/
shortstrings are always supposed to be encoded using the current code
page, and this code page can vary from execution to execution).
3- if i has another unit with ansi text not UTF 8 and there is a B
variable in that unit, then i assigned to the A := B is B string
converted to widestring?.
No. All (ansi)strings are always supposed to be already encoded using
the current ansi encoding, so no conversion happens when assigning one
to another.
4- How can i show the content of string (Wide, Ansi) (save it to file
without any converting), is there any example.
uses
sysutils;
var
f: file;
s: string;
w: widestring;
begin
assign(f,'test.txt');
rewrite(f,1);
s:='abc'+sLineBreak;
w:='def'+sLineBreak;
blockwrite(f,s[1],length(s)*sizeof(s[1]));
blockwrite(f,w[1],length(w)*sizeof(w[1]));
close(f);
end.
Jonas
_______________________________________________
fpc-pascal maillist - [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal