[fpc-devel] Unicode functions

Graeme Geldenhuys graemeg.lists at gmail.com
Tue Aug 26 09:26:23 CEST 2008


On Tue, Aug 26, 2008 at 9:19 AM, Graeme Geldenhuys
<graemeg.lists at gmail.com> wrote:
> project. Maybe we could use something there - it's written in Object
> Pascal as well? The LPTK project used a BSD license.

I had a quick look at the LPTK project source...  So I gather this
implementations is totally rubbish?  First of all, a Unicode char is
defined as a word (2 bytes), so that means it's only UCS2 compliant
and not full Unicode UTF-16 (which is what we want).  Plus, it uses no
lookup tables as far as I can see - frankly, I don't understand the
code at all. :-)


function UpCase16(const s : string16) : string16;
begin
  if length(s) < 2 then Exit;
  if s[2] = #0 then Result := UpCase(s[1])+#0
  else
  begin
    result := chr(ord(s[1]) and $FE) + s[2];
  end;
end;


function Upper16(const s : string16) : string16;
var
  n : integer;
begin
  result := '';
  for n := 1 to length16(s) do
  begin
    result := result + UpCase16(s[n*2-1]+s[n*2]);
  end;
end;



Regards,
 - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-devel mailing list