Sign in Join
Wiki copytemporary

UTF8 Tools/ru

English · Русский

О пакете

Этот код позволяет обрабатывать текст Unicode и определять, [является ли] символ Unicode:

Также у него есть класс для чтения/записи Unicode из/в TStream (поток в памяти).

Модули

Использование потоков

Модуль "charencstreams": загружает/сохраняет данные практически из/в любого текстового источника:

Демо:

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

Информация о символе

Unit "character": get information about code points using the TCharacter class. Demo: Модуль "character": получает информацию о кодовых точках, используя класс TCharacter. Демо:

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

Доступ к UTF-8 по индексу кода

Модуль "utf8scanner": [осуществляет] доступ к строкам UTF-8 по индексу кода, использует операторы case в строках UTF-8 и многое другое. Демо:

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:

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 utf8tools.zip


From the Free Pascal wiki, page "UTF8 Tools/ru", as it stood on 2019-01-17 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 .

Talk about this page

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