Attribute VB_Name = "iceenc"
Option Explicit

Function URLEncode(ByVal Text As String) As String
    Dim i As Integer
    Dim acode As Integer
    Dim char As String
    
    URLEncode = Text
    
    For i = Len(URLEncode) To 1 Step -1
        acode = Asc(Mid$(URLEncode, i, 1))
        Select Case acode
            Case 48 To 57, 65 To 90, 97 To 122
                ' don't touch alphanumeric chars
            Case 32
                ' replace space with "+"
                Mid$(URLEncode, i, 1) = "+"
            Case Else
                ' replace punctuation chars with "%hex"
                URLEncode = Left$(URLEncode, i - 1) & "%" & Hex$(acode) & Mid$ _
                    (URLEncode, i + 1)
        End Select
    Next
    
End Function


Public Function iceencript(source As String) As String
    Dim i As Long
    Dim buffer As String
    
    For i = 1 To Len(source)
        buffer = buffer & Chr$(Asc(Mid$(source, i, 1)) + 3)
    Next
    iceencript = buffer
End Function

Public Function icecom(uno As String, dos As String) As Boolean

    If Len(uno) <> Len(dos) Then
        icecom = False
        Exit Function

    End If

    Dim tuno() As Byte
    Dim tdos() As Byte
    Dim i      As Long
    tuno = StrConv(uno, vbFromUnicode)
    tdos = StrConv(dos, vbFromUnicode)

    For i = 0 To Len(uno) - 1

        If Asc(tuno(i)) <> Asc(tdos(i)) Then
            icecom = False
            Exit Function

        End If

    Next i

    icecom = True

End Function

Public Function ansiencript(source As String) As String
    Dim buffer As String
    Dim tam As Long
    Dim i As Long
    tam = Len(source)
    For i = 1 To tam
        buffer = buffer & Chr$(Asc(Mid$(source, i, 1)) + 3)
    Next
    ansiencript = buffer

End Function

Public Function ansidecript(source As String) As String
    Dim buffer As String
    Dim tam As Long
    Dim i As Long
    tam = Len(source)
    For i = 1 To tam
        buffer = buffer & Chr$(Asc(Mid$(source, i, 1)) - 3)
    Next
    ansidecript = buffer

End Function
