Sign in Join
Wiki copytemporary

UTF8 Tools

Sent here from Theodp.

English · Русский

About

This code allows to process Unicode text and determine for unicode chars:

Also it has class to read/write Unicode from/to TStream.

Units

Using streams

Unit "charencstreams": load/save data from/to almost any text source:

Demo:

pascal
 f := TCharEncStream.Create;
 f.LoadFromFile(OpenDialog1.FileName);
 Memo1.Text := f.UTF8Text;  
 f.Free;

Character info

Unit "character": get information about code points using the TCharacter class. Demo:

pascal
 if TCharacter.IsLetter(s[i]) then
    s[i] := TCharacter.toLower(s[i]);

Access UTF-8 by code index

Unit "utf8scanner": access UTF-8 strings by code index, use case statements on UTF-8 strings and more. Demo:

pascal
 s := TUTF8Scanner.Create(Memo1.Text);
 for i := 1 to s.Length do
   if TCharacter.IsLetter(s[i]) then
     s[i] := TCharacter.toLower(s[i]);
 Memo1.Text := s.UTF8String;
 s.Free;

Case demo:

pascal
  s := TUTF8Scanner.Create(Memo1.Text);
  s.FindChars := 'öäü';
  repeat
    case s.FindIndex(s.Next) of
  {ö} 0: s.Replace('oe');
  {ä} 1: s.Replace('ae');
  {ü} 2: s.Replace('ue');
    end;
  until s.Done;
  Memo1.Text := s.UTF8String;
  s.Free;

Download

Download utf8tools.zip


From the Free Pascal wiki, page "UTF8 Tools", as it stood on 2018-12-12 after a change by Zoltanleo, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Edited on wiki.freepascal.org by 5 people, 2009–2018

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
TheodpNew page: = UTF-8 Tools = == Download == [http://www.theo.ch/lazarus/utf8tools.zip Donwload utf8tools.zip]
Theodp
TheodpUTF-8 Tools
TheodpUTF-8 Tools
TheodpPurpose
Theodp
TheodpUTF-8 Tools
TheodpUTF-8 Tools
TheodpUTF-8 Tools
TheodpPurpose
TheodpDownload
Rjbosch
AlextpAbout: text new
AlextpAbout (minor)
Alextpmoved Theodp to UTF8 Tools: name UTF8tools is from download name of file. old name strange. (minor)
AlextpText change
JwdietrichCategorization
Zoltanleo
Zoltanleo
Zoltanleo

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.