-
Notifications
You must be signed in to change notification settings - Fork 13
/
mime-en.texi
1625 lines (1081 loc) · 44.4 KB
/
mime-en.texi
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
\input texinfo-ja @c -*-texinfo -*- coding: utf-8 -*-
@c Generated automatically from mime-en.sgml by sinfo 3.7.
@setfilename mime-en.info
@settitle FLIM-LB 1.14 Reference Manual about MIME Features
@documentencoding utf-8
@documentlanguage en
@dircategory GNU Emacs Lisp
@direntry
* FLIM-LB (en): (mime-en). Internet message library.
@end direntry
@titlepage
@title FLIM-LB 1.14 Reference Manual about MIME Features
@author MORIOKA Tomohiko <morioka@@jaist.ac.jp>
@author Kazuhiro Ito
@subtitle 2020-09-17
@end titlepage
@node Top, Introduction, (dir), (dir)
@top FLIM-LB 1.14 Reference Manual about MIME Features
@ifinfo
This file documents MIME features of FLIM-LB, a fundamental library to
process Internet Messages for GNU Emacsen.
@end ifinfo
@menu
* Introduction:: What is FLIM-LB?
* How to use:: How to use MIME features
* Entity:: Message and Entity
* Content-Type:: Information of Content-Type field
* Content-Disposition:: Information of Content-Disposition field
* Content-Transfer-Encoding:: Encoding Method
* encoded-word:: Network representation of header
* custom:: Various Customization
* Appendix::
* Concept Index::
* Function Index::
* Variable Index::
@end menu
@node Introduction, How to use, Top, Top
@chapter What is FLIM-LB?
FLIM is a library to provide basic features about message
representation or encoding. FLIM-LB is a variant of FLIM, which
features supports to latest Emacs.
@node How to use, Entity, Introduction, Top
@chapter How to use MIME features
Please eval following to use MIME features provided by FLIM:
@lisp
(require 'mime)
@end lisp
@node Entity, Content-Type, How to use, Top
@chapter Message and Entity
@cindex mime-entity
@cindex entity
According to RFC 2045 (@ref{RFC 2045}), `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 @strong{entity} indicates all of header fields and
body.@refill
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.@refill
FLIM uses @strong{mime-entity} structure to represent
information of entity. In this document, it is called simply
`mime-entity'.
@menu
* Entity creation:: Functions to create mime-entity
* Entity hierarchy:: Features about message tree
* Entity Search:: Find Entity
* Entity Attributes:: Functions about attributes of mime-entity
* Entity-header:: Information of entity header
* entity formatting:: Text presentation of entity
* Entity-content:: Contents of Entity
* Entity-network-representation:: Network representation of Entity
* Entity buffer:: Entity as buffer representation
* mm-backend:: Entity representations and implementations
@end menu
@node Entity creation, Entity hierarchy, Entity, Entity
@section Functions to create mime-entity
@defun mime-open-entity &optional type location
Open an entity and return it.@refill
@var{type} is representation-type. (cf. @ref{mm-backend}) @refill
@var{location} is location of entity. Specification of it is depended
on representation-type.
@end defun
@defun mime-parse-buffer &optional buffer type
Parse @var{buffer} as message, and set the result to buffer local
variable @code{mime-message-structure} of @var{buffer} as
mime-entity.@refill
If @var{buffer} is omitted, current buffer is used.@refill
@var{type} is representation-type of created
mime-entity. (cf. @ref{mm-backend}) Default value is @var{buffer}.
@end defun
@node Entity hierarchy, Entity Search, Entity creation, Entity
@section Features about message tree
@cindex node-id
@cindex entity-number
@cindex message
@cindex root-entity
Structure of a MIME message is tree.@refill
In the tree, root node is the entity indicates all of the message. In
this document, it is called @strong{root-entity} or @strong{message}.
In FLIM, it is indicated by buffer local variable
@code{mime-message-structure}.@refill
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.@refill
In addition, we can indicate an entity by absolute position of the
message.@refill
Each entity, which is a node of the tree, can be numbered by
depth and left-to-right order of the depth.
@example
+-------+
| nil |
+---+---+
+-------------------+-------------------+
+-+-+ +-+-+ +-+-+
| 0 | | 1 | | 2 |
+-+-+ +-+-+ +-+-+
| +---------+---------+ |
+--+--+ +--+--+ +--+--+ +--+--+ +--+--+
| 0.0 | | 1.0 | | 1.1 | | 1.2 | | 2.0 |
+-----+ +-----+ +-----+ +-----+ +-----+
@end example
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
@strong{entity-number}. An entity-number is represented by list of
integer, like @code{(1 2 3)}.@refill
mime-entity has also @strong{node-id}. 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)}.@refill
Each entity can be indicated by entity-number or node-id in
@code{mime-message-structure}.
@defvar mime-message-structure
Buffer local variable to store mime-entity structure of message.
@end defvar
@defun mime-entity-children entity
Return list of entities included in the @var{entity}.
@end defun
@defun mime-entity-parent entity &optional message
Return parent entity of the @var{entity}.@refill
If @var{message} is specified, it is regarded as root instead of
@code{mime-message-structure}.
@end defun
@defun mime-root-entity-p entity
Return non-@code{nil} if @var{entity} is root entity (message).
@end defun
@defun mime-entity-node-id entity
Return node-id of @var{entity}.
@end defun
@defun mime-entity-number entity
Return entity-number of @var{entity}.
@end defun
@node Entity Search, Entity Attributes, Entity hierarchy, Entity
@section Find Entity
@defun mime-find-entity-from-number entity-number &optional message
Return entity from @var{entity-number} in @var{message}.@refill
If @var{message} is not specified, @code{mime-message-structure} is
used.
@end defun
@defun mime-find-entity-from-node-id entity-node-id &optional message
Return entity from @var{entity-node-id} in @var{message}.@refill
If @var{message} is not specified, @code{mime-message-structure} is
used.
@end defun
@defun mime-find-entity-from-content-id cid &optional message
Return entity from @var{cid} in @var{message}.@refill
If @var{message} is not specified, @code{mime-message-structure} is
used.
@end defun
@node Entity Attributes, Entity-header, Entity Search, Entity
@section Functions about attributes of mime-entity
@defun mime-entity-content-type entity
Return content-type of @var{entity}. (cf. @ref{mime-content-type})
@end defun
@defun mime-entity-content-disposition entity
Return content-disposition of
@var{entity}. (cf. @ref{mime-content-disposition})
@end defun
@defun mime-entity-filename entity
Return file name of @var{entity}.
@end defun
@defun mime-entity-encoding entity &optional default-encoding
Return content-transfer-encoding of @var{entity}.
(cf. @ref{Content-Transfer-Encoding}) @refill
If the @var{entity} does not have Content-Transfer-Encoding field, this
function returns @var{default-encoding}. If it is nil, @code{"7bit"} is
used as default value.
@end defun
@defun mime-entity-cooked-p entity
Return non-nil if contents of @var{entity} has been already
code-converted.
@end defun
@node Entity-header, entity formatting, Entity Attributes, Entity
@section Information of entity header
@defun mime-fetch-field field-name &optional entity
Return field-body of @var{field-name} field in header of
@var{entity}.@refill
The results is network representation.@refill
If @var{entity} is omitted, @code{mime-message-structure} is used as
default value.@refill
If @var{field-name} field is not found, this function returns
@code{nil}.
@end defun
@defun mime-read-field field-name &optional entity
Parse @var{field-name} field in header of @var{entity}, and return the
result.@refill
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.@refill
Strings in the result will be converted to internal representation of
Emacs.@refill
If @var{entity} is omitted, @code{mime-message-structure} is used as
default value.@refill
If @var{field-name} field is not found, this function returns
@code{nil}.
@end defun
@node entity formatting, Entity-content, Entity-header, Entity
@section Text presentation of entity
@defun mime-insert-header entity &optional invisible-fields visible-fields
Insert before point a decoded contents of header of @var{entity}.@refill
@var{invisible-fields} is list of regexps to match field-name to hide.
@var{visible-fields} is list of regexps to match field-name to
hide.@refill
If a field-name is matched with some elements of @var{invisible-fields}
and matched with none of @var{visible-fields}, this function don't
insert the field.@refill
Each encoded-word (@ref{encoded-word}) in the header is decoded. ``Raw
non us-ascii characters'' are also decoded as
@code{default-mime-charset}.
@end defun
@defun mime-insert-text-content entity
Insert before point a contents of @var{entity} as text entity.@refill
Contents of the @var{entity} are decoded as MIME charset (@ref{MIME charset}). If the @var{entity} does not have charset parameter of
Content-Type field, @code{default-mime-charset} is used as default
value.
@end defun
@defvar default-mime-charset
Symbol to indicate default value of MIME charset (@ref{MIME charset}).@refill
It is used when MIME charset is not specified.@refill
It is originally variable of APEL.
@end defvar
@node Entity-content, Entity-network-representation, entity formatting, Entity
@section Contents of Entity
@defun mime-entity-content entity
Return content of @var{entity} as byte sequence.
@end defun
@defun mime-insert-entity-content entity
Insert content of @var{entity} at point.
@end defun
@defun mime-write-entity-content entity filename
Write content of @var{entity} into @var{filename}.
@end defun
@node Entity-network-representation, Entity buffer, Entity-content, Entity
@section Network representation of Entity
@defun mime-insert-entity entity
Insert header and body of @var{entity} at point.
@end defun
@defun mime-write-entity entity filename
Write representation of @var{entity} into @var{filename}.
@end defun
@defun mime-write-entity-body entity filename
Write body of @var{entity} into @var{filename}.
@end defun
@node Entity buffer, mm-backend, Entity-network-representation, Entity
@section Entity as buffer representation
@defun mime-entity-buffer entity
Return buffer, which contains @var{entity}.
@end defun
@defun mime-entity-point-min entity
Return the start point of @var{entity} in the buffer which contains
@var{entity}.
@end defun
@defun mime-entity-point-max entity
Return the end point of @var{entity} in the buffer which contains
@var{entity}.
@end defun
@defun mime-entity-header-start entity
Return the start point of header of @var{entity} in the buffer which
contains @var{entity}.
@end defun
@defun mime-entity-header-end entity
Return the end point of header of @var{entity} in the buffer which
contains @var{entity}.
@end defun
@defun mime-entity-body-start entity
Return the start point of body of @var{entity} in the buffer which
contains @var{entity}.
@end defun
@defun mime-entity-body-end entity
Return the end point of body of @var{entity} in the buffer which
contains @var{entity}.
@end defun
@node mm-backend, , Entity buffer, Entity
@section Entity representations and implementations
@cindex mm-backend
@cindex entity processing method
@cindex representation-type
Entity is an abstraction. It is designed to use various data
representations for their purposes.@refill
Each entity has @strong{representation-type}. It must be specified when
an entity is created. (cf. @ref{Entity creation}) @refill
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 @strong{entity processing method}. A module,
consists of them corresponding with a representation-type, is called
@strong{mm-backend}.@refill
Module name of each mm-backend consists of the prefix @code{mm}
and its representation-type. The module is required automatically
when its entity is created at first.
@menu
* Request for entity:: Message-passing for entity
* mm-backend module:: Definition of mm-backend
@end menu
@node Request for entity, mm-backend module, mm-backend, mm-backend
@subsection Message-passing for entity
@defun mime-entity-send entity message &rest args
Send @var{message} to @var{entity} with @var{args}, and return the
result.@refill
@var{args} is arguments of the @var{message}.
@end defun
@node mm-backend module, , Request for entity, mm-backend
@subsection Definition of mm-backend
@defmac mm-define-backend type &optional parents
Define @var{type} as a mm-backend.@refill
If @var{PARENTS} is specified, @var{type} inherits parents. Each parent
must be representation-type.@refill
Example:@refill
@lisp
(mm-define-backend chao (generic))
@end lisp
@end defmac
@defmac mm-define-method name args &rest body
Define @var{name} as a method function of (nth 1 (car @var{args}))
backend.@refill
@var{args} is like an argument list of lambda, but (car @var{args}) must
be specialized parameter. (car (car @var{args})) is name of variable
and (nth 1 (car @var{args})) is name of backend
(representation-type).@refill
Example:@refill
@lisp
(mm-define-method entity-cooked-p ((entity chao)) nil)
@end lisp
@end defmac
@node Content-Type, Content-Disposition, Entity, Top
@chapter Information of Content-Type field
@cindex mime-content-type
@cindex Content-Type field
@strong{Content-Type field} is a field to indicate kind of contents or
data format, such as media-type (@ref{media-type}) and MIME charset. It
is defined in RFC 2045 (@ref{RFC 2045}).
@noindent
@strong{[Memo]}
@quotation
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.
@end quotation
FLIM provides parser for Content-Type field and structure
@strong{mime-content-type} to store information of
Content-Type field.
@menu
* Content-Type field:: Format of Content-Type field
* mime-content-type:: mime-content-type structure
* Content-Type parser:: Parser
* Content-Type utility:: Utility functions
@end menu
@node Content-Type field, mime-content-type, Content-Type, Content-Type
@section Format of Content-Type field
@cindex parameter
@cindex subtype
@cindex type
Format of Content-Type field is defined as follows:
@quotation
``Content-Type'' ``:'' @strong{type} ``/''
@strong{subtype} *( ``;'' @strong{parameter} )
@end quotation
For example:
@quotation
@example
Content-Type: image/jpeg
@end example
@end quotation
@quotation
@example
Content-Type: text/plain; charset=iso-2022-jp
@end example
@end quotation
`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.
@noindent
@strong{[Memo]}
@quotation
If an entity does not have Content-Type field, it is regarded as
following:
@quotation
@example
Content-Type: text/plain; charset=us-ascii
@end example
@end quotation
@noindent
(cf. @ref{us-ascii})
@end quotation
@node mime-content-type, Content-Type parser, Content-Type field, Content-Type
@section mime-content-type structure
@deffn{Structure} mime-content-type
Structure to store information of a Content-Type field.@refill
Applications should use reference functions
@code{mime-content-type-SLOT} to refer information of the
structure.@refill
Slots of the structure are following:
@table @var
@item primary-type
primary type of media-type (symbol).
@item subtype
subtype of media-type (symbol).
@item parameters
parameters of Content-Type field (association-list).
@end table
@end deffn
@defun make-mime-content-type type subtype
&optional parameters
Constructor of content-type.
@end defun
@defun mime-content-type-parameter content-type parameter
Return value of @var{parameter} of @var{content-type}.
@end defun
@node Content-Type parser, Content-Type utility, mime-content-type, Content-Type
@section Parser
@defun mime-parse-Content-Type string
Parse @var{string} as a field-body of Content-Type field, and return the
result as mime-content-type (@ref{mime-content-type}) structure.
@end defun
@defun mime-read-Content-Type
Parse Content-Type field of the current buffer, and return the result as
mime-content-type (@ref{mime-content-type}) structure.@refill
Return @code{nil} if Content-Type field is not found.
@end defun
@node Content-Type utility, , Content-Type parser, Content-Type
@section Utility functions
@defun mime-type/subtype-string type &optional subtype
Return type/subtype string from @var{type} and @var{subtype}.
@end defun
@node Content-Disposition, Content-Transfer-Encoding, Content-Type, Top
@chapter Information of Content-Disposition field
@cindex mime-content-disposition
@cindex RFC 2183
@cindex Standards Track
@cindex Content-Disposition field
@strong{Content-Disposition field} is an optional field to
specify presentation of an entity or attributes of an entity, such as
file name.
@noindent
[RFC 2183]
@quotation
S. Dorner, K. Moore and R. Troost, ``Communicating Presentation
Information in Internet Messages: The Content-Disposition Header'',
August 1997, Standards Track.
@end quotation
FLIM provides parser for Content-Disposition field and structure
@strong{mime-content-disposition} to store information of
Content-Disposition field.
@menu
* mime-content-disposition:: mime-content-disposition structure
* Content-Disposition parser:: Parser for Content-Disposition field
@end menu
@node mime-content-disposition, Content-Disposition parser, Content-Disposition, Content-Disposition
@section mime-content-disposition structure
@deffn{Structure} mime-content-disposition
Structure to store information of a Content-Disposition field.@refill
Applications should use reference functions
@code{mime-content-disposition-SLOT} to refer information of the
structure.@refill
Slots of the structure are following:
@table @var
@item disposition-type
disposition-type (symbol).
@item parameters
parameters of Content-Disposition field
(association-list).
@end table
@end deffn
@defun mime-content-disposition-parameter content-disposition parameter
Return value of @var{parameter} of @var{content-disposition}.
@end defun
@defun mime-content-disposition-filename content-disposition
Return filename of @var{content-disposition}.
@end defun
@node Content-Disposition parser, , mime-content-disposition, Content-Disposition
@section Parser for Content-Disposition field
@defun mime-parse-Content-Disposition string
Parse @var{string} as field-body of Content-Disposition field, and
return the result as mime-content-disposition
(@ref{mime-content-disposition}) structure.
@end defun
@defun mime-read-Content-Disposition
Parse Content-Disposition field of the current buffer, and return the
result as mime-content-disposition (@ref{mime-content-disposition})
structure.@refill
Return @code{nil} if Content-Disposition field is not found.
@end defun
@node Content-Transfer-Encoding, encoded-word, Content-Disposition, Top
@chapter Encoding Method
@cindex Content-Transfer-Encoding field
@strong{Content-Transfer-Encoding field} is a header field to indicate
body encoding of a entity.@refill
FLIM provides parser functions for Content-Transfer-Encoding field.
They represent information of Content-Transfer-Encoding field as
string.@refill
In addition, FLIM provides encoder/decoder functions by
Content-Transfer-Encoding.
@menu
* Content-Transfer-Encoding parser:: Parser
* encoder/decoder:: Encoder/decoder
* Encoding information:: Other utilities
* mel-backend:: How to write encoder/decoder module
* generic function for mel-backend:: How to add encoding/decoding service
@end menu
@node Content-Transfer-Encoding parser, encoder/decoder, Content-Transfer-Encoding, Content-Transfer-Encoding
@section Parser
@defun mime-parse-Content-Transfer-Encoding string
Parse @var{string} as a field-body of Content-Transfer-Encoding field,
and return the result.
@end defun
@defun mime-read-Content-Transfer-Encoding &optional default-encoding
Parse Content-Transfer-Encoding field of the current buffer, and return
the result.@refill
Return @var{default-encoding} if Content-Transfer-Encoding field is not
found. If it is not specified, @code{nil} is used as the default value.
@end defun
@node encoder/decoder, Encoding information, Content-Transfer-Encoding parser, Content-Transfer-Encoding
@section Encoder/decoder
@defun mime-encode-region start end encoding
Encode region @var{start} to @var{end} of current buffer using
@var{encoding}.
@end defun
@defun mime-decode-region start end encoding
Decode region @var{start} to @var{end} of current buffer using
@var{encoding}.
@end defun
@defun mime-decode-string string encoding
Decode @var{string} which is encoded in @var{encoding}, and return the
result.
@end defun
@defun mime-insert-encoded-file filename encoding
Insert file @var{FILENAME} encoded by @var{ENCODING} format.
@end defun
@defun mime-write-decoded-region start end filename encoding
Decode and write current region encoded by @var{encoding} into
@var{filename}.@refill
@var{start} and @var{end} are buffer positions.
@end defun
@node Encoding information, mel-backend, encoder/decoder, Content-Transfer-Encoding
@section Other utilities
@defun mime-encoding-list &optional SERVICE
Return list of Content-Transfer-Encoding.@refill
If @var{service} is specified, it returns available list of
Content-Transfer-Encoding for it.
@end defun
@defun mime-encoding-alist &optional SERVICE
Return table of Content-Transfer-Encoding for completion.@refill
If @var{service} is specified, it returns available list of
Content-Transfer-Encoding for it.
@end defun
@node mel-backend, generic function for mel-backend, Encoding information, Content-Transfer-Encoding
@section How to write encoder/decoder module
@defmac mel-define-method name args &rest body
Define @var{name} as a method function of (nth 1 (car (last
@var{args}))) backend.@refill
@var{args} is like an argument list of lambda, but (car (last
@var{args})) must be specialized parameter. (car (car (last
@var{args}))) is name of variable and (nth 1 (car (last @var{args}))) is
name of backend (encoding).@refill
Example:@refill
@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)
)))
@end lisp
@end defmac
@defmac mel-define-method-function spec function
Set @var{spec}'s function definition to @var{function}.@refill
First element of @var{spec} is service.@refill
Rest of @var{args} is like an argument list of lambda, but (car (last
@var{args})) must be specialized parameter. (car (car (last
@var{args}))) is name of variable and (nth 1 (car (last @var{args}))) is
name of backend (encoding).@refill
Example:@refill
@lisp
(mel-define-method-function (mime-encode-string string (nil "base64"))
'encode-base64-string)
@end lisp
@end defmac
@node generic function for mel-backend, , mel-backend, Content-Transfer-Encoding
@section How to add encoding/decoding service
@defmac mel-define-service name &optional args doc-string
Define @var{name} as a service for Content-Transfer-Encodings.@refill
If @var{args} is specified, @var{name} is defined as a generic function
for the service.@refill
Example:@refill
@lisp
(mel-define-service encoded-text-encode-string (string encoding)
"Encode STRING as encoded-text using ENCODING.
ENCODING must be string.")
@end lisp
@end defmac
@node encoded-word, custom, Content-Transfer-Encoding, Top
@chapter Network representation of header
@cindex RFC 2047
@cindex Standards Track
@cindex encoded-word
@cindex RFC 2047
@strong{RFC 2047} defines the @strong{encoded-word} which is a format to
represent non-ASCII (@ref{ASCII}) characters in a header.@refill
@noindent
[RFC 2047]
@quotation
K. Moore, ``MIME (Multipurpose Internet Mail Extensions) Part Three:
Message Header Extensions for Non-ASCII Text'', November 1996, Standards
Track (obsolete RFC 1521,1522,1590).
@end quotation
The encoded-word is the only valid format to represent non-ASCII
(@ref{ASCII}) characters in a header, but there are also invalid styles.
Such kinds of evil messages represent non-ASCII (@ref{ASCII}) characters
in headers without encoded-words (it is called "raw" non-ASCII
(@ref{ASCII}) characters).@refill
FLIM provides encoding/decoding features of both encoded-word and
invalid "raw" non-ASCII (@ref{ASCII}) characters.
@menu
* Header encoder/decoder:: Header encoding/decoding
@end menu
@node Header encoder/decoder, , encoded-word, encoded-word
@section Header encoding/decoding
@defun eword-decode-header &optional code-conversion separator