.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "MIME::Type 3pm" .TH MIME::Type 3pm "2018-03-10" "perl v5.26.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" MIME::Type \- description of one MIME type .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 5 \& use MIME::Types; \& my $mimetypes = MIME::Types\->new; \& my MIME::Type $plaintext = $mimetypes\->type(\*(Aqtext/plain\*(Aq); \& print $plaintext\->mediaType; # text \& print $plaintext\->subType; # plain \& \& my @ext = $plaintext\->extensions; \& print "@ext" # txt asc c cc h hh cpp \& \& print $plaintext\->encoding # 8bit \& if($plaintext\->isBinary) # false \& if($plaintext\->isAscii) # true \& if($plaintext\->equals(\*(Aqtext/plain\*(Aq) {...} \& if($plaintext eq \*(Aqtext/plain\*(Aq) # same \& \& print MIME::Type\->simplified(\*(Aqx\-appl/x\-zip\*(Aq) # \*(Aqappl/zip\*(Aq .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\s-1MIME\s0 types are used in \s-1MIME\s0 entities, for instance as part of e\-mail and \s-1HTTP\s0 traffic. Sometimes real knowledge about a mime-type is need. Objects of \f(CW\*(C`MIME::Type\*(C'\fR store the information on one such type. .SH "OVERLOADED" .IX Header "OVERLOADED" .IP "overload: \fBstring comparison\fR" 4 .IX Item "overload: string comparison" When a MIME::Type object is compared to either a string or another MIME::TYpe, the \fIequals()\fR method is called. Comparison is smart, which means that it extends common string comparison with some features which are defined in the related RFCs. .IP "overload: \fBstringification\fR" 4 .IX Item "overload: stringification" The stringification (use of the object in a place where a string is required) will result in the type name, the same as \fItype()\fR returns. .Sp example: use of stringification .Sp .Vb 3 \& my $mime = MIME::Type\->new(\*(Aqtext/html\*(Aq); \& print "$mime\en"; # explicit stringification \& print $mime; # implicit stringification .Ve .SH "METHODS" .IX Header "METHODS" .SS "Initiation" .IX Subsection "Initiation" .IP "MIME::Type\->\fBnew\fR(%options)" 4 .IX Item "MIME::Type->new(%options)" Create (\fIinstantiate\fR) a new MIME::Type object which manages one mime type. .Sp .Vb 6 \& \-Option \-\-Default \& encoding \& extensions [] \& simplified \& system undef \& type .Ve .RS 4 .IP "encoding => '7bit'|'8bit'|'base64'|'quoted\-printable'" 2 .IX Item "encoding => '7bit'|'8bit'|'base64'|'quoted-printable'" How must this data be encoded to be transported safely. The default depends on the type: mimes with as main type \f(CW\*(C`text/\*(C'\fR will default to \f(CW\*(C`quoted\-printable\*(C'\fR and all other to \f(CW\*(C`base64\*(C'\fR. .IP "extensions => REF-ARRAY" 2 .IX Item "extensions => REF-ARRAY" An array of extensions which are using this mime. .IP "simplified => \s-1STRING\s0" 2 .IX Item "simplified => STRING" The mime types main\- and sub-label can both start with \f(CW\*(C`x\-\*(C'\fR, to indicate that is a non-registered name. Of course, after registration this flag can disappear which adds to the confusion. The simplified string has the \&\f(CW\*(C`x\-\*(C'\fR thingies removed and are translated to lower-case. .IP "system => \s-1REGEX\s0" 2 .IX Item "system => REGEX" Regular expression which defines for which systems this rule is valid. The \&\s-1REGEX\s0 is matched on \f(CW$^O\fR. .IP "type => \s-1STRING\s0" 2 .IX Item "type => STRING" The type which is defined here. It consists of a \fItype\fR and a \fIsub-type\fR, both case-insensitive. This module will return lower-case, but accept upper-case. .RE .RS 4 .RE .SS "Attributes" .IX Subsection "Attributes" .ie n .IP "$obj\->\fBencoding\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBencoding\fR()" 4 .IX Item "$obj->encoding()" Returns the type of encoding which is required to transport data of this type safely. .ie n .IP "$obj\->\fBextensions\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBextensions\fR()" 4 .IX Item "$obj->extensions()" Returns a list of extensions which are known to be used for this mime type. .ie n .IP "$obj\->\fBsimplified\fR( [$string] )" 4 .el .IP "\f(CW$obj\fR\->\fBsimplified\fR( [$string] )" 4 .IX Item "$obj->simplified( [$string] )" .PD 0 .IP "MIME::Type\->\fBsimplified\fR( [$string] )" 4 .IX Item "MIME::Type->simplified( [$string] )" .PD Returns the simplified mime type for this object or the specified \s-1STRING.\s0 Mime type names can get officially registered. Until then, they have to carry an \f(CW\*(C`x\-\*(C'\fR preamble to indicate that. Of course, after recognition, the \f(CW\*(C`x\-\*(C'\fR can disappear. In many cases, we prefer the simplified version of the type. .Sp example: results of \fIsimplified()\fR .Sp .Vb 2 \& my $mime = MIME::Type\->new(type => \*(Aqx\-appl/x\-zip\*(Aq); \& print $mime\->simplified; # \*(Aqappl/zip\*(Aq \& \& print $mime\->simplified(\*(Aqtext/PLAIN\*(Aq); # \*(Aqtext/plain\*(Aq \& print MIME::Type\->simplified(\*(Aqx\-xyz/x\-abc\*(Aq); # \*(Aqxyz/abc\*(Aq .Ve .ie n .IP "$obj\->\fBsystem\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBsystem\fR()" 4 .IX Item "$obj->system()" Returns the regular expression which can be used to determine whether this type is active on the system where you are working on. .ie n .IP "$obj\->\fBtype\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBtype\fR()" 4 .IX Item "$obj->type()" Returns the long type of this object, for instance \f(CW\*(Aqtext/plain\*(Aq\fR .SS "Knowledge" .IX Subsection "Knowledge" .ie n .IP "$obj\->\fBequals\fR($string|$mime)" 4 .el .IP "\f(CW$obj\fR\->\fBequals\fR($string|$mime)" 4 .IX Item "$obj->equals($string|$mime)" Compare this mime-type object with a \s-1STRING\s0 or other object. In case of a \s-1STRING,\s0 simplification will take place. .ie n .IP "$obj\->\fBisAscii\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBisAscii\fR()" 4 .IX Item "$obj->isAscii()" Old name for \fIisText()\fR. .ie n .IP "$obj\->\fBisBinary\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBisBinary\fR()" 4 .IX Item "$obj->isBinary()" Returns true when the type is not known to be text. See \fIisText()\fR. .ie n .IP "$obj\->\fBisExperimental\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBisExperimental\fR()" 4 .IX Item "$obj->isExperimental()" [2.00] Return \f(CW\*(C`true\*(C'\fR when the type is defined for experimental use; the subtype starts with \f(CW\*(C`x.\*(C'\fR .ie n .IP "$obj\->\fBisPersonal\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBisPersonal\fR()" 4 .IX Item "$obj->isPersonal()" [2.00] Return \f(CW\*(C`true\*(C'\fR when the type is defined by a person for private use; the subtype starts with \f(CW\*(C`prs.\*(C'\fR .ie n .IP "$obj\->\fBisRegistered\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBisRegistered\fR()" 4 .IX Item "$obj->isRegistered()" Mime-types which are not registered by \s-1IANA\s0 nor defined in RFCs shall start with an \f(CW\*(C`x\-\*(C'\fR. This counts for as well the media-type as the sub-type. In case either one of the types starts with \f(CW\*(C`x\-\*(C'\fR this method will return false. .ie n .IP "$obj\->\fBisSignature\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBisSignature\fR()" 4 .IX Item "$obj->isSignature()" Returns true when the type is in the list of known signatures. .ie n .IP "$obj\->\fBisText\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBisText\fR()" 4 .IX Item "$obj->isText()" [2.05] All types which may have the charset attribute, are text. However, there is currently no record of attributes in this module... so we guess. .ie n .IP "$obj\->\fBisVendor\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBisVendor\fR()" 4 .IX Item "$obj->isVendor()" [2.00] Return \f(CW\*(C`true\*(C'\fR when the type is defined by a vendor; the subtype starts with \f(CW\*(C`vnd.\*(C'\fR .ie n .IP "$obj\->\fBmediaType\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBmediaType\fR()" 4 .IX Item "$obj->mediaType()" The media type of the simplified mime. For \f(CW\*(Aqtext/plain\*(Aq\fR it will return \f(CW\*(Aqtext\*(Aq\fR. .Sp For historical reasons, the \f(CW\*(AqmainType\*(Aq\fR method still can be used to retrieve the same value. However, that method is deprecated. .ie n .IP "$obj\->\fBsubType\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBsubType\fR()" 4 .IX Item "$obj->subType()" The sub type of the simplified mime. For \f(CW\*(Aqtext/plain\*(Aq\fR it will return \f(CW\*(Aqplain\*(Aq\fR. .SH "DIAGNOSTICS" .IX Header "DIAGNOSTICS" .IP "Error: Type parameter is obligatory." 4 .IX Item "Error: Type parameter is obligatory." When a MIME::Type object is created, the type itself must be specified with the \f(CW\*(C`type\*(C'\fR option flag. .SH "SEE ALSO" .IX Header "SEE ALSO" This module is part of MIME-Types distribution version 2.17, built on January 26, 2018. Website: \fIhttp://perl.overmeer.net/CPAN/\fR .SH "LICENSE" .IX Header "LICENSE" Copyrights 1999\-2018 by [Mark Overmeer ]. For other contributors see ChangeLog. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See \fIhttp://dev.perl.org/licenses/\fR