Graeme Geldenhuys schreef:
Thanks Marc,

It was a real informative explanation, and helped a lot.  Now lets see
if I understood it correctly. :-)

AnsiStrings are 1 byte wide and WideStrings are 2 byte wide. Fixed.
The delphi WideStrings are the same as used by MS in their Wide
functions, being UCS-2 initially. So all unicode chars would fit in
there (initially).

Now this brings me to another point which makes no sense! Naming
convertion of functions.
Lets look at the following RTL function as an example:

* StrPos is used for 1 byte (8 bit) ANSI strings.

* AnsiStrPos is used for multi-byte (or is that 2 bytes max) UTF-8
strings. aka WideString.

So why did Borland name it AnsiStrPos, when it doesn't operate on ANSI
strings!!  Why not name it Utf8StrPos or WideStrPos?  The prefix Ansi*
completely goes against what it does (operates on)! It doesn't work
with Ansi strings, but rather WideStrings.

I think you are still a bit confused. I am sure, but I think it is as follows.

UTF-8 strings are stored in ansistrings.
UTF-16 are stored in widestrings.

both UTF-8 and UTF-16 are unicode strings.



Now here is another piece of code - parts removed for the purpose of
simplicity. To protect the innocent, we will keep the author
anonymous. ;-)

The code below is a function that outputs Unicode or Ansi text to a canvas.
Is my assumtions about this code correct?

1... I assume that the String type, as used in the parameter "AText:
String", can hold ANSI or Unicode text. The function supports both,
but isn't sure what it is going to get.

2... The function Utf8ToUnicode tells me, that it is going to process
a String (AText) to Unicode using the UTF-8 algorithm.

3... The function Utf8ToAnsi tell me, that it is going to process a
String (AText) which might contain UTF-8 encoded text to 8-bit ANSI
text.

4... If this code only supported Unicode (UTF8), we could have defined
the parameter AText as UTF8String and remove the second part of the if
statement inside the function.

Is all this correct?

I don't know, but it contains the same bug as the snippet from Felipe on 
fpc-pascal:
http://lists.freepascal.org/lists/fpc-pascal/2006-October/012325.html


Regards,
Vincent

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to