img
00:00
imgDRKB online - RTF-->HTML
imgimgimg
  Общие вопросы
  Delphi IDE, компиллятор, отладчик, редактор
  Язык программирования Дельфи
  VCL
  Системные функции и WinAPI
  Базы данных
  Работа с файловой системой
  Репортинг, работа с принтером
  Работа с сетью, интернетом, протоколами
  Работа с графикой и мультимедиа
  Математика, алгоритмы
  Форматы файлов, данных. Конвертация форматов
  ANSI ---> ASCII
  BMP ---> AVI (для TAnimate)
  BMP ---> EMF
  BMP ---> DIB
  BMP ---> ICO
  BMP ---> JPG
  BMP --> EMF (Enhanced Metafile)
  BMP ---> RTF
  BMP ---> WMF
  CUR ---> BMP
  ICO ---> BMP
  JPG ---> BMP
  TIF ---> PDF
  TXT ---> GIF
  DOC ---> HTML
  WMF ---> BMP
  RTF-->HTML
  HTML --> RTF
  DFM -->TXT, TXT --> DFM
  Win1251 <-> Koi8r
  Как инсталлировать INF файл?
  Как конвертировать WideString в String?
  Как определить графический формат файла (не используя расширение)?
  Как прочитать MP3 ID3-Tag?
  Как прочитать заголовок wav файла?
  Информация о AVI файле (разбор заголовка AVI)
  Как работать с DWG файлами (AutoCAD)?
  Как работать с GIF файлами?
  Как работать с PDF файлами?
  Как разрезать wav файл?
  Как узнать размер картинки для JPG, GIF и PNG файлов?
  Компонент для работы с PCX файлами
  Пример работы чтения и сохранении wav-файлов
  Работа с TGA файлами
  Формат wave файла
  Декомпилляция звукового файла формата Wave и получение звуковых данных
  Flash SWF --> EXE
  Преобразование иконок в Gliph-ы
  Документация на основе RTF-шаблона
  "Дедушка RTF" еще послужит
  ActiveX, COM, DCOM, MIDAS, CORBA, интерфейсы, OLE, DDE
  Разработка приложений
  Kylix
  Delphi.Net
  Развлечения
  
  [drkb=3988] Комментариев: 0 
RTF-->HTML


Приведу программу, которую я использую для преобразования содержимого RichEdit в SGML-код. Она не формирует полный HTML-аналог, но вы сами можете добавить необходимый RTF-код и его интерпретацию в HTML-тэги.

Код содержит интуитивно понятные комментарии и строки на шведском языке, нецелесообразные для перевода.

delphi
function rtf2sgml(text: string): string;
{Funktion for att konvertera en RTF-rad till SGML-text.}
var
  temptext: string;
  start: integer;
begin
  text := stringreplaceall(text, '&', '##amp;');
  text := stringreplaceall(text, '##amp', '&amp');
  text := stringreplaceall(text, '\' + chr(39) + 'e5', '&aring;');
  text := stringreplaceall(text, '\' + chr(39) + 'c5', '&Aring;');
  text := stringreplaceall(text, '\' + chr(39) + 'e4', '&auml;');
  text := stringreplaceall(text, '\' + chr(39) + 'c4', '&Auml;');
  text := stringreplaceall(text, '\' + chr(39) + 'f6', '&ouml;');
  text := stringreplaceall(text, '\' + chr(39) + 'd6', '&Ouml;');
  text := stringreplaceall(text, '\' + chr(39) + 'e9', '&eacute;');
  text := stringreplaceall(text, '\' + chr(39) + 'c9', '&Eacute;');
  text := stringreplaceall(text, '\' + chr(39) + 'e1', '&aacute;');
  text := stringreplaceall(text, '\' + chr(39) + 'c1', '&Aacute;');
  text := stringreplaceall(text, '\' + chr(39) + 'e0', '&agrave;');
  text := stringreplaceall(text, '\' + chr(39) + 'c0', '&Agrave;');
  text := stringreplaceall(text, '\' + chr(39) + 'f2', '&ograve;');
  text := stringreplaceall(text, '\' + chr(39) + 'd2', '&Ograve;');
  text := stringreplaceall(text, '\' + chr(39) + 'fc', '&uuml;');
  text := stringreplaceall(text, '\' + chr(39) + 'dc', '&Uuml;');
  text := stringreplaceall(text, '\' + chr(39) + 'a3', '&#163;');
  text := stringreplaceall(text, '\}', '#]#');
  text := stringreplaceall(text, '\{', '#[#');
  text := stringreplaceall(text, '{\rtf1\ansi\deff0\deftab720', ''); {Skall alltid tas bort}
  text := stringreplaceall(text, '{\fonttbl', ''); {Skall alltid tas bort}
  text := stringreplaceall(text, '{\f0\fnil MS Sans Serif;}', ''); {Skall alltid tas bort}
  text := stringreplaceall(text, '{\f1\fnil\fcharset2 Symbol;}', ''); {Skall alltid tas bort}
  text := stringreplaceall(text, '{\f2\fswiss\fprq2 System;}}', ''); {Skall alltid tas bort}
  text := stringreplaceall(text, '{\colortbl\red0\green0\blue0;}', ''); {Skall alltid tas bort}
{I version 2.01 av Delphi finns inte \cf0 med i RTF-rutan. Tog darfor bort
det efter \fs16 och la istallet en egen tvatt av \cf0.}

//temptext := hamtastreng (text,'{\rtf1','\deflang');
//text := stringreplace (text,temptext,''); {Hamta och radera allt fran start till deflang}
  text := stringreplaceall(text, '\cf0', '');
  temptext := hamtastreng(text, '\deflang', '\pard'); {Plocka fran deflang till pard for att fa }
  text := stringreplace(text, temptext, ''); {oavsett vilken lang det ar. Norska o svenska ar olika}
{Har skall vi plocka bort fs och flera olika siffror beroende pa vilka alternativ vi godkanner.}
//text := stringreplaceall (text,'\fs16','');{8 punkter}
//text := stringreplaceall (text,'\fs20','');{10 punkter}
{Nu stadar vi istallet bort alla tvasiffriga fontsize.}
  while pos('\fs', text) > 0 do

    begin
      application.processmessages;
      start := pos('\fs', text);
      Delete(text, start, 5);
    end;
  text := stringreplaceall(text, '\pard\plain\f0 ', '<P>');
  text := stringreplaceall(text, '\par \plain\f0\b\ul ', '</P><MELLIS>');
  text := stringreplaceall(text, '\plain\f0\b\ul ', '</P><MELLIS>');
  text := stringreplaceall(text, '\plain\f0', '</MELLIS>');
  text := stringreplaceall(text, '\par }', '</P>');
  text := stringreplaceall(text, '\par ', '</P><P>');
  text := stringreplaceall(text, '#]#', '}');
  text := stringreplaceall(text, '#[#', '{');
  text := stringreplaceall(text, '\\', '\');
  result := text;
end;

    //Нижеприведенный кусок кода вырезан из довольно большой программы, вызывающей вышеприведенную функцию.
//Я знаю что мог бы использовать потоки вместо использования отдельного файла, но у меня не было времени для реализации этого


utfilnamn := mditted.exepath + stringreplace(stringreplace(extractfilename(pathname), '.TTT', ''), '.ttt', '') + 'ut.RTF';
brodtext.lines.savetofile(utfilnamn);
temptext := '';
assignfile(tempF, utfilnamn);
reset(tempF);
try
  while not eof(tempF) do
    begin
      readln(tempF, temptext2);
      temptext2 := stringreplaceall(temptext2, '\' + chr(39) + 'b6', '');
      temptext2 := rtf2sgml(temptext2);
      if temptext2 <> '' then temptext := temptext + temptext2;
      application.processmessages;
    end;
finally
  closefile(tempF);
end;
deletefile(utfilnamn);
temptext := stringreplaceall(temptext, '</MELLIS> ', '</MELLIS>');
temptext := stringreplaceall(temptext, '</P> ', '</P>');
temptext := stringreplaceall(temptext, '</P>' + chr(0), '</P>');
temptext := stringreplaceall(temptext, '</MELLIS></P>', '</MELLIS>');
temptext := stringreplaceall(temptext, '<P></P>', '');
temptext := stringreplaceall(temptext, '</P><P></MELLIS>', '</MELLIS><P>');
temptext := stringreplaceall(temptext, '</MELLIS>', '<#MELLIS><P>');
temptext := stringreplaceall(temptext, '<#MELLIS>', '</MELLIS>');
temptext := stringreplaceall(temptext, '<P><P>', '<P>');
temptext := stringreplaceall(temptext, '<P> ', '<P>');
temptext := stringreplaceall(temptext, '<P>-', '<P>_');
temptext := stringreplaceall(temptext, '<P>_', '<CITAT>_');
while pos('<CITAT>_', temptext) > 0 do
  begin
    application.processmessages;
    temptext2 := hamtastreng(temptext, '<CITAT>_', '</P>');
    temptext := stringreplace(temptext, temptext2 + '</P>', temptext2 + '</CITAT>');
    temptext := stringreplace(temptext, '<CITAT>_', '<CITAT>-');
  end;
writeln(F, '<BRODTEXT>' + temptext + '</BRODTEXT>');



@Drkb::04284
Взято из Советов по Delphi от Валентина Озерова
Сборник Kuliba
Количество статей: 4366
 
Вход
Имя:
Пароль:
Запомнить
Регистрация Забыли пароль?
Мини-чат :)
Необходима регистрация
Архив мини-чата
12-03-2025 15:42
DartKane
О! Нашёл в панели управления!
12-03-2025 15:37
DartKane
Всем привет. А как поменять пароль на свой?
04-07-2024 06:46
Adler
https://gamedev....27.png
04-07-2024 06:15
Adler
yt kjubyntcm yf 'njv cfqnt: https://gamedev....903#m2
02-05-2024 16:57
Divann
никогда не видел подобного сайта, как ваш [url=http://desksoft.ru] smiley!
02-05-2024 16:57
Divann
привет
26-03-2024 15:49
Roan
Надеюсь, оно ещё живо. Классный ресурс
03-03-2024 16:34
ПаХаН
Надо чтобы этот сайт был жив
20-02-2024 06:12
memoryspeak
обалденный сайт. искал ответ на вопрос, как скриптом закрыть вкладку, и наткнулся на это чудо.
08-02-2024 20:22
stark452
Разработчику огромный респект
Статистика
 СегодняВсего
Посетителей44610022338
Запросов2719449162335
Online
Пользователей0
Гостей4
imgimgimgimg
 
img
     00:00