in reply to UTF-8 woes with file upload

Very likely the input you receive from the browser isn't utf-8 encoded.

the big issue is that AFAIK there is no standard that describes the encoding that should be used when uploading text files. Probably the file is sent in whatever encoding it was in originally. Even more annoying is that you'll probably get no indication of what that encoding is.

Since file uploads and POST data is read from STDIN and STDIN is normally not used for anything else, you may be able to explicitly set the IO layers for STDIN to raw prior to processing the input.

After you've received the uploaded data from CGI, you can then try to decode the data as utf-8 or latin-1 / latin-15 (which, assuming you're in the USA or europe are probably the most common encodings).

Replies are listed 'Best First'.
Re^2: UTF-8 woes with file upload
by daxim (Curate) on Aug 17, 2007 at 19:46 UTC