![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java JavaScript Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(SQL Server) Base62 Encoding and DecodingDemonstrates base62 encoding and decoding. Note: This example requires Chilkat v11.2.0 or greater.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int -- Important: Do not use nvarchar(max). See the warning about using nvarchar(max). DECLARE @sTmp0 nvarchar(4000) DECLARE @bd int EXEC @hr = sp_OACreate 'Chilkat.BinData', @bd OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END -- Base62 encode. DECLARE @success int EXEC sp_OAMethod @bd, 'AppendString', @success OUT, 'hello world', 'utf-8' DECLARE @base62_encoded nvarchar(4000) EXEC sp_OAMethod @bd, 'GetEncoded', @base62_encoded OUT, 'base62' PRINT 'hello world --> ' + @base62_encoded -- Output: -- hello world --> AAwf93rvy4aWQVw -- Base62 decode DECLARE @sb int EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sb OUT EXEC sp_OAMethod @sb, 'DecodeAndAppend', @success OUT, 'AAwf93rvy4aWQVw', 'base62', 'utf-8' EXEC sp_OAMethod @sb, 'GetAsString', @sTmp0 OUT PRINT 'decoded: ' + @sTmp0 -- Output: -- decoded: hello world EXEC @hr = sp_OADestroy @bd EXEC @hr = sp_OADestroy @sb END GO |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.