Difference between revisions of "Talk:Character and string types"
From Lazarus wiki
Jump to navigationJump to searchJwdietrich (talk | contribs) |
(false statement in "Array_of_Char" ?) |
||
Line 12: | Line 12: | ||
::: Thanks for your positive feedback. In fact, it is ANSI. Although the official Free Pascal documentation states that a char contains an ASCII character, is is stored as a byte to use extended ASCII or ANSI. | ::: Thanks for your positive feedback. In fact, it is ANSI. Although the official Free Pascal documentation states that a char contains an ASCII character, is is stored as a byte to use extended ASCII or ANSI. | ||
::: --[[User:Jwdietrich|Jwdietrich]] 16:55, 28 December 2013 (CET) | ::: --[[User:Jwdietrich|Jwdietrich]] 16:55, 28 December 2013 (CET) | ||
+ | |||
+ | |||
+ | Is the sentence in [[Character_and_string_types#Array_of_Char]], ''delivers: a b c d #0 since arrays are filled with null-bytes in Free Pascal'' correct?! | ||
+ | |||
+ | I've tested (Lazarus 1.2.2 r44758 FPC 2.6.4 i386-win32-win32/win64 and Lazarus 1.3 r45097M FPC 2.7.1 i386-win32-win32/win64 on Win7) | ||
+ | <source> | ||
+ | procedure TForm1.Button1Click(Sender: TObject); | ||
+ | type | ||
+ | TOldString4 = array[0..4] of char; | ||
+ | var | ||
+ | aOldString4: TOldString4; | ||
+ | begin | ||
+ | aOldString4[0] := 'a'; | ||
+ | aOldString4[1] := 'b'; | ||
+ | aOldString4[2] := 'c'; | ||
+ | aOldString4[3] := 'd'; | ||
+ | writeln('['+aOldString4[4]+']'); | ||
+ | Caption:=IntToStr(ord(aOldString4[4])); | ||
+ | end; | ||
+ | </source> | ||
+ | |||
+ | I got different results, but not #0 for ''aOldString4[4]''. So, do I have to update the facts or do I missunderstood the statement? | ||
+ | |||
+ | Thanks --[[User:Michl|Michl]] 23:10, 1 June 2014 (CEST) |
Revision as of 23:10, 1 June 2014
Doesn't ANSIChar contain an ANSI character instead of ASCII? I.e. it is codepage dependent but can contain byte values 0..255?
--BigChimp 15:28, 28 December 2013 (CET)
- This is the information of the official FPC documentation. I will do additional research.
- --Jwdietrich 15:33, 28 December 2013 (CET)
- Yes, I suspect the official FPC documentation is wrong/incomplete ;)
- BTW: thanks for writing this page - it's very helpful!
- --BigChimp 16:53, 28 December 2013 (CET)
- Thanks for your positive feedback. In fact, it is ANSI. Although the official Free Pascal documentation states that a char contains an ASCII character, is is stored as a byte to use extended ASCII or ANSI.
- --Jwdietrich 16:55, 28 December 2013 (CET)
Is the sentence in Character_and_string_types#Array_of_Char, delivers: a b c d #0 since arrays are filled with null-bytes in Free Pascal correct?!
I've tested (Lazarus 1.2.2 r44758 FPC 2.6.4 i386-win32-win32/win64 and Lazarus 1.3 r45097M FPC 2.7.1 i386-win32-win32/win64 on Win7)
procedure TForm1.Button1Click(Sender: TObject);
type
TOldString4 = array[0..4] of char;
var
aOldString4: TOldString4;
begin
aOldString4[0] := 'a';
aOldString4[1] := 'b';
aOldString4[2] := 'c';
aOldString4[3] := 'd';
writeln('['+aOldString4[4]+']');
Caption:=IntToStr(ord(aOldString4[4]));
end;
I got different results, but not #0 for aOldString4[4]. So, do I have to update the facts or do I missunderstood the statement?
Thanks --Michl 23:10, 1 June 2014 (CEST)