Upload - use unicode (utf-8) character set for request/response data

Sample for ScriptUtils.ASPForm.CharSet | Changes | Purchase | Download


Upload - use unicode (utf-8) character set for request/response data 
'Sample file Unicode.asp
'Use unicode (utf-8) character set for request/response data.
  Dim Form: Set Form = Server.CreateObject("ScriptUtils.ASPForm")
  Response.CharSet = "utf-8"

  If Form.State = 0 Then 
    'Set conversion character set.
    Form.CharSet = Response.CharSet

    Dim DestFolder: DestFolder = Server.MapPath("UploadFolder")
    'Saev source files
    Form.Files.Save DestFolder

    For Each Item In Form
      I = I + 1
      Response.Write "<br><br>Item no.:" & I
      Response.Write "<br>Length:" & Item.Length

      'Write unicode name of the source field.
      WriteUTF8Data "<br>Name:" & Item.Name
      If Item.IsFile Then
        'Write unicode value of the source file name.
        WriteUTF8Data "<br>File path:" & Item.FilePath

        'Write source UTF-8 representation (encoded) of the same value
        WriteUTF8Data "<br>Source path, encoded by UTF-8:" & Item.FilePath("x-ansi")
      Else' Item.IsFile then
        'Write contents for non-file fields.

        'Write unicode value of the source field.
        WriteUTF8Data "<br>Value:" & Item.String

        'Write source representation of the same value
        WriteUTF8Data "<br>Source value, encoded by UTF-8:" & Item.String("x-ansi")
      End If' Item.IsFile then

  End If

  'Create HTML output in ANSI code page
  Dim HTML
  HTML = "This form demonstrates use of unicode (utf-8) character set for text fields and file names<br>"
  HTML = HTML & "Try to write text / select filename with characters not in U.S. ASCII character subset.<br>"
  HTML = HTML & "<form name=file_upload method=POST ENCTYPE=multipart/form-data>"
  HTML = HTML & "<input Name=Description1 Size=50 Value=""Some non-U.S. ASCII chars - ̊؎""><br>"
  HTML = HTML & "<input Name=File1 Type=File><br>"
  HTML = HTML & "<input Value=Submit >> Type=Submit><br>"
  HTML = HTML & "</Form>"

WriteUTF8Data HTML

'Write utf-8 data using Session.CodePage
Sub WriteUTF8Data1(HTML)  

  Session.CodePage = 65001
  Response.Write HTML
End Sub

'Write utf-8 data using ScriptUtils.ByteArray, without session object.
Sub WriteUTF8Data(HTML)  

  Dim ByteArray
  Set ByteArray = CreateObject("ScriptUtils.ByteArray") 

  'set ByteArray charset to UTF-8 (code page 65001)
  ByteArray.CharSet = "utf-8"

  'Write HTML data to byte array
  ByteArray.String = HTML

  'Write binary data to output.
  Response.BinaryWrite ByteArray.ByteArray
End Sub

Other links for the Upload - use unicode (utf-8) character set for request/response data sample


The ASPForm collection retrieves the values of form elements posted to ASP script by a form using the POST method. ASPForm can process multipart/form-data or application/x-www-form-urlencoded data with length up to 2GB.


Huge ASP upload is easy to use, hi-performance ASP file upload component with progress bar indicator. This component lets you upload multiple files with size up to 4GB to a disk or a database along with another form fields. Huge ASP file upload is a most featured upload component on a market with competitive price and a great performance . The software has also a free version of asp upload with progress, called Pure asp upload , written in plain VBS, without components (so you do not need to install anything on server). This installation package contains also ScriptUtilities library. Script Utilities lets you create hi-performance log files , works with binary data , you can download multiple files with zip/arj compression, work with INI files and much more with the ASP utility.

© 1996 - 2011 Antonin Foller, Motobit Software | About, Contacts | e-mail: info@pstruh.cz

Other Motobit links:   IISTracer, real-time IIS monitor   ASP file upload - upload files to ASP. 
ActiveX/VBSScript registry editor  ActiveX NT User account manager  Export MDB/DBF from ASP Active LogFile  Email export  ActiveX/ASP Scripting Dictionary object