I'm trying to make some String processing routines compatible with newest delphi version. I'm using Delphi2005 and 2007 but I'm not totally sure of the compatibility.
Here are a few samples, are they compatible with both the old and the new string type ? ( I'll use an imaginary STRING_UNICODE directive ).
a Type definition:
{$IFNDEF UNICODE_STRING} TextBuffer = Array[0..13] Of Char; {$ELSE} TextBuffer = Array[0..13] Of WideChar; {$ENDIF}
Useless or not? Is the Char type (becomes what was) a WideChar before the Unicode String, or is there still a difference?
a Function:
Function RemoveBlanks(Text: String): String; Var i: integer; Begin result := ''; For i:= 0 To Length(Text) Do Begin {$IFNDEF UNICODE_STRING} If Byte(Text[i]) < 21 Then Continue; {$ELSE} If Word(Text[i]) < 21 Then Continue; {$ENDIF} If Text[i] = ' ' Then Continue; Result := Result + Text[i]; End;
Is the Word() casting OK?
Here there is also the
' '
problem. How is the space handled in Unicode version? Should I also use the directive to differentiate' '
and' '
or will the' '
be automatically handled as a 2-byte blank?a line jump:
NewLineBegin := CanReadText( aPTextBuffer, #13#10 );
How is the the second argument (
#13#10
) interpreted in the Unicode version? Is it compatible? Will it be translated to the byte block00130010
? If not, then should the directive be used instead with the constant#0013#0010
?