$encode

From Scriptwiki
Jump to: navigation, search

Encodes text that can be in a variable or a binary variable, using Mime or Uuencode.

$encode(%var | &binvar[, mubt][, N])
  • The first parameter is the variable, raw text or binary variable to encode.
  • The second parameter is a list of options pertaining to the type of encoding, and the type of variable given. Defaults are ut.
    • m means that the text will be encoded using Mime. Do not use with u.
    • u means that the text will be encoded using Uuencode. Do not use with m
    • b means that the text is in a binary variable. Do not use with t.
    • t means that the text is given straight or in a variable. Do not use with b.
  • The last parameter is which chunk of encoded text you wish to return. Encode will encode the information into 60-character-each chunks. 0 returns the total number of chunks. Default is 1.
  • Returns
    • For binary variables, returns the number of bytes written to the binary file.
    • For text or variables
      • For N=0, returns the total number of 60-character chunks exists.
      • For N>0, returns the characters in the given chunk, or $null if N is too large