.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45) .\" .\" 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 .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . 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 .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Required to disable full justification in groff 1.23.0. .if n .ds AD l .\" ======================================================================== .\" .IX Title "MIME::Type 3" .TH MIME::Type 3 2026-01-05 "perl v5.42.0" "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\->isText) # 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" MIME types are used in MIME entities, for instance as part of e\-mail and HTTP 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: \fB""""\fR stringification" 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 \fBtype()\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 .IP "overload: \fB==\fR numerical comparison" 4 .IX Item "overload: == numerical comparison" Compare whether the \fBtype()\fR of the objects is the same. .IP "overload: \fBcmp\fR string comparison" 4 .IX Item "overload: cmp string comparison" When a MIME::Type object is compared to either a string or another MIME::Type, the \fBequals()\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. .SH METHODS .IX Header "METHODS" .SS Initiation .IX Subsection "Initiation" .ie n .IP $class\->\fBnew\fR(%options) 4 .el .IP \f(CW$class\fR\->\fBnew\fR(%options) 4 .IX Item "$class->new(%options)" Create (\fIinstantiate\fR) a new MIME::Type object which manages one mime type. .Sp .Vb 7 \& \-Option \-\-Default \& charset undef \& encoding \& extensions [] \& simplified \& system undef \& type .Ve .RS 4 .ie n .IP "charset => $charset" 2 .el .IP "charset => \f(CW$charset\fR" 2 .IX Item "charset => $charset" Specify the default charset for this type. .IP "encoding => \*(Aq7bit\*(Aq|\*(Aq8bit\*(Aq|\*(Aqbase64\*(Aq|\*(Aqquoted\-printable\*(Aq" 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 => STRING" 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 => REGEX" 2 .IX Item "system => REGEX" Regular expression which defines for which systems this rule is valid. The REGEX is matched on \f(CW$^O\fR. .IP "type => STRING" 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\->\fBcharset\fR() 4 .el .IP \f(CW$obj\fR\->\fBcharset\fR() 4 .IX Item "$obj->charset()" [2.28] RFC6657 prescribes that IANA registrations for text category types explicitly state their default character\-set. MIME\-Types contains a manually produced list of these defaults. .Sp This method may also return \f(CW\*(C`_REQUIRED\*(C'\fR, when there is no default, or \&\f(CW\*(C`_FRAMED\*(C'\fR when the charset is determined by the content. .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 "$any\->\fBsimplified\fR( [$string] )" 4 .el .IP "\f(CW$any\fR\->\fBsimplified\fR( [$string] )" 4 .IX Item "$any->simplified( [$string] )" Returns the simplified mime type for this object or the specified STRING. 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 \fBsimplified()\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\->\fBdefaultCharset\fR() 4 .el .IP \f(CW$obj\fR\->\fBdefaultCharset\fR() 4 .IX Item "$obj->defaultCharset()" [2.29] As per RFC6657, all \f(CW\*(C`text/*\*(C'\fR types must either specify a default charset in its IANA registration, or require the charset parameter. Non\-text types may require a charset as well. .Sp It is hard to extract this information from the IANA registration files automagically, so is manually maintained. .Sp » example: default charset use .Sp .Vb 1 \& $charset //= $type\->defaultCharset // \*(Aqutf\-8\*(Aq; .Ve .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 type as \f(CW$string\fR or other \f(CW$mime\fR type object. In case of a \f(CW$string\fR, 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 \fBisText()\fR. .ie n .IP $obj\->\fBisBinary\fR() 4 .el .IP \f(CW$obj\fR\->\fBisBinary\fR() 4 .IX Item "$obj->isBinary()" Returns \f(CW\*(C`true\*(C'\fR when the type is not known to be text. See \fBisText()\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 IANA 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 \f(CW\*(C`false\*(C'\fR. .ie n .IP $obj\->\fBisSignature\fR() 4 .el .IP \f(CW$obj\fR\->\fBisSignature\fR() 4 .IX Item "$obj->isSignature()" Returns \f(CW\*(C`true\*(C'\fR 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. Cast by \f(CWnew()\fR .SH "SEE ALSO" .IX Header "SEE ALSO" This module is part of MIME\-Types version 2.30, built on December 08, 2025. Website: \fIhttp://perl.overmeer.net/CPAN/\fR .SH LICENSE .IX Header "LICENSE" For contributors see file ChangeLog. .PP This software is copyright (c) 1999\-2025 by Mark Overmeer. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.