14.03.2014 Views

Scripting Guide - SAS

Scripting Guide - SAS

Scripting Guide - SAS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 6 Types of Data 121<br />

Hexadecimal and BLOB Functions<br />

Table 6.6 Hexadecimal and BLOB Functions (Continued)<br />

Syntax<br />

Blob To Char(blob)<br />

Blob To Char(blob,<br />

encoding)<br />

Blob Peek(blob,<br />

offset, length)<br />

Explanation<br />

Converts binary data to a Unicode string.<br />

The default encoding supported for the hex code is UTF-8. You can also<br />

specify one of these encodings: utf-8, utf-16le, utf-16be, us-ascii,<br />

iso-8859-1, and ascii-hex.<br />

Returns a new BLOB that is a subset of the given BLOB that is length<br />

bytes long and begins at the offset. Note that the offset is 0-based.<br />

Hex (string) returns the hexadecimal codes for each character in the argument. For example,<br />

returns<br />

Hex("Abc")<br />

"416263"<br />

since 41, 62, and 63 are the hexadecimal codes (in Ascii) for “A”, “b”, and “c”.<br />

Hex to Char (string) converts hexadecimal to characters. The resulting character string might not be<br />

valid display characters. All the characters must be in pairs, in the ranges 0-9, A-Z, and a-z. Blanks and<br />

commas are allowed, and skipped. For example,<br />

returns<br />

Hex To Char (“4142”)<br />

"AB"<br />

since 41 and 42 are the hexadecimal equivalents of “A” and “B”.<br />

Hex and Hex To Char are inverses of each other, so<br />

returns<br />

Hex To Char ( Hex("Abc") )<br />

"Abc"<br />

Hex To Blob(string) takes a string of hexadecimal codes and converts it to a binary object.<br />

a = Hex To Blob("6A6B6C"); Show(a);<br />

a = Char To Blob("jkl", “ascii~hex”)<br />

Blob Peek(blob,offset,length) extracts bytes as defined by the parameters from a blob.<br />

b = Blob Peek(a,1,2); Show(b);<br />

b = Char To Blob("kl", “ascii~hex”)<br />

b = Blob Peek(a,0,2); Show(b);<br />

b = Char To Blob("jk", “ascii~hex”)<br />

b = Blob Peek(a,2); Show(b);<br />

b = Char To Blob("l", “ascii~hex”)<br />

Hex(blob) converts a blob into hexadecimal.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!