VBScript/ASP URLEncode function with charset (urlencode to utf-8 or other character encoding) Batch charset conversion - convert all .txt files in a folder from ibm-850 unicode utf-8 This sample contains short algorithm to convert more files (all files in one folder) from one character set to another. The sample works for any code page (unicode utf-8 -> shift-jis, windows-1250 -> utf-8, ..) and shorter files, the files are converted in memory and there is no good idea to use it for files over 100MB. (See
Charset conversion of very large files - 2GB and more).
Batch file conversion - character set and BOM detection of html files This sample can do batch conversion of text files with different code pages - Unicode, utf-8, windows-1250 and others to one selected code page. The algorithm contains simple detection of source file code page using BOM.
You can choose any destination charset. See also
ByteArray - save unicode data (string) as utf-8 with BOM to save files with BOM (unicode Little/Big, utf-8)
ASP gigabyte download - download over 2GB, 4GB, very large/huge files. ASP/VBScript source code to download of very large files using ASP. The download size is not limited by 2GB or 4GB of size, you can download files with any size, 10th of gigabytes or more.
The sample uses Response.BinaryWrite. Remember that IIS6 has a strong memory leak, so this code does not work with Windows 2003 SP1, you need Windows 2003 SP2 at least. The code works also with other versions of IIS (IIS1-5, IIS7) See also
Experience high memory usage in the W3wp.exe process
Memory leaks may occur when the BinaryWrite method is called
Several browsers (IE, Firefox) or http clients (winhttp) has a download size limit of 2GB or 4GB. See
http download over 2GB, 4GB - browser and server behaviorByteArray - Store data with another charset (ibm850) to a database This sample works with a text data column in a database with any character set. For example, if you work with utf-8 in ASP, but you need to store data as an ibm850 charset in a database. If you have next table:
CREATE TABLE [dbo].[textTable] (
[textColumn] [VARCHAR] (250) COLLATE SQL_AltDiction_CP850_CI_AI NULL
) ON [PRIMARY]
but your ASP will work with utf-8, you need a binary conversion between utf-8 and ibm850.
ByteArray - Convert data from BinaryRead to string ByteArray - Save the posted data. ByteArray - Fill byte array by a random data ByteArray - ASP download Advapi - Logon and impersonate user Advapi - RevertToSelf sample ASP timing Simple download Multiple files download with on-the-fly compression zip/arj ByteArray - HexString sample INI and integer value Timing informations. Kernel - Sleep for 2second Kernel - Get command line Kernel - Get name of the local computer Kernel - Get current directory Kernel - Kernel and user time taken by process. Kernel - Kernel and user time taken by current thread. Kernel - Get all envinronment strings. Kernel - One of the environment variable Kernel - Write temporary directory path Kernel - TickCount Write system variables. Same ASP sample with PureASP upload ZLib - Compress file Transfer compressed file from client to server using IE (special upload) ZLib - Accept compressed data on server-side ASP Kernel - Get exact consumed time of VBS function Kernel - Get exact duration of a VBS function using msPerformanceCounter LogFile - Get current path to the log file. LogFile - Specify one log file per week. LogFile - Sample ASP log of variant arguments. LogFile - Delete log file LogFile - String to log as one line LogFile - DateTimeFormat sample LogFile - Local/GMT date/time values LogFile - Sample of values on begin of line. LogFile - Encode values LogFile - Separator of logged values LogFile - Log some array value LogFile - Description of log file fields LogFile - Define comment on the beggining of file LogFile - Samples of Log method LogFile - Simple log file sample Set task priority in MS SQL Upload - Count and enumarate form fields, text fields and files. Upload - Enumerate source files and write file names Upload - Save extra upload info to a database Upload - Read short source data in one block Upload - Store up to 1MB data in memory Upload - Do not upload data greater than 1MB. Upload - Custom temporary folder Upload - Enumerate text fields in a form. Upload - Write source form data along with form fields Upload - Switch page using form state Upload - Enumerate source fields using index Upload - Save all source files to the specified path Upload - Count number of source fields with a specified name Upload - Write contents of all text form fields Upload - Use x-mac-ce code page for form data. Upload - Write names of all form fields Upload - Save source fields to different loactions Upload - Save form files with special name. Upload - Simple upload to database Upload - Upload of large files to database using AppendChunk method of RecordSet Upload - large files to MS SQL Server using a HexString property and UPDATETEXT SQL statement Upload - Simple asp upload Very short asp upload code with two source file fields and a description field.
Upload - use unicode (utf-8) character set for request/response data Convert string between windows-1250 and iso-8859-2 (or utf-8) charsets, ASP Multiselect fields (non-unique field names) Upload - Using a HexString property and Insert statement POST, ASPForm - Work with original posted data. Upload - Progress bar concept. Web browrser (IE/NN) does not accept response data when uploading. So there is one another way to show progress bar during upload - open a new client browser window with another server script on begginning of upload and access current uploading form from the second server script (task).
These two server upload tasks are join using
ScriptUtils.
ASPForm.
UploadID property (in the uploading task) and
ScriptUtils.
ASPForm.
getForm property (progress bar task). You can use
ScriptUtils.
ASPForm.
NewUploadID property to get unique upload ID, or you can get this ID by any other way (for example, using rnd() function).
Upload - upload with ie-style progress bar. Upload - Send an email with attachment Upload - Use ASPForm object in VB6 class Upload - Form parser and VBA 6 Upload - progress bar, number and percent of completed Upload - get new upload ID for upload and progress script Field CharSets - handle form fields in different code pages Multipart - enumerate field headers Upload - Save only images Kernel - copy file ByteArray - Convert iso-2022-jp binary data to shift-jis codepage binary data ByteArray - decode and encode from Base64 ByteArray - encode a file to a base64 string (Base64 file) You can simply encode a binary or text file to a Base64 string using this sample code. The base64 string can be stored to a file using
SaveAs method.
ByteArray - Decode a Base64 string to a binary data. Upload - cause read when source data exceeds a limit Convert files from one code page / character set to another (ANSI to utf-8) ASP Form - process standard x-www-form-urlencoded data with unicode code page and unlimitted size.
|
This sample demontrates accepting of a plain form (Form without ENCTYPE="multipart/form-data") by Huge-ASP file upload, ASPForm Object. Full source is in form-url-encode-utf-8.asp sample file.
ASPForm object has some great functionality against of Request.Form: size limit for ASPForm object is 2GB. Request.Form(...) can accept maximum of 100kB.
ASPForm acepts ANY code page. This page is written in utf-8. It lets you write and mix some special character sets and characters
such are hebrew (קבוצות דיון), arabic (مجموعات), east-european (žluťoučký kůň), russian (Картинки), japanese (イメージ) or chinese (圖片).
You can have the characters NOT only in HTML page, you can use them in input fields, of course. ASPForm accepts application/x-www-form-urlencoded and multipart/related data and contains automatic detection of type of a source form.
|
Upload - Check file contents to ensure the field is really an image This function checks the uploaded file contents to ensure that the file is an image. You can check extension of the file or content-type. If the content-type begins with 'image/' or extension is in imageExts, the file is probably an image.
But - someone can rename an .exe file and send the file as 'image'. So a second part of the check function tests file contents for usual characteristics of image files. You can use
String or
HexString property to get a part of contents of the file and compare it with image file characteristics.
You can use this function to check other file types (compressed, executable, ) also.
These tables are from
Richard Ogley's pages.
Jump to:
Image files |
Compressed files |
Archive files |
Executable files |
Miscellaneous files
| File type | Typical extension |
Hex digits xx = variable |
Ascii digits . = not an ascii char |
| Bitmap format |
.bmp |
42 4d |
BM |
| FITS format |
.fits |
53 49 4d 50 4c 45 |
SIMPLE |
| GIF format |
.gif |
47 49 46 38 |
GIF8 |
| Graphics Kernel System |
.gks |
47 4b 53 4d |
GKSM |
| IRIS rgb format |
.rgb |
01 da |
.. |
| ITC (CMU WM) format |
.itc |
f1 00 40 bb |
.... |
| JPEG File Interchange Format |
.jpg |
ff d8 ff e0 |
.... |
| NIFF (Navy TIFF) |
.nif |
49 49 4e 31 |
IIN1 |
| PM format |
.pm |
56 49 45 57 |
VIEW |
| PNG format |
.png |
89 50 4e 47 |
.PNG |
| Postscript format |
.[e]ps |
25 21 |
%! |
| Sun Rasterfile |
.ras |
59 a6 6a 95 |
Y.j. |
| Targa format |
.tga |
xx xx xx |
... |
| TIFF format (Motorola - big endian) |
.tif |
4d 4d 00 2a |
MM.* |
| TIFF format (Intel - little endian) |
.tif |
49 49 2a 00 |
II*. |
| X11 Bitmap format |
.xbm |
xx xx |
|
| XCF Gimp file structure |
.xcf |
67 69 6d 70 20 78 63 66 20 76 |
gimp xcf |
| Xfig format |
.fig |
23 46 49 47 |
#FIG |
| XPM format |
.xpm |
2f 2a 20 58 50 4d 20 2a 2f |
/* XPM */ |
| File type | Typical extension |
Hex digits xx = variable |
Ascii digits . = not an ascii char |
| Bzip |
.bz |
42 5a |
BZ |
| Compress |
.Z |
1f 9d |
.. |
| gzip format |
.gz |
1f 8b |
.. |
| pkzip format |
.zip |
50 4b 03 04 |
PK.. |
| File type | Typical extension |
Hex digits xx = variable |
Ascii digits . = not an ascii char |
| TAR (pre-POSIX) |
.tar |
xx xx |
(a filename) |
| TAR (POSIX) |
.tar |
75 73 74 61 72 |
ustar (offset by 257 bytes) |
| File type | Typical extension |
Hex digits xx = variable |
Ascii digits . = not an ascii char |
| MS-DOS, OS/2 or MS Windows |
|
4d 5a |
MZ |
| Unix elf |
|
7f 45 4c 46 |
.ELF |
| File type | Typical extension |
Hex digits xx = variable |
Ascii digits . = not an ascii char |
| pgp public ring |
|
99 00 |
.. |
| pgp security ring |
|
95 01 |
.. |
| pgp security ring |
|
95 00 |
.. |
| pgp encrypted data |
|
a6 00 |
¦. |
ByteArray - accept very large data in POST/PUT request, ASP, VBScript Upload - handle other requests with higher priority ByteArray - Punycode - unicode conversions Short functions to encode/decode string<->punycode data. You can use these functions as an Internationalized Domain Names VBScript converter.
punycode to unicode conversion
unicode string to punycode conversion
IDN string to unicode conversion
unicode string to IDN string conversion
See Live punycode idn decoder/encoder.
ByteArray - save unicode data (string) as utf-8 with BOM See also Batch file conversion - character set and BOM detection of html files to detect files with BOM (unicode Little/Big, utf-8)
ByteArray, T-SQL - base64 encoder for Microsoft SQL This short sample lets you convert any string data to Base64 directly in SQL stored procedure (SP written in MS T-SQL). The data are passed as a string, you can do String-to-binary conversion with specified charset (the default charset is specified by system locale). The binary data are converted by get_Base64 property.
See also ByteArray, T-SQL - base64 decoder for Microsoft SQL
ByteArray, T-SQL - base64 decoder for Microsoft SQL This short sample lets you convert a Base64 string data to a decoded String or Binary data directly in SQL stored procedure (SP written in MS T-SQL). The data are passed as a Base64 string, then you can get the original data as a binary/image data type or converted to unicode string using specified charset/code page. The data are converted by put_Base64 property.
See also ByteArray, T-SQL - base64 encoder for Microsoft SQL
Charset conversion of very large files - 2GB and more This sample contains a block-by-block character set conversion algorithm for a very large files, you can use it for files with any size, this code work also with files over 2GB or 4GB. It takes maximum of 5*BlockSize of memory to convert the data (5MB of memory for the 1MB block).
The SourceCharSet may be only a charset with a constant char size, one, two or four bytes (and the BlockSize must be an integral multiple of the character size). You can use single byte charsets as Windows-1250, windows-1251, Latin II, ibm850... for the source file, but not utf-8 (it has a variable size of char). You can use any destination charset, including utf-8
ASP - upload and store files to a network drive You can store uploaded files also to a network disk or network resource. The main problem within this task are user rights. The default user account running ASP script (usually IUSR_COMPUTERNAME) has no access to network resources. One of the way is to connect to a network resource with another Username and Password (using AddConnection), store uploaded files and Disconnect from the resource (CancelConnection). This is a sample VBScript concept of the task. See
upload-network.asp sample for full code.
Bytearray - test of Simplified Chinese, iso-ir-58