Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
|
UU Encoding and DecodingDemonstrates how to UU encode and decode.
CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @sTmp0 nvarchar(4000) DECLARE @crypt int EXEC @hr = sp_OACreate 'Chilkat.Crypt2', @crypt OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END -- Any string argument automatically begins the 30-day trial. DECLARE @success int EXEC sp_OAMethod @crypt, 'UnlockComponent', @success OUT, '30-day trial' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @crypt, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END DECLARE @s1 nvarchar(4000) DECLARE @s2 nvarchar(4000) DECLARE @s3 nvarchar(4000) SELECT @s1 = 'This string is to be UU encoded' EXEC sp_OASetProperty @crypt, 'UuMode', '666' EXEC sp_OASetProperty @crypt, 'UuFilename', 'something.txt' -- UU encode: EXEC sp_OAMethod @crypt, 'EncodeString', @s2 OUT, @s1, 'ansi', 'uu' -- Note: Call crypt.Encode instead of crypt.EncodeString -- to UU encode binary bytes (i.e. non-text binary data). PRINT @s2 -- UU decode: DECLARE @crypt2 int EXEC @hr = sp_OACreate 'Chilkat.Crypt2', @crypt2 OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END EXEC sp_OAMethod @crypt2, 'DecodeString', @s3 OUT, @s2, 'ansi', 'uu' -- Note: Likewise, call crypt.Decode to decode non-text binary data. PRINT @s3 -- Show the file permissions mode and filename found -- in the UU encoded data: EXEC sp_OAGetProperty @crypt2, 'UuMode', @sTmp0 OUT PRINT 'UuMode = ' + @sTmp0 EXEC sp_OAGetProperty @crypt2, 'UuFilename', @sTmp0 OUT PRINT 'UuFilename = ' + @sTmp0 END GO |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.