You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First off, thanks for the mime library. It's so simple and exactly what I need every time.
Recently, I've been working on a project that uses character sets base on custom mime types. This is similar to the API I have been using and I would like to suggest it as an addition to this library.
mime.charsets.lookup(mime, fallback)
Same as current implementation in terms of arguments and what it returns. Like Apache's AddDefaultCharset, this should return "UTF-8" if and only if mime is either text/plain or text/html. This, however, is only for the sake of convention.
mime.charsets.lookup("text/plain") -> "UTF-8"
mime.charsets.lookup("image/png") -> fallback or undefined
mime.charsets.define(obj)
The keys of obj are mime types and values of obj are charsets. Unlike mime.define(), values must be a String, not an Array. Previously declared mime types should be overridden.
Sets a charset based on the mime. Not in the spirit node-mime however this is an attempt to (somewhat) follow Apache's addCharset. This is obviously optional as mime.charsets.define(obj) duplicates this functionality.
Additionally, one could easily replicate Apache's addCharset by running:
mime.charsets.add(mime.lookup("x-mt"), "UTF-16")
Notes
Internally, node-mime should hold an Object of mime types pointing to a specific charset. Node-mime should also set mime.default_charset to 'UTF-8'. Whether or not this is the default for all mimes starting in text/* or just text/plain and text/html is up to you.
If you have neither the time nor the will, I would be happy to whip up a simple implementation and submit a pull-request.
The text was updated successfully, but these errors were encountered:
First off, thanks for the mime library. It's so simple and exactly what I need every time.
Recently, I've been working on a project that uses character sets base on custom mime types. This is similar to the API I have been using and I would like to suggest it as an addition to this library.
mime.charsets.lookup(mime, fallback)
Same as current implementation in terms of arguments and what it returns. Like Apache's AddDefaultCharset, this should return "UTF-8" if and only if mime is either
text/plain
ortext/html
. This, however, is only for the sake of convention.mime.charsets.define(obj)
The keys of
obj
are mime types and values ofobj
are charsets. Unlikemime.define()
, values must be a String, not an Array. Previously declared mime types should be overridden.mime.charsets.add(mime, charset)
Sets a charset based on the mime. Not in the spirit node-mime however this is an attempt to (somewhat) follow Apache's addCharset. This is obviously optional as
mime.charsets.define(obj)
duplicates this functionality.Additionally, one could easily replicate Apache's addCharset by running:
Notes
Internally, node-mime should hold an Object of mime types pointing to a specific charset. Node-mime should also set
mime.default_charset
to 'UTF-8'. Whether or not this is the default for all mimes starting intext/*
or justtext/plain
andtext/html
is up to you.If you have neither the time nor the will, I would be happy to whip up a simple implementation and submit a pull-request.
The text was updated successfully, but these errors were encountered: