[DUG] D2009 Unicode String

John Bird johnkbird at paradise.net..nz
Wed Apr 22 18:31:16 NZST 2009


Unless I missed it I still didn't hear if anyone recorded the David I 
Codegear seminar in Ak on D2009.
Any recordings out there anywhere?

Failing that, a couple of questions that I am wondering about in terms of 
converting string code for D2009:

I understand that code such as

q1 -     if (string[i] > ' ')  and  (string[i] < '~')   then .......  should 
work no problem

q2 - how about code such as
     if (ord(string[i])  in [32..126]            ie finding if the ascii 
code is in a range.
                                                            from what I have 
read that should produce a compiler warning, and it
                                                            does jiggery 
pokery behind the scenes conversions to make it work
                                                            as set elements 
have to be < 256, recommended is to use new functions
                                                            to specify what 
you want - i am guessing something like:

    if CharInSet(string[i[, [' '..'~']) then

q3 -  if string[i] = #13  then                          //testing for CR 
carriage return - string[i] and #13 will both be WideChar,
                                                            //but is #13 the 
wrong value now?

        or eol := #13#10                            //where eol is a string

q4 - using TFilestream to read a file and putting the result into a string 
buffer

        eg
              fs.seek(byteoffset, soFromBeginning);
              sizeread := fs.read(chbuff, lreclen2);
              buffer := chbuff;
              setlength(buffer, lreclen2);

buffer is string, chBuff is an array of Char, and I suspect I may need to 
change the declaration of chBuff to be an array of AnsiChar for a start  (if 
I am reading ASCII files) and converting the array of AnsiChar to String or 
AnsiString will need some explicit code

q5 - are the .pas and .dfm files still stored as ascii or unicode text?   Or 
more to the point, can they be opened with Notepad or my favourite 
programmers editor.   I have a Delphi program to search .pas and .dfm 
files - will the same program be able to search D2007 (ascii) files and 
D2009 files  (it does a readln and then a AnsiPos to find matches)....

q6 - I read that as Win9x are NOT unicode, D2009 cannot produce applications 
for them.  If a program is written using AnsiString instead of string, will 
it run on Win9x?   or is it the VCL itself that is the problem??

I found some good references which I have been reading:

http://edn.embarcadero.com/article/38693
http://www.drbob42.com/examines/examinA7.htm

John 



More information about the Delphi mailing list