Поможем написать учебную работу
Если у вас возникли сложности с курсовой, контрольной, дипломной, рефератом, отчетом по практике, научно-исследовательской и любой другой работой - мы готовы помочь.

Предоплата всего

Подписываем
Если у вас возникли сложности с курсовой, контрольной, дипломной, рефератом, отчетом по практике, научно-исследовательской и любой другой работой - мы готовы помочь.
Предоплата всего
Подписываем
Лабораторная работа №3
Форматы текстовых документов
Rich Text Format —межплатформенный формат хранения размеченных текстовых документов, предложенный группами программистов, основавшими компании Microsoft и Adobe, как метатэговский формат для редактора Word в 1982 году. С тех пор спецификация формата несколько раз изменялась. RTF-документы поддерживаются всеми современными текстовыми редакторами.
В RTF для обмена документами используются только представимые символами коды из ASCII-, MAC- и PC-символьного набора. Кроме текста, файл в RT-формате в читаемой форме содержит команды управления.
Документ состоит преимущественно из команд управления настройки программы чтения файлов в RTF-формате. Эти команды можно разделить на управляющие слова (control words) и управляющие символы (control symbols).
Управляющее слово представляет собой последовательность символов с разделителем (delimiter) в конце:
\lettersequence <delimiter>
Перед управляющим словом вводится обратная косая черта "\" (backslash). В качестве разделяющих могут использоваться следующие символы:
В RT-формате для задания управляющей последовательности используются буквы от "А" до "Z" и от "а" до "z", а также цифры от "0" до "9". Национальные символы к управляющей информации не относятся.
В качестве, управляющих символов используются отдельные буквы. Перед каждым управляющим символом вводится обратная косая черта "\":
\control symbol
В настоящее время определены только некоторые из этих символов. Поэтому при чтении неизвестные символы могут быть пропущены.
В RT-формате существует возможность объединять отдельные последовательности в группы при помощи скобок:
{ начало группы
} конец группы
Такие группы создаются, например, при описании сносок, колонтитулов и т.п. Если необходимо разместить символы "\", "{" или "}" внутри обычного текста, то перед ними надлежит поставить обратную косую черту:
\\
\{
\}.
Это позволяет программе, читающей RTF-последовательность, распознать, что символ не следует интерпретировать как управляющий.
Для форматирования текста в формате RTF используются управляющие слова, указанные в таблице:
Control Word |
Meaning |
\plain |
Reset font (character) formatting properties to a default value defined by the application (for example, bold, underline and italic are disabled; font size is reset to 12 pt). The associated font (character) formatting properties (described in the section Associated Character Properties of this RTF Specification) are also reset. |
\animtextN |
Animated text properties. 1Las Vegas Lights 2Blinking background 3Sparkle text 4Marching black ants 5Marching red ants 6Shimmer |
\accnone |
No accent characters (over dot / over comma). |
\accdot |
Over dot accent. |
\acccomma |
Over comma accent. |
\b |
Bold.* |
\caps |
All capitals.* |
\cbN |
Background color (the default is 0). |
\cchsN |
Indicates any characters not belonging to the default document character set and tells which character set they do belong to. Macintosh character sets are represented by values greater than 255. The values for N correspond to the values for the \ fcharset control word. |
\cfN |
Foreground color (the default is 0). |
\charscalexN |
Character scaling value. The N argument is a value representing a percentage (the default is 100). |
\csN |
Designates character style. If a character style is specified, style properties must be specified with the character run. N refers to an entry in the style table. |
\cgridN |
Character grid. |
\g |
Destination related to character grids. |
\gcw |
Grid column width. |
\gridtbl |
Destination keyword related to character grids. |
\deleted |
Marks the text as deletion revision marked.* |
\dnN |
Subscript position in half-points (the default is 6). |
\embo |
Emboss. |
\expndN |
Expansion or compression of the space between characters in quarter-points; a negative value compresses (the default is 0). |
\expndtwN |
Expansion or compression of the space between characters in twips; a negative value compresses. For backward compatibility, both \expndtw and\expnd should be emitted. |
\fittextN |
Fit the text in the current group in N twips. When N is set to -1 (\fittext-1) it indicates a continuation of the previous \fittextN run. In other words{\fittext1000 Fit this} {\fittext-1 text} fits the string "Fit this text" in 1000 twips. |
\fN |
Font number. N refers to an entry in the font table. |
\fsN |
Font size in half-points (the default is 24). |
\i |
Italic.* |
\impr |
Engrave. |
\kerningN |
Point size (in half-points) above which to kern character pairs. \kerning0 turns off kerning. |
\langfeN |
Applies a language to a character. N is a number corresponding to a language. The \plain control word resets the language property to the language defined by \deflangfeN in the document properties. |
\langfenpN |
Applies a language to a character. N is a number corresponding to a language. The \plain control word resets the language property to the language defined by \deflangfeN in the document properties. Usually follows \langfeN |
\langN |
Applies a language to a character. N is a number corresponding to a language. The \plain control word resets the language property to the language defined by \deflangN in the document properties. |
\langnpN |
Applies a language to a character. N is a number corresponding to a language. The \plain control word resets the language property to the language defined by \deflangN in the document properties. It is identical to \langN, but needed when \noproof is written together with \lang1024 in order to preserve the language of the text that is not being checked for spelling or grammar. Usually follows \langN |
\ltrch |
The character data following this control word will be treated as a left-to-right run (the default). |
\rtlch |
The character data following this control word will be treated as a right-to-left run. |
\noproof |
Do not check spelling or grammar for text in the group. Serves the function of \lang1024. usually \lang1024 is emitted with it for backwards compatibility with old readers. |
\nosupersub |
Turns off superscripting or subscripting. |
\nosectexpand |
Disable character space basement. |
\outl |
Outline.* |
\rtlch |
The character data following this control word will be treated as a right-to-left run. |
\scaps |
Small capitals.* |
\shad |
Shadow.* |
\strike |
Strikethrough.* |
\striked1 |
Double strikethrough. \striked0 turns it off. |
\sub |
Subscripts text and shrinks point size according to font information. |
\super |
Superscripts text and shrinks point size according to font information. |
\ul |
Continuous underline. \ul0 turns off all underlining. |
\ulcN |
Underline color |
\uld |
Dotted underline. |
\uldash |
Dash underline. |
\uldashd |
Dash dot underline. |
\uldashdd |
Dash dot dot underline. |
\uldb |
Double underline. |
\ulhwave |
Heavy wave underline |
\ulldash |
Long dash underline |
\ulnone |
Stops all underlining. |
\ulth |
Thick underline |
\ulthd |
Thick dotted underline |
\ulthdash |
Thick dash underline |
\ulthdashd |
Thick dash dot underline |
\ulthdashdd |
Thick dash dot dot underline |
\ulthldash |
Thick long dash underline |
\ululdbwave |
Double wave underline |
\ulw |
Word underline. |
\ulwave |
Wave underline. |
\upN |
Superscript position in half-points (the default is 6). |
\v |
Hidden text.* |
\webhidden |
Indicates that the text in the group is hidden in Word 2000's Web View and will not be emitted upon saving as web page. |
Для того, чтобы просмотреть RTF-код, необходимо открыть его с помощью блокнота, где форматирование текста будет отсутствовать, в то время как в окне текстового редактора он будет выглядеть форматированным. Текстовые редакторы добавляют в код свои, служебные, управляющие символы. Например, исходный код может быть следующим:
{\rtf1
Hello!
\par
{\i This \i0} is {\b text \b0}.\par
End
который будет выглядеть в текстовом редакторе с поддержкой RTF как
Hello!
This is text .
End
Но если тот же текст изначально создать в текстовом редакторе WordPad, то RTF-код будет следующим:
{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang9\f0\fs22 Hello!\par
\i This \i0 is \b text\b0 .\par
End\par
}
Текстовый редактор WordPad не позволяет использовать RTF-спецификацию полностью, например, невозможно добавить к тексту волнообразное подчёркивание. При этом, создавая код с помощью простейшего текстового редактора «Блокнот» или с помощью серверных сценариев, указав управляющее слово «\ulwave» – можно выполнить такое подчёркивание.
Задание:
1. Создайте в соответствии со спецификацией RTF-код:
2. Используя максимум управляющих RTF-слов напишите следующую информацию:
Ф.И.О, номер группы
Дата и место рождения
Примерный перевод текста из задания 1.