# Base91 and Base128 Functions

## Recommended Posts

Here's  Base91 and Base128 functions I ported from code I found on the net. Quick search of the forum did not pull up anything so don't think these have been posted before. Both just for fun. The base128 is pretty straight forward as its pretty much the same concept as base64 only using 7bits instead of 6, but I thought the base91 was real interesting and Im actually still trying to wrap my head around the algorithm. The functions Ive posted are shortened/combined a bit so if your gonna try and learn the flow I would break it back down to one operation per line. Let me know if you find a string it does not work with. I mainly wanted them for embedding dlls in scripts and the the results are below for a dll that I tested.  Have fun!

Base91:

```; ; #FUNCTION# ====================================================================================================================
; Name...........: _Base91Encode
; Description ...: Encodes string to Base91
; Author ........: Brian J Christy (Beege)
; Source ........: http://base91.sourceforge.net/  [Joachim Henke]
; ===============================================================================================================================
Func _Base91Encode(\$sStr)

Local \$aB91 = StringSplit('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#\$%&()*+,./:;<=>?@[]^_`{|}~"', '', 2)
Local \$sEncoded, \$b, \$n, \$v, \$aStr = StringToASCIIArray(\$sStr)

For \$i = 0 To UBound(\$aStr) - 1
\$b = BitOR(\$b, BitShift(\$aStr[\$i], (\$n * - 1)))
\$n += 8
If \$n > 13 Then
\$v = BitAND(\$b, 8191)
\$s = 13 + (\$v <= 88)
If \$v <= 88 Then \$v = BitAND(\$b, 16383)
\$b = BitShift(\$b, \$s)
\$n -= \$s
\$sEncoded &= \$aB91[Mod(\$v, 91)] & \$aB91[\$v / 91]
EndIf
Next

If \$n Then
\$sEncoded &= \$aB91[Mod(\$b, 91)]
If \$n > 7 Or \$b > 90 Then \$sEncoded &= \$aB91[\$b / 91]
EndIf

Return \$sEncoded

EndFunc   ;==>_Base91Encode

; #FUNCTION# ====================================================================================================================
; Name...........: _Base91Encode
; Description ...: Decodes string from Base91
; Author ........: Brian J Christy (Beege)
; Source ........: http://base91.sourceforge.net/  [Joachim Henke]
; ===============================================================================================================================
Func _Base91Decode(\$sStr)

Local \$sB91 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#\$%&()*+,./:;<=>?@[]^_`{|}~"'
Local \$sDecoded, \$n, \$c, \$b, \$v = -1, \$aStr = StringSplit(\$sStr, '', 2)

For \$i = 0 To UBound(\$aStr) - 1
\$c = StringInStr(\$sB91, \$aStr[\$i], 1) - 1
If \$v < 0 Then
\$v = \$c
Else
\$v += \$c * 91
\$b = BitOR(\$b, BitShift(\$v, (\$n * - 1)))
\$n += 13 + (BitAND(\$v, 8191) <= 88)
Do
\$sDecoded &= Chr(BitAND(\$b, 255))
\$b = BitShift(\$b, 8)
\$n -= 8
Until Not (\$n > 7)
\$v = -1
EndIf
Next

If (\$v + 1) Then \$sDecoded &= Chr(BitAND(BitOR(\$b, BitShift(\$v, (\$n * - 1))), 255))

Return \$sDecoded

EndFunc   ;==>_Base91Decode```

Base128:

```; #FUNCTION# ====================================================================================================================
; Name...........: _Base128Encode
; Description ...: Decodes string from Base128
; Author ........: Brian J Christy (Beege)
; Source ........: https://github.com/seizu/base128/blob/master/base128.php  [Erich Pribitzer]
; ===============================================================================================================================
Func _Base128Encode(\$sStr)

Local \$aB128 = StringSplit('!#\$%()*,.0123456789:;=@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎ', '', 2)
Local \$sEncoded, \$ls, \$r, \$rs = 7, \$aStr = StringToASCIIArray(\$sStr & ' ')

For \$i = 0 To UBound(\$aStr) - 1
If \$ls > 7 Then
\$i -= 1
\$ls = 0
\$rs = 7
EndIf
\$nc = BitOR(BitAND(BitShift(\$aStr[\$i], (\$ls * -1)), 0x7f), \$r)
\$r = BitAND(BitShift(\$aStr[\$i], \$rs), 0x7f)
\$rs -= 1
\$ls += 1
\$sEncoded &= \$aB128[\$nc]
Next

Return \$sEncoded

EndFunc   ;==>_Base128Encode

; #FUNCTION# ====================================================================================================================
; Name...........: _Base91Encode
; Description ...: Decodes string from Base128
; Author ........: Brian J Christy (Beege)
; Source ........: https://github.com/seizu/base128/blob/master/base128.php  [Erich Pribitzer]
; ===============================================================================================================================
Func _Base128Decode(\$sStr)

Local \$sDecoded, \$r, \$rs = 8, \$ls = 7, \$aStr = StringSplit(\$sStr, '', 2)

For \$i = 0 To UBound(\$aStr) - 1
\$nc = StringInStr(\$sB128, \$aStr[\$i], 1) - 1
If \$rs > 7 Then
\$rs = 1
\$ls = 7
\$r = \$nc
ContinueLoop
EndIf
\$r1 = \$nc
\$nc = BitOR(BitAND(BitShift(\$nc, (\$ls * -1)), 0xFF), \$r)
\$r = BitShift(\$r1, \$rs)
\$rs += 1
\$ls -= 1
\$sDecoded &= Chr(\$nc)
Next

Return \$sDecoded

EndFunc   ;==>_Base128Decode```
Dll Size Tests:

```Binary Len  =   57346
Base64 Len  =   38232
Base91 Len  =   35180
Base128 Len =   32768```
Base91 - Base128.au3

Edit: Fixed Base91 error pointed out by trancexx

Edited by Beege

"Only those who have the patience to do simple things perfectly will acquire the skill to do difficult things easily" - Johann von Schiller

##### Share on other sites

Base91 is really interesting.

Unfortunatly something like this doesn't work:

```\$sStr = FileRead(@ScriptFullPath)

ConsoleWrite(_Base91Decode(_Base91Encode(\$sStr)) & @CRLF)

; #FUNCTION# ====================================================================================================================
; Name...........: _Base91Encode
; Description ...: Encodes string to Base91
; Author ........: Brian J Christy (Beege)
; Source ........: http://base91.sourceforge.net/  [Joachim Henke]
; ===============================================================================================================================
Func _Base91Encode(\$sStr)

Local \$aB91 = StringSplit('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#\$%&()*+,./:;<=>?@[]^_`{|}~"', '', 2)
Local \$sEncoded, \$b, \$n, \$v, \$s, \$aStr = StringToASCIIArray(\$sStr)

For \$i = 0 To UBound(\$aStr) - 1
\$b = BitOR(\$b, BitShift(\$aStr[\$i], (\$n * -1)))
\$n += 8
If \$n > 13 Then
\$v = BitAND(\$b, 8191)
If (\$v <= 88) Then \$v = BitAND(\$b, 16383)
\$s = 13 + (\$v <= 88)
\$b = BitShift(\$b, \$s)
\$n -= \$s
\$sEncoded &= \$aB91[Mod(\$v, 91)] & \$aB91[\$v / 91]
EndIf
Next

If \$n Then
\$sEncoded &= \$aB91[Mod(\$b, 91)]
If \$n > 7 Or \$b > 90 Then \$sEncoded &= \$aB91[\$b / 91]
EndIf

Return \$sEncoded

EndFunc   ;==>_Base91Encode

; #FUNCTION# ====================================================================================================================
; Name...........: _Base91Encode
; Description ...: Decodes string from Base91
; Author ........: Brian J Christy (Beege)
; Source ........: http://base91.sourceforge.net/  [Joachim Henke]
; ===============================================================================================================================
Func _Base91Decode(\$sStr)

Local \$sB91 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#\$%&()*+,./:;<=>?@[]^_`{|}~"'
Local \$sDecoded, \$n, \$c, \$b, \$v = -1, \$aStr = StringSplit(\$sStr, '', 2)

For \$i = 0 To UBound(\$aStr) - 1
\$c = StringInStr(\$sB91, \$aStr[\$i], 1) - 1
If \$v < 0 Then
\$v = \$c
Else
\$v += \$c * 91
\$b = BitOR(\$b, BitShift(\$v, (\$n * -1)))
\$n += 13 + (BitAND(\$v, 8191) <= 88)
Do
\$sDecoded &= Chr(BitAND(\$b, 255))
\$b = BitShift(\$b, 8)
\$n -= 8
Until Not (\$n > 7)
\$v = -1
EndIf
Next

If (\$v + 1) Then \$sDecoded &= Chr(BitAND(BitOR(\$b, BitShift(\$v, (\$n * -1))), 255))

Return \$sDecoded

EndFunc   ;==>_Base91Decode```

Did you just translate the code from another language or made it by following documentation.

.

eMyvnE

##### Share on other sites

Hey good catch. Thanks! Ill be looking at this later to see if I can pinpoint the problem. - If its my code or not.

Just a translation from other code  . Surprisingly base91 really didn't have any documentation that I could find other than what the code does.

"Only those who have the patience to do simple things perfectly will acquire the skill to do difficult things easily" - Johann von Schiller

##### Share on other sites

Fixed error pointed out by trancexx. thanks again

"Only those who have the patience to do simple things perfectly will acquire the skill to do difficult things easily" - Johann von Schiller

##### Share on other sites
```_Example()

Func _Example()

\$sEnc = _Base128Encode(\$sTest)
\$sDec = _Base128Decode(\$sEnc)
If \$sDec = \$sTest Then
ConsoleWrite(\$sEnc & @LF & \$sDec & @LF & '**Test Passed**' & @LF)
Else
ConsoleWrite(\$sEnc & @LF & \$sDec & @LF & '**Test Failed**' & @LF)
EndIf

EndFunc   ;==>_Example

; #FUNCTION# ====================================================================================================================
; Name...........: _Base128Encode
; Description ...: Decodes string from Base128
; Author ........: Brian J Christy (Beege)
; Source ........: https://github.com/seizu/base128/blob/master/base128.php  [Erich Pribitzer]
; ===============================================================================================================================
Func _Base128Encode(\$sStr)

Local \$aB128 = StringSplit('!#\$%()*,.0123456789:;=@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~?￠￡¤￥|§¨?a???ˉ°±23′μ?·?1o?????àá??????èéê?ìí?', '', 2)
Local \$sEncoded, \$ls, \$r, \$rs = 7, \$aStr = StringToASCIIArray(\$sStr & ' ')

For \$i = 0 To UBound(\$aStr) - 1
If \$ls > 7 Then
\$i -= 1
\$ls = 0
\$rs = 7
EndIf
\$nc = BitOR(BitAND(BitShift(\$aStr[\$i], (\$ls * - 1)), 0x7f), \$r)
\$r = BitAND(BitShift(\$aStr[\$i], \$rs), 0x7f)
\$rs -= 1
\$ls += 1
\$sEncoded &= \$aB128[\$nc]
Next

Return \$sEncoded

EndFunc   ;==>_Base128Encode

; #FUNCTION# ====================================================================================================================
; Name...........: _Base91Encode
; Description ...: Decodes string from Base128
; Author ........: Brian J Christy (Beege)
; Source ........: https://github.com/seizu/base128/blob/master/base128.php  [Erich Pribitzer]
; ===============================================================================================================================
Func _Base128Decode(\$sStr)

Local \$sB128 = '!#\$%()*,.0123456789:;=@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~?￠￡¤￥|§¨?a???ˉ°±23′μ?·?1o?????àá??????èéê?ìí?'
Local \$sDecoded, \$r, \$rs = 8, \$ls = 7, \$aStr = StringSplit(\$sStr, '', 2)

For \$i = 0 To UBound(\$aStr) - 1
\$nc = StringInStr(\$sB128, \$aStr[\$i], 1) - 1
If \$rs > 7 Then
\$rs = 1
\$ls = 7
\$r = \$nc
ContinueLoop
EndIf
\$r1 = \$nc
\$nc = BitOR(BitAND(BitShift(\$nc, (\$ls * - 1)), 0xFF), \$r)
\$r = BitShift(\$r1, \$rs)
\$rs += 1
\$ls -= 1
\$sDecoded &= Chr(\$nc)
Next

Return \$sDecoded

EndFunc   ;==>_Base128Decode```

±n8M:?BF°n′S%Py]_?;UμPxEbx=:@P§[[n)w%

Base128  The result of the decryption and encryption string is not the same as before

Edited by xz00311

##### Share on other sites

Edited by argumentum
problem fixed, no need for this post

##### Share on other sites

±n8M:?BF°n′S%Py]_?;UμPxEbx=:@P§[[n)w%

See my previous posting source, long string encryption, decryption and encryption string before is not the same

##### Share on other sites
On 2/22/2016 at 11:05 PM, xz00311 said:
```Func _Base128Encode(\$sStr)

Local \$aB128 = StringSplit('!#\$%()*,.0123456789:;=@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~?￠￡¤￥|§¨?a???ˉ°±23′μ?·?1o?????àá??????èéê?ìí?', '', 2)

EndFunc   ;==>_Base128Encode

Func _Base128Decode(\$sStr)

Local \$sB128 = '!#\$%()*,.0123456789:;=@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~?￠￡¤￥|§¨?a???ˉ°±23′μ?·?1o?????àá??????èéê?ìí?'

EndFunc   ;==>_Base128Decode```

±n8M:?BF°n′S%Py]_?;UμPxEbx=:@P§[[n)w%

Base128  The result of the decryption and encryption string is not the same as before

If that's the actual code being used then something went wrong with your copy and paste i think. The character set for \$aB128 doesn't match what was originally posted. Make sure you download the .au3 file posted when doing your tests.

```Â±n8M:Â¶BFÂ°nÂ´S%Py]_Â½;UÂµPxEbx=:@PÂ§[[n)w%
**Test Passed**```

"Only those who have the patience to do simple things perfectly will acquire the skill to do difficult things easily" - Johann von Schiller

##### Share on other sites

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
*
How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
, be   and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

11

Signature last update: 2018-10-31

thank you

## Create an account

Register a new account

• ### Similar Content

• AutoIt Machine Code Algorithm Collection
By Ward, November 11, 2010 in AutoIt Example Scripts
Posted November 11, 2010 (edited) I have already published a lot of AutoIt UDF about algorithm, but all of them only support 32 bits or so called X86 system. Recently I got a computer with Windows 7 64 bits, so I finally added X64 support to most of my old projects. Besides, I also added some new. For example, some compression algorithm and SHA3 Candidates.
Following are the algorithms list:
Checksum   CRC16   CRC32   ADLER32 Compression   FastLZ   LZF   LZMA   LZMAT   MiniLZO   QuickLZ Encode   Base64   ARC4   XXTEA   DES   AES Hash   Checksums (CRC16/CRC32/ADLER32)   MD2   MD4   MD5   SHA1   SHA2 (SHA224/256/384/512)   SHA3 Candidates     BLAKE     BMW (Blue Midnight Wish)     CUBEHASH     ECHO     SHABAL     SKEIN Some points to mention:
All of the subroutines have one or more examples to demonstrate the usage. Since the function and usage of subroutine are easy to understand. A complete subroutines and parameters list are unavailability now. Sorry for my lazy. All of the subroutines here invoked by Lazycat's method (through CallWindowProc API). My MemoryDLL UDF is not necessary this time. Although MemoryFuncCall (part of MemoryDLL) is still good, but inevitably, it is slower than CallWindowProc. Some subroutines have the same name with my old machine code version UDF. But for some reason, I rearrange the position of the parameters. Please not mix up. If you notice, yes, checksums are duplicated. But they receive different parameters. One is the old style, and another use the same interface as other hashes. Choose what you like, but don't use them in the same time. Some algorithm already supported by the standard UDF "Encryption.au3". But I still provide them, because some system lack of the full support of Windows Crypt Library. If you are looking for only one hash algorithm, for example, used in encryption, I suggested "SHABAL_TINY.au3". Although it is a bit slower then SHABAL, but it is smaller, and it supports different size of output (from 32 to 512 bits).
• By Ascer
Hello.
A couple week ago i've started learning API Interface for different websites. In this fact sometimes you have to encode your "photo" or "document.body" to send request.
Functions to encode and decode Base64 was already created by others. Unfortunately i have troubles with running it on Windows R 2008, also speed was terrible.
I try to find alternative way to code data.
I've read about Microsoft "XMLDOM" and created a one simple function to Encode / Decode data to base64binary, base64url
Thanks for Ghads on Wordpress i coverted a part of his lines from VBscript to AutoIT
;============================================================================================================================== ; Function: base64(\$vCode [, \$bEncode = True [, \$bUrl = False]]) ; ; Description: Decode or Encode \$vData using Microsoft.XMLDOM to Base64Binary or Base64Url. ; IMPORTANT! Encoded base64url is without @LF after 72 lines. Some websites may require this. ; ; Parameter(s): \$vData - string or integer | Data to encode or decode. ; \$bEncode - boolean | True - encode, False - decode. ; \$bUrl - boolean | True - output is will decoded or encoded using base64url shema. ; ; Return Value(s): On Success - Returns output data ; On Failure - Returns 1 - Failed to create object. ; ; Author (s): (Ghads on Wordpress.com), Ascer ;=============================================================================================================================== Func base64(\$vCode, \$bEncode = True, \$bUrl = False) Local \$oDM = ObjCreate("Microsoft.XMLDOM") If Not IsObj(\$oDM) Then Return SetError(1, 0, 1) Local \$oEL = \$oDM.createElement("Tmp") \$oEL.DataType = "bin.base64" If \$bEncode then \$oEL.NodeTypedValue = Binary(\$vCode) If Not \$bUrl Then Return \$oEL.Text Return StringReplace(StringReplace(StringReplace(\$oEL.Text, "+", "-"),"/", "_"), @LF, "") Else If \$bUrl Then \$vCode = StringReplace(StringReplace(\$vCode, "-", "+"), "_", "/") \$oEL.Text = \$vCode Return \$oEL.NodeTypedValue EndIf EndFunc ;==>base64

• By RobOtter
Hi,
is there a function or a UDF for parsing a hotkey definition string like "^a" or "+!{F1}" ?
I´d like to create a settings GUI where users are able to define their custom hotkeys for a specific function and then save it to an ini. Of course, at the next start of the program, these settings have to read and not only the HotkeySet() command needs to be fed with it but also the settings GUI.
As I do not want to present the user just the hotkey string but a rather user-friendly display (like checkboxes for the separate modifier keys and a drop down list of supported trigger keys), I need to fiddle on the saved string.
I would envision a function that takes a hotkey string and returns for example an array like this: [isCtrl][isAlt][isShift][isWin][triggerKey][isTriggerVirtual]. And of course, there needs to be a function decoding the array back to the respective string representation.

• By noorm
Hello!
I've been lurking around for a loooong time... and I decided to finally share a little. I do a lot of internet stuff, mostly machine to machine for work (instrumentation) so I have quite a few "RFC" scripts.
Disclaimer these work for me... but I sometime use... "shortcuts" based on my particular requirement. An example, the Base64 encoding snippet might not be too good for binary data. I pad the original data with spaces to avoid the "==" padding of base64.
So... first is the base64 encoding snippet. It is not in a function, it was in a sequential program, used only once! It encode \$Graph to \$SMTPMessage:
; Create the base64 encoding table Dim \$Base64EncodingTable[0] For \$Cpt = Asc("A") to Asc("Z") _ArrayAdd(\$Base64EncodingTable, Chr(\$Cpt)) Next For \$Cpt = Asc("a") to Asc("z") _ArrayAdd(\$Base64EncodingTable, Chr(\$Cpt)) Next For \$Cpt = Asc("0") to Asc("9") _ArrayAdd(\$Base64EncodingTable, Chr(\$Cpt)) Next _ArrayAdd(\$Base64EncodingTable, "+") _ArrayAdd(\$Base64EncodingTable, "/") ; Pad the SVG Graph to attach with space(s). Lazy way to avoid base64 == pading While Mod(StringLen(\$Graph), 3) <> 0 \$Graph &= " " WEnd ; Start from the first character \$Cpt = 1 Do ; Extract the 3 characters to encode \$Char1 = Asc(StringMid(\$Graph, \$Cpt, 1)) \$Char2 = Asc(StringMid(\$Graph, \$Cpt+1, 1)) \$Char3 = Asc(StringMid(\$Graph, \$Cpt+2, 1)) ; Encode them to 4 characters \$SMTPMessage &= \$Base64EncodingTable[BitShift(BitAND(\$Char1, 252), 2)] \$SMTPMessage &= \$Base64EncodingTable[BitShift(BitAND(\$Char1, 3), -4) + BitShift(BitAND(\$Char2, 240), 4)] \$SMTPMessage &= \$Base64EncodingTable[BitShift(BitAND(\$Char2, 15), -2) + BitShift(BitAND(\$Char3, 192), 6)] \$SMTPMessage &= \$Base64EncodingTable[BitAND(\$Char3, 63)] ; Increment the counter, and if required, add a @CRLF to split in multiples lines \$Cpt += 3 If Mod(\$Cpt, 57) = 1 Then \$SMTPMessage &= @CRLF ; Do this until all the graph has been encoded Until \$Cpt >= StringLen(\$Graph)
Second... I just finished this one and was allready thinking about sharing it... so it's been encapsulated into function a bit more. I use it to decode email subjects in a system where you can update something by email. I separated the Base64Decode function so it can be grabbed more easily. Please note that it return an hex string so you would still need to convert it if it's a string with BinaryToString or whatever suit your needs.
If can be copied as is and runned directly... it include my test strings! (Yes... I'm french!)
Last thing... I may update it into a better format for you, like a standalone telnet program with GUI. It is my telnet options negociations loops. The basic concept is systematically deny all request for special options and keep it "raw".
If server says "Will", I reply "Don't". If it says "Do", I reply "Wont"... unless it's the terminal type subnegociation, in which case I reply xterm!
\$Data for now needs to be Global. You still need to know what you're doing, opening sockets and making a basic communication loop or something.
Global \$T_Is = Chr(0) Global \$T_Send = Chr(1) Global \$T_TerminalType = Chr(24) Global \$T_SE = Chr(240) Global \$T_SB = Chr(250) Global \$T_Will = Chr(251) Global \$T_Wont = Chr(252) Global \$T_Do = Chr(253) Global \$T_Dont = Chr(254) Global \$T_IAC = Chr(255) Func NegotiateTelnetOptions() \$NegotiationCommandsToSendBack = "" While StringInStr(\$Data, \$T_IAC) \$IACPosition = StringInStr(\$Data, \$T_IAC) Switch StringMid(\$Data, \$IACPosition+1, 1) Case \$T_Will \$NegotiationCommandsToSendBack &= CraftReply_CleanUpData(\$IACPosition, \$T_Dont) Case \$T_Do If StringMid(\$Data, \$IACPosition+2, 1) = \$T_TerminalType Then \$NegotiationCommandsToSendBack &= CraftReply_CleanUpData(\$IACPosition, \$T_Will) Else \$NegotiationCommandsToSendBack &= CraftReply_CleanUpData(\$IACPosition, \$T_Wont) EndIf Case \$T_SB If StringMid(\$Data, \$IACPosition, 6) = (\$T_IAC & \$T_SB & \$T_TerminalType & \$T_Send & \$T_IAC & \$T_SE) Then \$NegotiationCommandsToSendBack &= \$T_IAC & \$T_SB & \$T_TerminalType & \$T_Is & "xterm" & \$T_IAC & \$T_SE \$Data = StringReplace(\$Data, StringMid(\$Data, \$IACPosition, 6), "") Else MsgBox(0, "", "Unknown Subnegotiation...") ; Should never happen. Exit EndIf EndSwitch WEnd Return \$NegotiationCommandsToSendBack EndFunc Func CraftReply_CleanUpData(\$IACPosition, \$Reply) \$PartialCommandToSendBack = \$T_IAC & \$Reply & StringMid(\$Data, \$IACPosition+2, 1) \$Data = StringReplace(\$Data, StringMid(\$Data, \$IACPosition, 3), "") Return \$PartialCommandToSendBack EndFunc
×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...