[fpc-devel] XML Components

Hans-Peter Diettrich DrDiettrich1 at aol.com
Sun Nov 4 06:19:16 CET 2012


Andrew Brunner schrieb:
> I just added this Prepare method to my database API.
> 
> class function XML.IsInvalid(var Value:Byte):boolean;
> begin
>   Result:=(Value<9) or (Value=11) or (Value=12) or ( (Value>13) and 
> (Value<32));
> end;
[...]

> The question is, what is going to happen when the encoding is UTF8 or 
> UTF16?  Will this code allow bytes to go by without messing them all up?

The control characters, precisely the full ASCII character set, has the 
same char values in *every* Unicode encoding. In UTF-8 encoding the 
escape sequences have bytes all above 127, no confusion possible with 
control characters.

In UTF-16 encoding you'll have problems when converting an WideString or 
UnicodeString into an AnsiString. I'd suggest that you use the 
predefined DOM string and char types, which IMO currently are 
WideString/WideChar.

DoDi




More information about the fpc-devel mailing list