SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    writing filenames in utf8 (chinese characters) to the server

    Hi there,
    We have a file uploading script; it works fine with regular filenames;
    however, when uploading filenames with utf8 characters (ex, chinese, japanese), the files are saved with weird characters.

    here is our form:
    <FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="process.asp" accept-charset="UTF-8">
    <input type=file name="FILE1">
    ....
    </form>

    The script processing this file is (relevant section):

    Session.CodePage = 65001
    Response.CharSet = "UTF-8"


    Set oFS = Server.CreateObject("Scripting.FileSystemObject")
    Set oFile = oFS.CreateTextFile(sPath & Filename,true)



    When I do response.write File.FileName it displays the correct chinese characters to the browser.
    However, when I actually look at the file created on the server, I am seeing weird characters like: &#229;‚&#228;&#188;š&#228;&#187;&#163;&#232;&#161;&#168;2.JPG

    Any advice would be much appreciated,

    Thanks!

  2. #2
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    675
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    However, when I actually look at the file created on the server, I am seeing weird characters like: &#229;�‚&#228;&#188;š&#228;&#187;&#163;&#232;&#161;&#168;2.JPG
    This is not an ASP issue.

    Best guess is that the application in use to view the server files is not configured to support chinese characters....

  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,494
    Mentioned
    164 Post(s)
    Tagged
    1 Thread(s)
    Maybe this SitePoint article will help?
    The Definitive Guide to Web Character Encoding

  4. #4
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply guys.

    I am using window's native folder viewer to view the files uploaded. If I manually create a file with chinese (or other unicode) names, they show up fine.

    So it seems unlikely that it is the viewing app that is causing the file names to show up weird.

    Also, thank you for that article, it seems to talk about unicode displayed on the browser's side; we have this covered already as our sites do show up in chinese correctly.

    Its only when filenames with chinese characters get uploaded that they show up weird characters in the server's folder.

    Am I missing something here in my asp code, or possibly an IIS config parameter that may be causing this ?


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •