Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. File name contains garbled or special characters when download.

File name contains garbled or special characters when download.

Scheduled Pinned Locked Moved ASP.NET
databasehelptutorial
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Satish_S
    wrote on last edited by
    #1
          filename1 = "のサンプル";
          Response.Clear();
          Response.ContentType = "text/comma-separated-values";
          Response.ContentEncoding = System.Text.Encoding.GetEncoding( 932 );
          Response.AppendHeader("Content-Disposition", "filename=\\"" +   filename + "\\"");
          Response.WriteFile(filepath);
          Response.Flush();
          System.IO.File.Delete(filepath);
    

    Above code is used for downloading japanese file, when using as above i am getting file downloaded but the file when it shows in file save as dialog contains some machine mixed special characters(non ascii). expected file name is

    のサンプル

    .xls and not like "a1/4a...." How to over come this issue. Hi As i found in the forum link i used this function to convert file name but this too didnt helped me out.

    public static string EncodeTwit(string txt)
    {
    UTF8Encoding utf8 = new UTF8Encoding();
    byte[] bytes = utf8.GetBytes(txt);
    char[] chars = new char[bytes.Length];
    for (int index = 0; index < bytes.Length; index++)
    {
    chars[index] = Convert.ToChar(bytes[index]);
    }

        string s = new string(chars);
        return s;
    }
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups