README.md

December 4, 2022 ยท View on GitHub

Binary Data Manipulation

Description

These two functions allow you to convert between Unicode and Ascii strings. This is great if you are working with the Request.BinaryRead/BinaryWrite methods or binary data within a database.

More Info

Submitted On
ByLewis E. Moten III
LevelAdvanced
User Rating5.0 (10 globes from 2 users)
CompatibilityASP (Active Server Pages)
CategoryFiles
WorldASP / VbScript
Archive File

Source Code

Function AsciiToUnicode(ByRef pstrAscii)
	Dim llngLength
	Dim llngIndex
	Dim llngAscii
	Dim lstrUnicode
	llngLength = LenB(pstrAscii)
	For llngIndex = 1 to llngLength
		llngAscii = AscB(MidB(pstrAscii, llngIndex, 1))
		lstrUnicode = lstrUnicode & Chr(llngAscii)
	Next
	AsciiToUnicode = lstrUnicode
End Function
Function UnicodeToAscii(ByRef pstrUnicode)
	Dim llngLength
	Dim llngIndex
	Dim llngAscii
	Dim lstrAscii
	llngLength = Len(pstrUnicode)
	For llngIndex = 1 to llngLength
		llngAscii = Asc(Mid(pstrUnicode, llngIndex, 1))
		lstrAscii = lstrUnicode & ChrB(llngAscii)
	Next
	UnicodeToAscii = lstrAscii
End Function