REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 3-Aug-2010 Edit History  

REBOL 3 Functions: debase

debase  value  /base  base-value

Decodes binary-coded string (BASE-64 default) to binary value.

Arguments:

value [binary! string!] - The string to decode

Refinements:

/base - Binary base to use

base-value [integer!] - The base to convert from: 64, 16, or 2

See also:

enbase   dehex  

Description

Converts from an encoded string to the binary value. Primarily used for BASE-64 decoding.

The /base refinement allows selection of number base as 64, 16, 2. Default is base64.

probe debase "MTIzNA=="
#{31323334}
probe debase/base "12AB C456" 16
#{12ABC456}
enbased: probe enbase "a string of text"
"YSBzdHJpbmcgb2YgdGV4dA=="
probe string? enbased         ; enbased value is a string
true
debased: probe debase enbased ; converts to binary value

probe to-string debased       ; converts back to original string

If the input value cannot be decoded (such as when missing the proper number of characters), a none is returned.

probe debase "100"

probe debase "1001"
#{D74D35}


  TOC < Back Next > REBOL.com - WIP Wiki Feedback Admin