[cgiapp] file uploads and encodings

ĵohn sayļør jsaylor at liaison-intl.com
Mon Oct 4 17:13:05 EDT 2010


hola

On Mon, 2010-10-04 at 13:34 -0700, Todd Ross wrote:
> In order to convert _to_ EBCDIC, I need to know what I'm converting _from_.  And 
> therein lies my impossible problem; how does one determine the encoding of a 
> file upload?  The browser does provide some information in the form of the file 
> name and the mime type but neither would indicate whether the (text/plain) file 
> was encoded with ISO-8859-1 or UTF-8 or something else entirely.

i think you have to do this programmatically by examining the characters
in the file. there may be libraries to do this already somewhere, but i
have exerted no effort to find them.

as you mention, you can't count on users, and they can [and will] upload
just about anything.

good luck!

-- 
\js


More information about the cgiapp mailing list