This URI escape for Chinese character has being bugging me for quite sometime.

I have a filename saved in my data with mixed letters so as Chinese characters in base64 encoded. However, when I execute a file Download request, I unable to get the save file to appear back to original Chinese characters filename. I'm not sure if it can be done or not. For now, they are all in standard uri_escape.

I also tried using uri_escape_utf8 result still same. It will become something like "...chinese%20%27%E9%A1%B6%E9%A1%B6.....png". The original Chinese filename is "chinese '顶顶顶顶' & 123.png" just for testing.

In download script;

use URI::Escape; .... $fname = uri_escape($fname); .... print "Content-length: $fsize\n"; print "Content-Disposition: attachment; filename=$fname\n"; print "Content-Type: application/force-download;\n\n"; ....

The download script works fine. Just when download file that contain Chinese characters filename, I can't get it Save in Chinese characters. The filename stored in my data base64 are decoded properly.

Could someone please give me some suggestions or that is just the way how it works? Many thanks.


In reply to URI escape Chinese characters on file download by hankcoder

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.