-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmime-ja.texi
1626 lines (1074 loc) · 50.5 KB
/
mime-ja.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-ja.sgml by sinfo 3.7.
@setfilename mime-ja.info
@documentlanguage ja
@documentencoding utf-8
@settitle FLIM-LB 1.14 MIME 機能説明書
@dircategory GNU Emacs Lisp
@direntry
* FLIM-LB (ja): (mime-ja). Internet message library.
@end direntry
@titlepage
@title FLIM-LB 1.14 MIME 機能説明書
@author 守岡 知彦 <morioka@@jaist.ac.jp>
@author 伊藤 和博
@subtitle 2020-09-17
@end titlepage
@node Top, Introduction, (dir), (dir)
@top FLIM-LB 1.14 MIME 機能説明書
@ifinfo
This file documents MIME features of FLIM-LB, a fundamental library to
process Internet Messages for GNU Emacsen.@refill
GNU Emacsen 用の Internet Message 処理のための基礎 library である FLIM-LB
の MIME 機能に関して説明します。
@end ifinfo
@menu
* Introduction:: FLIM-LB って何?
* How to use:: FLIM の MIME 機能の使い方
* Entity:: Message と Entity
* Content-Type:: Content-Type 欄の情報
* Content-Disposition:: Content-Disposition 欄の情報
* Content-Transfer-Encoding:: 符号化法
* encoded-word:: Header の network 表現
* custom:: 一般設定
* Appendix:: 付録
* Concept Index:: 概念索引
* Function Index:: 関数索引
* Variable Index:: 変数索引
@end menu
@node Introduction, How to use, Top, Top
@chapter FLIM-LB って何?
FLIM は Internet Message の表現や符号化に関する基礎的な機能を提供する
ための library です。
FLIM-LB は FLIM のバリアントの一つで、
最新バージョンの Emacs への対応などを特徴とします。
@node How to use, Entity, Introduction, Top
@chapter FLIM の MIME 機能の使い方
FLIM の提供する MIME 機能を使うためには
@lisp
(require 'mime)
@end lisp
@noindent
を評価してください。
@node Entity, Content-Type, How to use, Top
@chapter Message と Entity
@cindex mime-entity
@cindex entity
RFC 2045 (@ref{RFC 2045}) によれば、「Entity という語は、message, もしく
は、multipart entity の body 中の1つの部分の、MIME で定義された header
field と内容を指す」となっています。ここでは、MIME で定義された header
field 以外の全ての header と body を指す語として @strong{entity}を用いる
ことにします。@refill
RFC 2045 の定義は、MIME message が entity を節とする木構造であることを示
しています。つまり、MIME は message を木構造に拡張した訳です。@refill
FLIM は entity の情報を表現するために@strong{mime-entity} 構
造体を用います。以下では単に mime-entity と呼ぶことにします。
@menu
* Entity creation:: Entity の生成
* Entity hierarchy:: Entity 階層
* Entity Search:: Entity の検索
* Entity Attributes:: Entity の属性
* Entity-header:: Entity header の情報
* entity formatting:: Entity の文字表現
* Entity-content:: Entity の内容
* Entity-network-representation:: Entity のネットワーク表現
* Entity buffer:: Entity の buffer による表現
* mm-backend:: Entity の表現と実現
@end menu
@node Entity creation, Entity hierarchy, Entity, Entity
@section Entity の生成
@defun mime-open-entity type location
Entity を開いて、それを返します。@refill
@var{type} は representation-type です。(cf. @ref{mm-backend}) @refill
@var{location} は entity の位置です。指定方法は
representation-type に依って変わります。
@end defun
@defun mime-parse-buffer &optional buffer type
@var{buffer} を message として構文解析し、その結果の mime-entity を
@var{buffer} の@code{mime-message-structure} に格納する。@refill
@var{buffer} が省略された場合、現在の buffer を構文解析する。@refill
@var{type} が指定された場合、その値を生成される mime-entity の表象型とし
て用いる。省略された場合は @var{buffer} となる。(cf. @ref{mm-backend})
@end defun
@node Entity hierarchy, Entity Search, Entity creation, Entity
@section Entity 階層
@cindex node-id
@cindex entity-number
@cindex message
@cindex root-entity
MIME message は entity を単位とする木構造になっています。@refill
この木において根となる節は message 全体を表す entity です。ここでは、こ
れを @strong{root-entity} もしくは@strong{message} と呼びます。@refill
root-entity 以外の entity は親を持ちます。また、entity は子供を持つかも
知れません。この親子関係を考えることで entity の相対関係を扱うことができ
ます。@refill
一方、entity の message における位置を考えることもできます。@refill
entity はこの木における節となりますが、この木には深さと同じ深さの中の
順番に従って番号が付けることができます。即ち、
@example
┌───┐
│ nil │
└─┬─┘
┌─────────┼─────────┐
┌┴┐ ┌┴┐ ┌┴┐
│0│ │1│ │2│
└┬┘ └┬┘ └┬┘
│ ┌────┼────┐ │
┌─┴─┐┌─┴─┐┌─┴─┐┌─┴─┐┌─┴─┐
│ 0.0││ 1.0││ 1.1││ 1.2││ 2.0│
└───┘└───┘└───┘└───┘└───┘
@end example
@noindent
のように深さ n の節には長さ n の整数列の節番号が振れます。これ
を @strong{entity-number} と呼びます。entity-number は S 式と
しては @code{(1 2 3)} のような整数のリストとして表現されます。
mime-entity では、これと同様の @strong{node-id} を用います。node-id はちょ
うど entity-number を逆にしたリストで、entity-number 1.2.3 に対応する
node-id は @code{(3 2 1)} です。@refill
前述のように、MIME message は entity を単位とした木構造になっているので、
この根である message 全体も mime-entity で表現することができ、buffer
local 変数 @code{mime-message-structure} に格納することにします。@refill
@code{mime-message-structure} を起点に entity-number や node-id
で示される entity を取り出すことができます。
@defvar mime-message-structure
現在の buffer における message 全体の mime-entity 構造体を格納するbuffer
local 変数。
@end defvar
@defun mime-entity-children entity
@var{entity} に含まれる entity の list を返す。
@end defun
@defun mime-entity-parent entity &optional message
@var{entity} の親の entity を返す。@refill
@var{message} が指定された場合、これを根と見倣す。
@end defun
@defun mime-root-entity-p entity
@var{entity} が根(即ち、message 全体)である場合に、非-@code{nil} を返
す。
@end defun
@defun mime-entity-node-id entity
@var{entity} の node-id を返す。
@end defun
@defun mime-entity-number entity
@var{entity} の entity-number を返す。
@end defun
@node Entity Search, Entity Attributes, Entity hierarchy, Entity
@section Entity の検索
@defun mime-find-entity-from-number entity-number &optional message
@var{message} から、@var{enity-number} の entity を返します。@refill
@var{message} が指定されていない場合は、
@code{mime-message-structrue} が使われます。
@end defun
@defun mime-find-entity-from-node-id entity-node-id &optional message
@var{message} から、@var{entity-node-id} の entity を返します。@refill
@var{message} が指定されていない場合は、
@code{mime-message-structure} が使われます。
@end defun
@defun mime-find-entity-from-content-id cid &optional message
@var{message} から、@var{cid} の entity を返します。@refill
@var{message} が指定されていない場合は、
@code{mime-message-structure} が使われます。
@end defun
@node Entity Attributes, Entity-header, Entity Search, Entity
@section Entity の属性
@defun mime-entity-content-type entity
@var{entity} の content-type を返す。(cf. @ref{mime-content-type})
@end defun
@defun mime-entity-content-disposition entity
@var{entity} の content-disposition を返す。
(cf. @ref{mime-content-disposition})
@end defun
@defun mime-entity-filename entity
@var{entity} の file 名を返す。
@end defun
@defun mime-entity-encoding entity &optional default-encoding
@var{entity} の content-transfer-encoding を返す。
(cf. @ref{Content-Transfer-Encoding}) @refill
もし、@var{entity} に Content-Transfer-Encoding 欄が存在しない場合は、
@var{default-encoding} を返す。これが指定されない場合は、@code{"7bit"}
を用いる。
@end defun
@defun mime-entity-cooked-p entity
@var{entity} の内容が既にコード変換されている場合は nil で無い値
を返す。
@end defun
@node Entity-header, entity formatting, Entity Attributes, Entity
@section Entity header の情報
@defun mime-fetch-field field-name &optional entity
@var{entity} の header 中の @var{field-name} 欄の body を返す。@refill
結果の文字列は network 表現のままである。@refill
@var{entity} が省略された場合は、@code{mime-message-structure} の値を用
いる。@refill
@var{field-name} 欄が存在しない場合は @code{nil} を返す。
@end defun
@defun mime-read-field field-name &optional entity
@var{entity} の header 中の @var{field-name} 欄を構文解析した結果を返す。
@refill
結果の形式は欄毎に異なる。非構造化欄の場合は文字列を返し、構造化欄の場合
はその形式に従った list を返す。@refill
結果中の文字列は Emacs の内部表現に変換される。@refill
@var{entity} が省略された場合は、@code{mime-message-structure} の値を用
いる。@refill
@var{field-name} 欄が存在しない場合は nil を返す。
@end defun
@node entity formatting, Entity-content, Entity-header, Entity
@section Entity の文字表現
@defun mime-insert-header entity &optional invisible-fields visible-fields
現在位置に @var{entity} の復号した header を挿入する。@refill
@var{invisible-fields} と @var{visible-fields} は正規表現のlist で、それ
ぞれ、表示したくない field 名と表示したい欄名を表現したものである。
@refill
@var{invisible-fields} の要素のどれかに match し、かつ、
@var{visible-fields} の要素のどれにも match しない欄は表示されない。
@refill
encoded-word (@ref{encoded-word}) は復号される。『生の非 us-ascii 文字』
は @code{default-mime-charset} として解釈される。
@end defun
@defun mime-insert-text-content entity
point の前に @var{entity} を text entity として挿入します。@refill
@var{entity} の内容は @ref{MIME charset} として復号化され
ます。@var{entity} の Content-Type field に charset paramter が無
いと、@code{default-mime-charset} が初期値として使われます。
@end defun
@defvar default-mime-charset
適切な MIME charset (@ref{MIME charset}) が見つからなかった場合に用いら
れるMIME charset.@refill
本来は APEL の変数である。
@end defvar
@node Entity-content, Entity-network-representation, entity formatting, Entity
@section Entity の内容
@defun mime-entity-content entity
@var{entity} の内容の byte 列を返す。
@end defun
@defun mime-insert-entity-content entity
point の位置に @var{entity} の内容を挿入します。
@end defun
@defun mime-write-entity-content entity filename
@var{entity} の内容を @var{filename} に書き込みます。
@end defun
@node Entity-network-representation, Entity buffer, Entity-content, Entity
@section Entity のネットワーク表現
@defun mime-insert-entity entity
@var{entity} の header と body を point のところに挿入します。
@end defun
@defun mime-write-entity entity filename
@var{entity} の表現を @var{filename} に書き込みます。
@end defun
@defun mime-write-entity-body entity filename
@var{entity} の body を @var{filename} に書き込みます。
@end defun
@node Entity buffer, mm-backend, Entity-network-representation, Entity
@section Entity の buffer による表現
@defun mime-entity-buffer entity
@var{entity} が存在する buffer を返す。
@end defun
@defun mime-entity-point-min entity
@var{entity} が存在する buffer における、@var{entity} が占める領域の先頭
位置を返す。
@end defun
@defun mime-entity-point-max entity
@var{entity} が存在する buffer における、@var{entity} が占める領域の末尾
位置を返す。
@end defun
@defun mime-entity-header-start entity
@var{entity} が存在する buffer における、header が占める領域の先頭位置を
返す。
@end defun
@defun mime-entity-header-end entity
@var{entity} が存在する buffer における、header が占める領域の末尾位置を
返す。
@end defun
@defun mime-entity-body-start entity
@var{entity} が存在する buffer における、body が占める領域の先頭位置を返
す。
@end defun
@defun mime-entity-body-end entity
@var{entity} が存在する buffer における、body が占める領域の末尾位置を返
す。
@end defun
@node mm-backend, , Entity buffer, Entity
@section Entity の表現と実現
@cindex mm-backend
@cindex entity 処理 method
@cindex representation-type
Entity は抽象化されたデータ表現で、実際のデータ表現としては用途に応じて
さまざまなものが利用できるように設計されています。@refill
ここで、entity がどういう種類の表現を行っているかを示すのが
@strong{representation-type} で、entity を生成する時にはこれを指定します。
(cf. @ref{Entity creation}) @refill
前節までに述べて来た entity に対する処理は、entity に対してその処理を依
頼することによって実現されています。Entity は自分の representation-type
を知っており、その representation-type に応じて実際の処理を行う関数を呼
び出します。このような関数を @strong{entity 処理method} と呼びます。また、
representation-type 毎にこのような関数をまとめたものを
@strong{mm-backend} と呼びます。@refill
mm-backend は representation-type の名前の先頭に @code{mm} という
接頭辞を付けた関数名からなる module で、その module 名は同様に
representation-type の名前の先頭に @code{mm} を付けたものになって
います。この module は representation-type の entity が最初に生成される
時に自動的に require されます。
@menu
* Request for entity:: Entity への便り
* mm-backend module:: mm-backend の作り方
@end menu
@node Request for entity, mm-backend module, mm-backend, mm-backend
@subsection Entity への便り
@defun mime-entity-send entity message &rest args
@var{entity} に @var{message} を送る。@refill
@var{args} は @var{message} の引数である。
@end defun
@node mm-backend module, , Request for entity, mm-backend
@subsection mm-backend の作り方
@defmac mm-define-backend type &optional parents
@var{type} を mm-backend として定義します。@refill
@var{PARENTS} が指定されている場合は、@var{type} は prents
を継承します。それぞれの parent は representation-type である必要があ
ります。
例:@refill
@lisp
(mm-define-backend chao (generic))
@end lisp
@end defmac
@defmac mm-define-method name args &rest body
@var{name} を (nth 1 (car @var{args})) backend の method 関
数として定義します。@refill
@var{args} は lambda の引数リストのようなものですが、(car
@var{args}) は指定された parameter である必要があります。(car
(car @var{args})) は変数の名前で、(nth 1 (car @var{args}))
は backend の名前 (representation-type) です。@refill
例:@refill
@lisp
(mm-define-method entity-cooked-p ((entity chao)) nil)
@end lisp
@end defmac
@node Content-Type, Content-Disposition, Entity, Top
@chapter Content-Type 欄の情報
@cindex mime-content-type
@cindex Content-Type 欄
@strong{Content-Type 欄} は media-type (@ref{media-type}) や MIME
charset といった entity (@ref{Entity}) の内容の種類や表現形式などを記述
するためのもので、RFC 2045 (@ref{RFC 2045}) で定義されています。
@noindent
@strong{[Memo]}
@quotation
歴史的には RFC 1049 で Content-Type 欄が提案されている。但し、MIME の
media-type のような type と subtype の区別はなく、MIME charset のような
文字符号の種類を表現することもできない。
@end quotation
FLIM は Content-Type 欄を構文解析する関数と Content-Type 欄の解析結果を
格納する構造体 @strong{mime-content-type} を提供します。
@menu
* Content-Type field:: Content-Type 欄の形式
* mime-content-type:: mime-content-type 構造体
* Content-Type parser:: Content-Type 欄の解析器
* Content-Type utility:: Content-Type に関する有用な関数
@end menu
@node Content-Type field, mime-content-type, Content-Type, Content-Type
@section Content-Type 欄の形式
@cindex parameter
@cindex subtype
@cindex type
Content-Type 欄の形式は以下のように定義されています:
@quotation
``Content-Type'' ``:'' @strong{type} ``/''
@strong{subtype} *( ``;'' @strong{parameter} )
@end quotation
例えば、
@quotation
@example
Content-Type: image/jpeg
@end example
@end quotation
@noindent
や
@quotation
@example
Content-Type: text/plain; charset=iso-2022-jp
@end example
@end quotation
@noindent
などのように用いられます。
ここで、`type' と `subtype' は entity の形式を示すもので、両者を総称し
て、`media-type' と呼ぶことにします。上記の例における `image/jpeg' や
`text/plain' は media-type の1つです。
@noindent
@strong{[Memo]}
@quotation
Content-Type 欄のない entity は
@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 構造体
@deffn{Structure} mime-content-type
Content-Type 欄の情報を格納するための構造体。@refill
この構造体を参照するには @code{mime-content-type-要素名} という名前の参
照関数を用いる。@refill
この構造体の要素は以下の通りである:
@table @var
@item primary-type
media-type の主型 (symbol).
@item subtype
media-type の副型 (symbol).
@item parameters
Content-Type 欄の parameter (連想 list).
@end table
@end deffn
@defun make-mime-content-type type subtype
&optional parameters
content-type の生成子。
@end defun
@defun mime-content-type-parameter content-type parameter
@var{content-type} の @var{parameter} の値を返す。
@end defun
@node Content-Type parser, Content-Type utility, mime-content-type, Content-Type
@section Content-Type 欄の解析器
@defun mime-parse-Content-Type string
@var{string} を content-type として解析した結果を返す。
@end defun
@defun mime-read-Content-Type
現在の buffer の Content-Type 欄を読み取り、解析した結果を返す。@refill
Content-Type 欄が存在しない場合は nil を返す。
@end defun
@node Content-Type utility, , Content-Type parser, Content-Type
@section Content-Type に関する有用な関数
@defun mime-type/subtype-string type &optional subtype
@var{type} と @var{subtype} から type/subtype 形式の文字列を返す。
@end defun
@node Content-Disposition, Content-Transfer-Encoding, Content-Type, Top
@chapter Content-Disposition 欄の情報
@cindex mime-content-disposition
@cindex RFC 2183
@cindex Standards Track
@cindex Content-Disposition 欄
@strong{Content-Disposition 欄} は entity の表示や file 名など
の属性になどに関する情報を記述するためのものです。
@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 は Content-Disposition 欄を構文解析する関数と Content-Disposition
欄の解析結果を格納する構造体
@strong{mime-content-disposition} を提供します。
@menu
* mime-content-disposition:: mime-content-disposition 構造体
* Content-Disposition parser:: Content-Disposition 欄の解析器
@end menu
@node mime-content-disposition, Content-Disposition parser, Content-Disposition, Content-Disposition
@section mime-content-disposition 構造体
@deffn{Structure} mime-content-disposition
Content-Disposition 欄の解析結果を収めるための構造体。@refill
この構造体を参照するには @code{mime-content-disposition-要素名} という名
前の参照関数を用いる。@refill
この構造体の要素は以下の通りである:
@table @var
@item disposition-type
disposition-type (symbol).
@item parameters
Content-Disposition 欄の parameter (連想 list).
@end table
@end deffn
@defun mime-content-disposition-parameter content-disposition parameter
@var{content-disposition} の @var{parameter} の値を返す。
@end defun
@defun mime-content-disposition-filename content-disposition
@var{content-disposition} の filename の値を返す。
@end defun
@node Content-Disposition parser, , mime-content-disposition, Content-Disposition
@section Content-Disposition 欄の解析器
@defun mime-parse-Content-Disposition string
@var{string} を content-disposition として解析した結果を返す。
@end defun
@defun mime-read-Content-Disposition
現在の buffer の Content-Disposition 欄を読み取り、解析した結果を返す。
@refill
Content-Disposition 欄が存在しない場合は nil を返す。
@end defun
@node Content-Transfer-Encoding, encoded-word, Content-Disposition, Top
@chapter 符号化法
@cindex Content-Transfer-Encoding 欄
@strong{Content-Transfer-Encoding 欄} は entity の符号化法を記述するため
のものです。@refill
FLIM では Content-Transfer-Encoding 欄を構文解析する関数を提供します。こ
れらの関数は Content-Transfer-Encoding 欄の情報は文字列で表現します。
@refill
また、Content-Transfer-Encoding に基づいて符号化・復号化を行う関数も提
供されます。
@menu
* Content-Transfer-Encoding parser:: Content-Transfer-Encoding 欄の解析器
* 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 Content-Transfer-Encoding 欄の解析器
@defun mime-parse-Content-Transfer-Encoding string
@var{string} を content-transfer-encoding として解析した結果を返す。
@end defun
@defun mime-read-Content-Transfer-Encoding &optional default-encoding
現在の buffer の Content-Transfer-Encoding 欄を読み取り、解析した結果を
返す。@refill
Content-Transfer-Encoding 欄が存在しない場合は@var{default-encoding} を
返す。
@end defun
@node encoder/decoder, Encoding information, Content-Transfer-Encoding parser, Content-Transfer-Encoding
@section 符号化・復号化
@defun mime-encode-region start end encoding
現在の buffer の @var{start} から @var{end} までの region を
@var{encoding} を使って符号化します。
@end defun
@defun mime-decode-region start end encoding
現在の buffer の @var{start} から @var{end} までの region を
@var{encoding} を使って復号化します。
@end defun
@defun mime-decode-string string encoding
@var{string} を @var{encoding} として復号した結果を返す。
@end defun
@defun mime-insert-encoded-file filename encoding
@var{ENCODING} format で符号化された file @var{FILENAME} を
挿入する。
@end defun
@defun mime-write-decoded-region start end filename encoding
@var{encoding} で符号化された現在の region を復号化して
@var{filename}に書き込みます。
<var>start<var> と @var{end} は buffer の位置です。
@end defun
@node Encoding information, mel-backend, encoder/decoder, Content-Transfer-Encoding
@section Other utilities
@defun mime-encoding-list &optional SERVICE
Content-Transfer-Encoding の list を返します。@refill
@var{service} が指定されていると、それに対する
Content-Transfer-Encoding を返します。
@end defun
@defun mime-encoding-alist &optional SERVICE
補完のための Content-Transfer-Encoding の表を返します。@refill
@var{service} が指定されている場合はそれに対する
Content-Transfer-Encoding の list を返します。
@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
@var{name} を (nth 1 (car (last @var{args}))) backend の
method 関数として定義します。
@var{args} は lambda の引数 list と似ていますが、(car (last
@var{args})) は指定された parameter である必要があります。(car
(car (last @var{args}))) は変数の名前で、(nth 1 (car (last
@var{args}))) は backend の名前 (encoding) です。@refill
例:@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
@var{spec} の関数定義を @var{function} に設定します。@refill
@var{spec} の最初の要素は service です。@refill
@var{args} の残りは lambda の引数 list 似ていますが、(car (last
@var{args})) は指定された parameter である必要があります。(car
(car (last @var{args}))) は変数の名前で、(nth 1 (car (last
@var{args}))) は backend の名前 (encoding) です。@refill
例:@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 符号化/復号化 service を追加する方法
@defmac mel-define-service name &optional args doc-string
@var{name} を Content-Transfer-Encoding の service として定義しま
す。@refill
@var{args} が指定されていると、@var{name} は service の
generic function として定義されます。@refill
例:@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 Header の network 表現
@cindex RFC 2047
@cindex Standards Track
@cindex RFC 2047
encoded-word は header で非 ASCII (@ref{ASCII}) 文字を表現するための形式
で、@strong{RFC 2047} で定義されています。@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
また、行儀の悪いことだと言えますが、encoded-word を用いずに非 ASCII
(@ref{ASCII}) 文字を header に入れた記事も存在します。@refill
FLIM はこれらを符号化・復号化する機能を提供します。
@menu
* Header encoder/decoder:: Header の符号化・復号化
@end menu
@node Header encoder/decoder, , encoded-word, encoded-word
@section Header の符号化・復号化
@defun eword-decode-header &optional code-conversion separator
Header 中の encoded-word を復号する。@refill
もし @var{code-conversion} が @code{nil} なら、encoded-word だけが復号さ
れる。もし、@var{code-conversion} が MIME charset (@ref{MIME charset})
なら、非 ASCII bit patterns はその MIME charset として復号される。これ以
外の場合、非 ASCII bit patterns は@code{default-mime-charset}. として復
号される。(cf. @ref{entity formatting}) @refill
もし @var{separator} が @code{nil} でなければ、その値がheader separator