forked from wanderlust/flim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mime-en.sgml
1422 lines (1216 loc) · 39 KB
/
mime-en.sgml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype sinfo system>
<head>
<title>FLIM 1.14 Reference Manual about MIME Features
<author>MORIOKA Tomohiko <mail>[email protected]</mail>
<date>1999-01-27
<toc>
</head>
<body>
<abstract>
<p>
This file documents MIME features of FLIM, a fundamental library to
process Internet Messages for GNU Emacsen.
</abstract>
<h1> What is FLIM?
<node> Introduction
<p>
FLIM is a library to provide basic features about message
representation or encoding.
<h1> How to use MIME features
<node> How to use
<p>
Please eval following to use MIME features provided by FLIM:
<lisp>
(require 'mime)
</lisp>
<h1> Message and Entity
<node> Entity
<p>
According to <dref>RFC 2045</dref>, `The term ``entity'', refers
specifically to the MIME-defined header fields and contents of either
a message or one of the parts in the body of a multipart entity.' In
this document, the term <concept>entity</concept> indicates all of
header fields and body.
<p>
The definition of RFC 2045 indicates that a MIME message is a tree,
and each node of the tree is an entity. Namely MIME extends message
to tree structure.
<p>
FLIM uses <concept>mime-entity</concept> structure to represent
information of entity. In this document, it is called simply
`mime-entity'.
<h2> Functions to create mime-entity
<node> Entity creation
<p>
<defun name="mime-open-entity">
<opts> type location
<p>
Open an entity and return it.
<p>
<var>type</var> is representation-type. <cf node="mm-backend">
<p>
<var>location</var> is location of entity. Specification of it is
depended on representation-type.
</defun>
<defun name="mime-parse-buffer">
<opts> buffer type
<p>
Parse <var>buffer</var> as message, and set the result to buffer local
variable <code>mime-message-structure</code> of <var>buffer</var> as
mime-entity.
<p>
If <var>buffer</var> is omitted, current buffer is used.
<p>
<var>type</var> is representation-type of created mime-entity. <cf
node="mm-backend"> Default value is <var>buffer</var>.
</defun>
<h2> Features about message tree
<node> Entity hierarchy
<p>
Structure of a MIME message is tree.
<p>
In the tree, root node is the entity indicates all of the message. In
this document, it is called <concept>root-entity</concept> or
<concept>message</concept>. In FLIM, it is indicated by buffer local
variable <code>mime-message-structure</code>.
<p>
Each entity except root-entity has a parent. An entity may have
children. We can indicate an entity by relative position from a base
entity, based on the parent-child relationship.
<p>
In addition, we can indicate an entity by absolute position of the
message.
<p>
Each entity, which is a node of the tree, can be numbered by
depth and left-to-right order of the depth.
<verb>
+-------+
| nil |
+---+---+
+-------------------+-------------------+
+-+-+ +-+-+ +-+-+
| 0 | | 1 | | 2 |
+-+-+ +-+-+ +-+-+
| +---------+---------+ |
+--+--+ +--+--+ +--+--+ +--+--+ +--+--+
| 0.0 | | 1.0 | | 1.1 | | 1.2 | | 2.0 |
+-----+ +-----+ +-----+ +-----+ +-----+
</verb>
<p>
Namely, if depth of a node is n, the node has a node-number, which is
consists of n integers. In this document, it is called
<concept>entity-number</concept>. An entity-number is represented by
list of integer, like <code>(1 2 3)</code>.
<p>
mime-entity has also <concept>node-id</concept>. A node-id is
represented by reversed list of entity-number. For example, node-id
corresponding with 1.2.3 is <code>(3 2 1)</code>.
<p>
Each entity can be indicated by entity-number or node-id in
<code>mime-message-structure</code>.
<defvar name="mime-message-structure">
<p>
Buffer local variable to store mime-entity structure of message.
</defvar>
<defun name="mime-entity-children">
<args> entity
<p>
Return list of entities included in the <var>entity</var>.
</defun>
<defun name="mime-entity-parent">
<args> entity <opts> message
<p>
Return parent entity of the <var>entity</var>.
<p>
If <var>message</var> is specified, it is regarded as root instead of
<code>mime-message-structure</code>.
</defun>
<defun name="mime-root-entity-p">
<args> entity
<p>
Return non-<code>nil</code> if <var>entity</var> is root entity
(message).
</defun>
<defun name="mime-entity-node-id">
<args> entity
<p>
Return node-id of <var>entity</var>.
</defun>
<defun name="mime-entity-number">
<args> entity
<p>
Return entity-number of <var>entity</var>.
</defun>
<h2> Find Entity
<node> Entity Search
<p>
<defun name="mime-find-entity-from-number">
<args> entity-number <opts> message
<p>
Return entity from <var>entity-number</var> in <var>message</var>.
<p>
If <var>message</var> is not specified,
<code>mime-message-structure</code> is used.
</defun>
<defun name="mime-find-entity-from-node-id">
<args> entity-node-id <opts> message
<p>
Return entity from <var>entity-node-id</var> in <var>message</var>.
<p>
If <var>message</var> is not specified,
<code>mime-message-structure</code> is used.
</defun>
<defun name="mime-find-entity-from-content-id">
<args> cid <opts> message
<p>
Return entity from <var>cid</var> in <var>message</var>.
<p>
If <var>message</var> is not specified,
<code>mime-message-structure</code> is used.
</defun>
<h2> Functions about attributes of mime-entity
<node> Entity Attributes
<p>
<defun name="mime-entity-content-type">
<args> entity
<p>
Return content-type of <var>entity</var>.
<cf node="mime-content-type">
</defun>
<defun name="mime-entity-content-disposition">
<args> entity
<p>
Return content-disposition of <var>entity</var>. <cf
node="mime-content-disposition">
</defun>
<defun name="mime-entity-filename">
<args> entity
<p>
Return file name of <var>entity</var>.
</defun>
<defun name="mime-entity-encoding">
<args> entity <opts> default-encoding
<p>
Return content-transfer-encoding of <var>entity</var>.
<cf node="Content-Transfer-Encoding">
<p>
If the <var>entity</var> does not have Content-Transfer-Encoding
field, this function returns <var>default-encoding</var>. If it is
nil, <code>"7bit"</code> is used as default value.
</defun>
<defun name="mime-entity-cooked-p">
<args> entity
<p>
Return non-nil if contents of <var>entity</var> has been already
code-converted.
</defun>
<h2> Information of entity header
<node> Entity-header
<p>
<defun name="mime-fetch-field">
<args> field-name <opts> entity
<p>
Return field-body of <var>field-name</var> field in header of
<var>entity</var>.
<p>
The results is network representation.
<p>
If <var>entity</var> is omitted, <code>mime-message-structure</code>
is used as default value.
<p>
If <var>field-name</var> field is not found, this function returns
<code>nil</code>.
</defun>
<defun name="mime-read-field">
<args> field-name <opts> entity
<p>
Parse <var>field-name</var> field in header of <var>entity</var>, and
return the result.
<p>
Format of result is depended on kind of field. For non-structured
field, this function returns string. For structured field, it returns
list corresponding with structure of the field.
<p>
Strings in the result will be converted to internal representation of
Emacs.
<p>
If <var>entity</var> is omitted, <code>mime-message-structure</code>
is used as default value.
<p>
If <var>field-name</var> field is not found, this function returns
<code>nil</code>.
</defun>
<h2> Text presentation of entity
<node> entity formatting
<p>
<defun name="mime-insert-header">
<args> entity <opts> invisible-fields visible-fields
<p>
Insert before point a decoded contents of header of <var>entity</var>.
<p>
<var>invisible-fields</var> is list of regexps to match field-name to
hide. <var>visible-fields</var> is list of regexps to match
field-name to hide.
<p>
If a field-name is matched with some elements of
<var>invisible-fields</var> and matched with none of
<var>visible-fields</var>, this function don't insert the field.
<p>
Each <dref>encoded-word</dref> in the header is decoded. ``Raw non
us-ascii characters'' are also decoded as
<code>default-mime-charset</code>.
</defun>
<defun name="mime-insert-text-content">
<args> entity
<p>
Insert before point a contents of <var>entity</var> as text entity.
<p>
Contents of the <var>entity</var> are decoded as <dref>MIME
charset</dref>. If the <var>entity</var> does not have charset
parameter of Content-Type field, <code>default-mime-charset</code> is
used as default value.
</defun>
<defvar name="default-mime-charset">
<p>
Symbol to indicate default value of <dref>MIME charset</dref>.
<p>
It is used when MIME charset is not specified.
<p>
It is originally variable of APEL.
</defvar>
<h2> Contents of Entity
<node> Entity-content
<p>
<defun name="mime-entity-content">
<args> entity
<p>
Return content of <var>entity</var> as byte sequence.
</defun>
<defun name="mime-insert-entity-content">
<args> entity
<p>
Insert content of <var>entity</var> at point.
</defun>
<defun name="mime-write-entity-content">
<args> entity filename
<p>
Write content of <var>entity</var> into <var>filename</var>.
</defun>
<h2> Network representation of Entity
<node> Entity-network-representation
<p>
<defun name="mime-insert-entity">
<args> entity
<p>
Insert header and body of <var>entity</var> at point.
</defun>
<defun name="mime-write-entity">
<args> entity filename
<p>
Write representation of <var>entity</var> into <var>filename</var>.
</defun>
<defun name="mime-write-entity-body">
<args> entity filename
<p>
Write body of <var>entity</var> into <var>filename</var>.
</defun>
<h2> Entity as buffer representation
<node> Entity buffer
<p>
<defun name="mime-entity-buffer">
<args> entity
<p>
Return buffer, which contains <var>entity</var>.
</defun>
<defun name="mime-entity-point-min">
<args> entity
<p>
Return the start point of <var>entity</var> in the buffer which
contains <var>entity</var>.
</defun>
<defun name="mime-entity-point-max">
<args> entity
<p>
Return the end point of <var>entity</var> in the buffer which
contains <var>entity</var>.
</defun>
<defun name="mime-entity-header-start">
<args> entity
<p>
Return the start point of header of <var>entity</var> in the buffer
which contains <var>entity</var>.
</defun>
<defun name="mime-entity-header-end">
<args> entity
<p>
Return the end point of header of <var>entity</var> in the buffer
which contains <var>entity</var>.
</defun>
<defun name="mime-entity-body-start">
<args> entity
<p>
Return the start point of body of <var>entity</var> in the buffer
which contains <var>entity</var>.
</defun>
<defun name="mime-entity-body-end">
<args> entity
<p>
Return the end point of body of <var>entity</var> in the buffer which
contains <var>entity</var>.
</defun>
<h2> Entity representations and implementations
<node> mm-backend
<p>
Entity is an abstraction. It is designed to use various data
representations for their purposes.
<p>
Each entity has <concept>representation-type</concept>. It must be
specified when an entity is created. <cf node="Entity Creation">
<p>
Functions about entity are implemented by request processing to the
entity. Each entity knows its representation-type. Each entity calls
processing function corresponding with the representation-type. Such
kind of function is called <concept>entity processing
method</concept>. A module, consists of them corresponding with a
representation-type, is called <concept>mm-backend</concept>.
<p>
Module name of each mm-backend consists of the prefix <code>mm</code>
and its representation-type. The module is required automatically
when its entity is created at first.
<h3> Message-passing for entity
<node> Request for entity
<p>
<defun name="mime-entity-send">
<args> entity message <rest> args
<p>
Send <var>message</var> to <var>entity</var> with <var>args</var>, and
return the result.
<p>
<var>args</var> is arguments of the <var>message</var>.
</defun>
<h3> Definition of mm-backend
<node> mm-backend module
<p>
<defmacro name="mm-define-backend">
<args> type
<opts> parents
<p>
Define <var>type</var> as a mm-backend.
<p>
If <var>PARENTS</var> is specified, <var>type</var> inherits parents.
Each parent must be representation-type.
<p>
Example:
<p>
<lisp>
(mm-define-backend chao (generic))
</lisp>
</defmacro>
<defmacro name="mm-define-method">
<args> name args <rest> body
<p>
Define <var>name</var> as a method function of (nth 1 (car
<var>args</var>)) backend.
<p>
<var>args</var> is like an argument list of lambda, but (car
<var>args</var>) must be specialized parameter. (car (car
<var>args</var>)) is name of variable and (nth 1 (car
<var>args</var>)) is name of backend (representation-type).
<p>
Example:
<p>
<lisp>
(mm-define-method entity-cooked-p ((entity chao)) nil)
</lisp>
</defmacro>
<h1> Information of Content-Type field
<node> Content-Type
<p>
<concept>Content-Type field</concept> is a field to indicate kind of
contents or data format, such as <dref>media-type</dref> and MIME
charset. It is defined in <dref>RFC 2045</dref>.
<memo>
<p>
Historically, Content-Type field was proposed in RFC 1049. In it,
Content-Type did not distinguish type and subtype, and there are no
mechanism to represent kind of character code like MIME charset.
</memo>
<p>
FLIM provides parser for Content-Type field and structure
<concept>mime-content-type</concept> to store information of
Content-Type field.
<h2> Format of Content-Type field
<node> Content-Type field
<p>
Format of Content-Type field is defined as follows:
<quote>
``Content-Type'' ``:'' <concept>type</concept> ``/''
<concept>subtype</concept> *( ``;'' <concept>parameter</concept> )
</quote>
<p>
For example:
<quote>
<verb>
Content-Type: image/jpeg
</verb>
</quote>
<quote>
<verb>
Content-Type: text/plain; charset=iso-2022-jp
</verb>
</quote>
<p>
`type' and `subtype' indicate format of an entity. In this document,
pair of them is called `media-type'. `image/jpeg' or `text/plain' is
a media-type.
<memo>
<p>
If an entity does not have Content-Type field, it is regarded as
following:
<quote>
<verb>
Content-Type: text/plain; charset=us-ascii
</verb>
</quote>
<noindent>
<cf node="us-ascii">
</memo>
<h2> mime-content-type structure
<node> mime-content-type
<p>
<define type="Structure" name="mime-content-type">
<p>
Structure to store information of a Content-Type field.
<p>
Applications should use reference functions
<code>mime-content-type-SLOT</code> to refer information of the
structure.
<p>
Slots of the structure are following:
<vl>
<dt>primary-type<dd>primary type of media-type (symbol).
</dd>
<dt>subtype<dd>subtype of media-type (symbol).
</dd>
<dt>parameters<dd>parameters of Content-Type field (association-list).
</dd>
</vl>
</define>
<defun name="make-mime-content-type">
<args> type subtype
<opts> parameters
<p>Constructor of content-type.
</defun>
<defun name="mime-content-type-parameter">
<args> content-type parameter
<p>
Return value of <var>parameter</var> of <var>content-type</var>.
</defun>
<h2> Parser
<node> Content-Type parser
<p>
<defun name="mime-parse-Content-Type">
<args> string
<p>
Parse <var>string</var> as a field-body of Content-Type field, and
return the result as <dref>mime-content-type</dref> structure.
</defun>
<defun name="mime-read-Content-Type">
<p>
Parse Content-Type field of the current buffer, and return the result
as <dref>mime-content-type</dref> structure.
<p>
Return <code>nil</code> if Content-Type field is not found.
</defun>
<h2> Utility functions
<node> Content-Type utility
<p>
<defun name="mime-type/subtype-string">
<args> type <opts> subtype
<p>
Return type/subtype string from <var>type</var> and
<var>subtype</var>.
</defun>
<h1> Information of Content-Disposition field
<node> Content-Disposition
<p>
<concept>Content-Disposition field</concept> is an optional field to
specify presentation of an entity or attributes of an entity, such as
file name.
<rfc number="2183" type="Standards Track"
author="S. Dorner, K. Moore and R. Troost"
title="Communicating Presentation Information in Internet
Messages: The Content-Disposition Header" date="August
1997">
<p>
FLIM provides parser for Content-Disposition field and structure
<concept>mime-content-disposition</concept> to store information of
Content-Disposition field.
<h2> mime-content-disposition structure
<node> mime-content-disposition
<p>
<define type="Structure" name="mime-content-disposition">
<p>
Structure to store information of a Content-Disposition field.
<p>
Applications should use reference functions
<code>mime-content-disposition-SLOT</code> to refer information of the
structure.
<p>
Slots of the structure are following:
<vl>
<dt>disposition-type<dd>disposition-type (symbol).
</dd>
<dt>parameters<dd>parameters of Content-Disposition field
(association-list).
</dd>
</vl>
</define>
<defun name="mime-content-disposition-parameter">
<args> content-disposition parameter
<p>
Return value of <var>parameter</var> of
<var>content-disposition</var>.
</defun>
<defun name="mime-content-disposition-filename">
<args> content-disposition
<p>
Return filename of <var>content-disposition</var>.
</defun>
<h2> Parser for Content-Disposition field
<node> Content-Disposition parser
<p>
<defun name="mime-parse-Content-Disposition">
<args> string
<p>
Parse <var>string</var> as field-body of Content-Disposition field,
and return the result as <dref>mime-content-disposition</dref>
structure.
</defun>
<defun name="mime-read-Content-Disposition">
<p>
Parse Content-Disposition field of the current buffer, and return the
result as <dref>mime-content-disposition</dref> structure.
<p>
Return <code>nil</code> if Content-Disposition field is not found.
</defun>
<h1> Encoding Method
<node> Content-Transfer-Encoding
<p>
<concept>Content-Transfer-Encoding field</concept> is a header field
to indicate body encoding of a entity.
<p>
FLIM provides parser functions for Content-Transfer-Encoding field.
They represent information of Content-Transfer-Encoding field as
string.
<p>
In addition, FLIM provides encoder/decoder functions by
Content-Transfer-Encoding.
<h2> Parser
<node> Content-Transfer-Encoding parser
<p>
<defun name="mime-parse-Content-Transfer-Encoding">
<args> string
<p>
Parse <var>string</var> as a field-body of Content-Transfer-Encoding
field, and return the result.
</defun>
<defun name="mime-read-Content-Transfer-Encoding">
<opts>default-encoding
<p>
Parse Content-Transfer-Encoding field of the current buffer, and
return the result.
<p>
Return <var>default-encoding</var> if Content-Transfer-Encoding field
is not found. If it is not specified, <code>nil</code> is used as the
default value.
</defun>
<h2> Encoder/decoder
<node> encoder/decoder
<p>
<defun name="mime-encode-region">
<args> start end encoding
<p>
Encode region <var>start</var> to <var>end</var> of current buffer
using <var>encoding</var>.
</defun>
<defun name="mime-decode-region">
<args> start end encoding
<p>
Decode region <var>start</var> to <var>end</var> of current buffer
using <var>encoding</var>.
</defun>
<defun name="mime-decode-string">
<args> string encoding
<p>
Decode <var>string</var> which is encoded in <var>encoding</var>, and
return the result.
</defun>
<defun name="mime-insert-encoded-file">
<args> filename encoding
<p>
Insert file <var>FILENAME</var> encoded by <var>ENCODING</var> format.
</defun>
<defun name="mime-write-decoded-region">
<args> start end filename encoding
<p>
Decode and write current region encoded by <var>encoding</var> into
<var>filename</var>.
<p>
<var>start</var> and <var>end</var> are buffer positions.
</defun>
<h2> Other utilities
<node> Encoding information
<p>
<defun name="mime-encoding-list">
<opts> SERVICE
<p>
Return list of Content-Transfer-Encoding.
<p>
If <var>service</var> is specified, it returns available list of
Content-Transfer-Encoding for it.
</defun>
<defun name="mime-encoding-alist">
<opts> SERVICE
<p>
Return table of Content-Transfer-Encoding for completion.
<p>
If <var>service</var> is specified, it returns available list of
Content-Transfer-Encoding for it.
</defun>
<h2> How to write encoder/decoder module
<node> mel-backend
<p>
<defmacro name="mel-define-method">
<args> name args <rest> body
<p>
Define <var>name</var> as a method function of (nth 1 (car (last
<var>args</var>))) backend.
<p>
<var>args</var> is like an argument list of lambda, but (car (last
<var>args</var>)) must be specialized parameter. (car (car (last
<var>args</var>))) is name of variable and (nth 1 (car (last
<var>args</var>))) is name of backend (encoding).
<p>
Example:
<p>
<lisp>
(mel-define-method mime-write-decoded-region (start end filename
(nil "base64"))
"Decode and write current region encoded by base64 into FILENAME.
START and END are buffer positions."
(interactive
(list (region-beginning) (region-end)
(read-file-name "Write decoded region to file: ")))
(let ((str (buffer-substring start end)))
(with-temp-buffer
(insert (decode-base64-string str))
(write-region-as-binary (point-min) (point-max) filename)
)))
</lisp>
</defmacro>
<defmacro name="mel-define-method-function">
<args> spec function
<p>
Set <var>spec</var>'s function definition to <var>function</var>.
<p>
First element of <var>spec</var> is service.
<p>
Rest of <var>args</var> is like an argument list of lambda, but (car
(last <var>args</var>)) must be specialized parameter. (car (car
(last <var>args</var>))) is name of variable and (nth 1 (car (last
<var>args</var>))) is name of backend (encoding).
<p>
Example:
<p>
<lisp>
(mel-define-method-function (mime-encode-string string (nil "base64"))
'encode-base64-string)
</lisp>
</defmacro>
<h2> How to add encoding/decoding service
<node> generic function for mel-backend
<p>
<defmacro name="mel-define-service">
<args> name
<opts> args doc-string
<p>
Define <var>name</var> as a service for Content-Transfer-Encodings.
<p>
If <var>args</var> is specified, <var>name</var> is defined as a
generic function for the service.
<p>
Example:
<p>
<lisp>
(mel-define-service encoded-text-encode-string (string encoding)
"Encode STRING as encoded-text using ENCODING.
ENCODING must be string.")
</lisp>
</defmacro>
<h1> Network representation of header
<node> encoded-word
<p>
<concept>RFC 2047</concept> defines the
<concept>encoded-word</concept> which is a format to represent
non-<dref>ASCII</dref> characters in a header.
<p>
<rfc number="2047" type="Standards Track" author="K. Moore"
title="MIME (Multipurpose Internet Mail Extensions) Part
Three: Message Header Extensions for Non-ASCII Text"
date="November 1996" obsolete="1521,1522,1590">
<p>
The encoded-word is the only valid format to represent
non-<dref>ASCII</dref> characters in a header, but there are also
invalid styles. Such kinds of evil messages represent
non-<dref>ASCII</dref> characters in headers without encoded-words (it
is called "raw" non-<dref>ASCII</dref> characters).
<p>
FLIM provides encoding/decoding features of both encoded-word and
invalid "raw" non-<dref>ASCII</dref> characters.
<h2> Header encoding/decoding
<node> Header encoder/decoder
<p>
<defun name="eword-decode-header">
<opts> code-conversion separator
<p>
Decode MIME encoded-words in header fields.
<p>
If <var>code-conversion</var> is <code>nil</code>, only encoded-words
are decoded. If <var>code-conversion</var> is a <dref>MIME
charset</dref>, non-ASCII bit patterns are decoded as the MIME
charset. Otherwise non-ASCII bit patterns are decoded as the
<code>default-mime-charset</code>. <cf node="entity formatting">
<p>
If <var>separator</var> is not <code>nil</code>, it is used as header
separator.
</defun>
<defun name="eword-encode-header">
<opts> code-conversion
<p>
Encode header fields to network representation, such as MIME
encoded-word.
<p>
Each field is encoded as corresponding method specified by variable
<code>mime-field-encoding-method-alist</code>.
</defun>
<defvar name="mime-field-encoding-method-alist">
<p>
Association list to specify field encoding method. Each element looks
like (FIELD . METHOD).
<p>
If METHOD is <code>mime</code>, the FIELD will be encoded into MIME
format (encoded-word).
<p>
If METHOD is <code>nil</code>, the FIELD will not be encoded.
<p>
If METHOD is a MIME charset, the FIELD will be encoded as the charset
when it must be convert into network-code.
<p>
Otherwise the FIELD will be encoded as variable
<code>default-mime-charset</code> when it must be convert into
network-code.
</defvar>
<h1> Various Customization
<node> custom
<p>
<define type="group" name="mime">
<p>
The group associated with functions related to MIME.
<p>
It belongs to <code>mail</code> and <code>news</code>.
</define>
<h1> Appendix
<node> Appendix
<h2> Glossary
<node> Glossary
<h3> 7bit
<node> 7bit
<p>
<concept>7bit</concept> means any integer between 0 .. 127.
<p>
Any data represented by 7bit integers is called <concept>7bit
data</concept>.
<p>
Textual string consisted of Control characters between 0 .. 31 and
127, and space represented by 32, and graphic characters between 33
.. 236 are called <concept>7bit (textual) string</concept>.
<p>
Conventional Internet <a node="MTA">MTA</a> can translate 7bit data,
so it is no need to translate by <a
node="Quoted-Printable">Quoted-Printable</a> or <a
node="Base64">Base64</a> for 7bit data.
<p>
However if there are too long lines, it can not translate by 7bit MTA
even if it is 7bit data. <dref>RFC 821</dref> and <dref>RFC
2045</dref> require lines in 7bit data must be less than 998 bytes.
So if a ``7bit data'' has a line more than 999 bytes, it is regarded
as <dref>binary</dref>. For example, Postscript file should be
encoded by Quoted-Printable.
<h3> 8bit
<node> 8bit
<p>
<concept>8bit</concept> means any integer between 0 .. 255.
<p>
Any data represented by 8bit integers is called <concept>8bit
data</concept>.
<p>
Textual string consisted of Control characters between 0 .. 31, 127,
and 128 .. 159, and space represented by 32, and graphic characters
between 33 .. 236 and 160 .. 255 are called <concept>8bit (textual)
string</concept>.
<p>
For example, <dref>iso-8859-1</dref> or <dref>euc-kr</dref> are
coded-character-set represented by 8bit textual string.
<p>
Traditional Internet <a node="MTA">MTA</a> can translate only
<dref>7bit</dref> data, so if a 8bit data will be translated such MTA,
it must be encoded by <dref>Quoted-Printable</dref> or
<dref>Base64</dref>.