Converting Octal & Hex & ASCII --

By Jonesy44 on Jul 31, 2009

5 Seperate aliases to do some fairly simple tasks

  • html2chr: converts html encoded ascii characters to normal symbols
    -- helpful for sockets as it scans the entire line

  • oct2chr: converts octal numbers to ascii character symbols
  • oct: retrieves octal code for ascii symbol

  • hex2chr: converts hexidecimal numbers to ascii character symbols
  • hex: retrieves hexidecimal code for ascii symbol

Rate & Comment & Likes if you find it helpful ;)

; syntax: $html2chr(txt)
; -- returns "txt" with converted &#<x> values
; -- e.g. $html2chr(&#100) -- "d"
alias html2chr return $replace($regsubex($1-,/(&#(\d*));?/g,$chr(\2)),&nbsp;,$chr(32),&amp;,&)

; syntax: $oct2chr(txt)
; -- returns "txt", converting any 3 number selections from octal to their ascii symbols
; -- e.g. $oct2chr(100) -- "@"
alias oct2chr return $regsubex($1-,/(\d{3})/g,$chr($base(\1,8,10,0)))
; syntax: $oct(X)
; -- returns octal value of character "X"
; -- e.g. $oct(@) -- "100"
alias oct return $base($asc($1),10,8,3)

; syntax: $hex2chr(txt)
; -- returns "txt", converting any hex values into their ascii symbols
alias hex2chr return $regsubex($1-,/(\d{2}|\w+)/g,$chr($base(\1,16,10,0)))
; syntax: $hex(X)
; -- returns hex value of character "X"
; -- e.g. $hex(?) -- "3F"
alias hex return $base($asc($1),10,16,0)

Comments

Sign in to comment.
D2K7   -  Aug 12, 2009

Mhm

 Respond  
Jonesy44   -  Aug 01, 2009

Perhaps not helpful to you :L

 Respond  
D2K7   -  Jul 31, 2009

i will rate 5 out of 10 bcuz it aint that Usefull to meh but good code :D

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.