PDA

View Full Version : PHPIO [PHP IO Classes]



JizzaBeez
07-09-2011, 03:01 AM
PHPIO [PHP IO Classes]
version: 1.0.6.0
created by: JizzaBeez
released: 07/13/2011
updated: 05/10/2012

PHPIO are IO classes for PHP that I put together to help make reading and writing files in PHP a little easier.
A data conversion class is included as well.

Currently supports:

#Reader
-Construct
-Open
-Close
-Length
-Position (get/set)
-FileName
-FileMode (get/set)
-ReadByte (returns decimal value)
-ReadBytes (returns array of decimal values)
-ReadChar (returns character)
-ReadString (returns ascii string)
-ReadUnicodeString (returns string)
-ReadHexString (returns hex string)
-ReadInt8
-ReadInt16 (big or little endian)
-ReadInt32 (big or little endian)
-ReaduInt8
-ReadUInt16 (big or little endian)
-ReadUInt32 (big or little endian)

#Writer
-Construct
-Open
-Close
-Length
-Position (get/set)
-FileName
-FileMode (get/set)
-WriteByte (returns length *write decimal value)
-WriteBytes (returns length *write array of decimal values)
-WriteChar (returns length)
-WriteString (returns length)
-WriteUnicodeString (returns length)
-WriteHexString (returns length)
-WriteInt8
-WriteInt16 (big or little endian)
-WriteInt32 (big or little endian)
-WriteUInt8
-WriteUInt16 (big or little endian)
-WriteUInt32 (big or little endian)

#Conversions
-Int8ToUInt8
-Int16ToUInt16
-Int32ToUInt32
-UInt8ToInt8
-UInt16ToInt16
-UInt32ToInt32
-Int8ToByte
-Int16ToBytes
-Int32ToBytes
-UInt8ToByte
-UInt16ToBytes
-UInt32ToBytes
-ByteToInt8
-BytesToInt16
-BytesToInt32
-ByteToUInt8
-BytesToUInt16
-BytesToUInt32
-BytesToHex
-HexToBytes
-AsciiToHex
-HexToAscii
-AsciiToBytes
-BytesToAscii
-UnicodeToHex
-HexToUnicode
-UnicodeToBytes
-BytesToUnicode

#EndianType
-BIG endian = 0
-LITTLE endian = 1

Here is the basic of using the Reader/Writer:

<?php
include("PHPIO.php");
$filepath = "C:\TextFile.txt";

$writer = new Writer($filepath, "w", 0);
$writer->Open();
$writer->WriteString("JizzaBeez");
$writer->Position(1337);
$writer->WriteString("Cool");
$writer->Close();

$reader = new Reader($filepath, "r", 0);
$reader->Open();
echo $reader->ReadString(9);
$reader->Position(1337);
echo $reader->ReadString(4);
$reader->Close();
?>
Here is an example of how to read and extract a PNG image from a CON file:

try {
$filepath = "C:\SystemData"; // path to CON file
if (!file_exists($filepath)) { throw new Exception("file does not exist"); }
$reader = new Reader($filepath);
$reader->Open();
$reader->Position(5906); // position of PNG length
$length = $reader->ReadInt32(0); // 0=BIG, 1=LITTLE, DEFAULT=0
$reader->Position(5914); // position of PNG data
$data = $reader->ReadBytes($length);
$reader->Close();

$pngfile = "C:\PNGimage.png"; // path for output PNG
$writer = new Writer($pngfile);
$writer->Open();
$writer->WriteBytes($data);
$writer->Close();
echo "extract complete";
}
catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
Here is an example of the input PHP file using the IO:

<?php
include "phpio.php"; //Include the PHP Classes file.
$filepath = "C:\TextFile.txt"; //declare a filepath to use

//..::Writer::..
try{
echo "..::WRITER::.." . "<br />"; //just a title :)
$writer = new Writer($filepath); //declares new Writer with default settings
//$writer = new Writer($filepath, "r+", 0); //declares new Writer with custom settings
echo "Open (return resource) : " . $writer->Open() . "<br />"; //opens file with set filemode/position
echo "FilePath (return filepath) : " . $filepath . "<br />"; //filepath of file
echo "FileName (return filename) : " . $writer->FileName() . "<br />"; //filename of open file
echo "FileMode (return filemode) : " . $writer->FileMode() . "<br />"; //filemode of open file
echo "Position (return position) : " . $writer->Position() . "<br />"; //position in open file
echo "Length (return length) : " . $writer->Length() . "<br />"; //length of file
echo "WriteByte (return count) : " . $writer->WriteByte(0x31) . "<br />"; //write dec byte
echo "WriteBytes (return count) : " . $writer->WriteBytes(array(0x32, 0x33, 0x34)) . "<br />"; //write dec byte array
echo "WriteHexString (return count) : " . $writer->WriteHexString("FFFFFFFF") . "<br />"; //write hex string
echo "Position (set & return position) : " . $writer->Position(1337) . "<br />"; //change position in open file
echo "WriteChar (return length) : " . $writer->WriteChar("J") . "<br />"; //write character
echo "WriteString (return length) : " . $writer->WriteString("izzaBeez") . "<br />"; //write string set by length
echo "Length (return updated length) : " . $writer->Length() . "<br />"; //length of file
echo "Close (return true/false) : " . $writer->Close() . "<br />"; //closes the open file
echo "FileMode (set & return filemode) : " . $writer->FileMode("r+") . "<br />"; //must close then re-open the file to change modes!
echo "Open (return resource) : " . $writer->Open() . "<br />"; //opens file with set filemode/position
echo "FileMode (return filemode) : " . $writer->FileMode() . "<br />"; //filemode of open file
echo "Position (return position) : " . $writer->Position() . "<br />"; //position in open file
echo "Close (return true/false) : " . $writer->Close() . "<br />"; //closes the open file
}
catch (Exception $e) { //catch errors
echo "Error: " . $e->getMessage() . "<br />"; //return error message
}

echo "<br />"; //just a new line :)

//..::Reader::..
try {
echo "..::READER::.." . "<br />"; //just a title :)
$reader = new Reader($filepath); //declares new Reader with default settings
//$reader = new Reader($filepath, "r+", 0); //declares new Reader with custom settings
echo "Open (return resource) : " . $reader->Open() . "<br />"; //opens file with set filemode/position
echo "FilePath (return filepath) : " . $filepath . "<br />"; //filepath of file
echo "FileName (return filename) : " . $reader->FileName() . "<br />"; //filename of open file
echo "FileMode (return filemode) : " . $reader->FileMode() . "<br />"; //filemode of open file
echo "Position (return position) : " . $reader->Position() . "<br />"; //position in open file
echo "Length (return length) : " . $reader->Length() . "<br />"; //length of file
echo "ReadByte (return dec byte) : " . $reader->ReadByte() . "<br />"; //read byte
echo "ReadBytes (return dec byte array) : " . $reader->ReadBytes(3) . "<br />"; //read bytes set by length
echo "ReadHexString (return hex string) : " . $reader->ReadHexString(4) . "<br />"; //read hex string set by length
echo "Position (set & return position) : " . $reader->Position(1337) . "<br />"; //change position in open file
echo "ReadChar (return character) : " . $reader->ReadChar() . "<br />"; //read character
echo "ReadString (return string) : " . $reader->ReadString(8) . "<br />"; //read string set by length
echo "Close (return true/false) : " . $reader->Close() . "<br />"; //closes the open file
echo "FileMode (set & return filemode) : " . $reader->FileMode("r+") . "<br />"; //must close then re-open the file to change modes!
echo "Open (return resource) : " . $reader->Open() . "<br />"; //opens file with set filemode/position
echo "FileMode (return filemode) : " . $reader->FileMode() . "<br />"; //filemode of open file
echo "Position (return position) : " . $reader->Position() . "<br />"; //position in open file
echo "Close (return true/false) : " . $reader->Close() . "<br />"; //closes the open file
}
catch (Exception $e) { //catch errors
echo "Error: " . $e->getMessage() . "<br />"; //return error message
}
?>
Here is the text output:

..::WRITER::..
Open (return resource) : Resource id #3
FilePath (return filepath) : C:\TextFile.txt
FileName (return filename) : TextFile.txt
FileMode (return filemode) : w
Position (return position) : 0
Length (return length) : 0
WriteByte (return count) : 1
WriteBytes (return count) : 3
WriteHexString (return count) : 4
Position (set & return position) : 1337
WriteChar (return length) : 1
WriteString (return length) : 8
Length (return updated length) : 1346
Close (return true/false) : 1
FileMode (set & return filemode) : r+
Open (return resource) : Resource id #4
FileMode (return filemode) : r+
Position (return position) : 1346
Close (return true/false) : 1

..::READER::..
Open (return resource) : Resource id #5
FilePath (return filepath) : C:\TextFile.txt
FileName (return filename) : TextFile.txt
FileMode (return filemode) : r
Position (return position) : 0
Length (return length) : 1346
ReadByte (return dec byte) : 49
ReadBytes (return dec byte array) : Array
ReadHexString (return hex string) : FFFFFFFF
Position (set & return position) : 1337
ReadChar (return character) : J
ReadString (return string) : izzaBeez
Close (return true/false) : 1
FileMode (set & return filemode) : r+
Open (return resource) : Resource id #6
FileMode (return filemode) : r+
Position (return position) : 1346
Close (return true/false) : 1
Here are the PHPIO classes:

<?php
// PHPIO: [PHP In/Out Classes]
// Version: 1.0.6.0
// Created by: JizzaBeez ([email protected])
// Released: 07/13/2011
// Updated: 05/10/2012

class Reader {
private $filepath = "";
private $openfile = "";
private $filemode = "";
private $position = 0;
private $length = 0;

public function __construct($filepath, $filemode = "r", $position = 0) {
if (file_exists($filepath)) {
$this->filepath = $filepath;
$this->filemode = $filemode;
$this->position = $position;
$this->length = filesize($this->filepath);
}
else { throw new Exception("file does not exist"); }
}

function FileName() {
return basename($this->filepath);
}

function FileMode($filemode) {
if ($filemode != null) { $this->filemode = $filemode; }
return $this->filemode;
}

function Length() {
clearstatcache();
$this->length = filesize($this->filepath);
return $this->length;
}

function Position($position) {
if ($position != null) { $this->position = $position; }
return $this->position;
}

function Open() {
$this->openfile = fopen($this->filepath, $this->filemode) or exit("could not open file");
return $this->openfile;
}

function Close() {
return fclose($this->openfile);
}

function ReadByte() {
fseek($this->openfile, $this->position);
$data = strtoupper(bin2hex(fread($this->openfile, 1)));
$this->position = ftell($this->openfile);
return hexdec($data);
}

function ReadBytes($length) {
fseek($this->openfile, $this->position);
$data = strtoupper(bin2hex(fread($this->openfile, $length)));
$bytes = array(); $x = 0;
for ($i = 0; $i < strlen($data); $i += 2) {
$bytes[$x] = hexdec(substr($data, $i, 1) . substr($data, $i + 1, 1));
$x += 1;
}
$this->position = ftell($this->openfile);
return $bytes;
}

function ReadHexString($length) {
fseek($this->openfile, $this->position);
$data = strtoupper(bin2hex(fread($this->openfile, $length)));
$this->position = ftell($this->openfile);
return $data;
}

function ReadChar() {
fseek($this->openfile, $this->position);
$data = fread($this->openfile, 1);
$this->position = ftell($this->openfile);
return $data;
}

function ReadString($length) {
fseek($this->openfile, $this->position);
$data = fread($this->openfile, $length);
$this->position = ftell($this->openfile);
return $data;
}

function ReadUnicodeString($length) {
fseek($this->openfile, $this->position);
$buffer = fread($this->openfile, $length * 2);
$data = str_replace(chr(0x0), "", $buffer);
$this->position = ftell($this->openfile);
return $data;
}

function ReadInt8() {
$conv = new Conversions;
$bytes = $this->ReadByte();
return $conv->ByteToInt8($bytes);
}

function ReadInt16($endian = 0) {
$conv = new Conversions;
$bytes = $this->ReadBytes(2);
if ($endian == 1) { $bytes = array_reverse($bytes); }
return $conv->BytesToInt16($bytes);
}

function ReadInt32($endian = 0) {
$conv = new Conversions;
$bytes = $this->ReadBytes(4);
if ($endian == 1) { $bytes = array_reverse($bytes); }
return $conv->BytesToInt32($bytes);
}

function ReadUInt8() {
$conv = new Conversions;
$bytes = $this->ReadByte();
return $conv->ByteToUInt8($bytes);
}

function ReadUInt16($endian = 0) {
$conv = new Conversions;
$bytes = $this->ReadBytes(2);
if ($endian == 1) { $bytes = array_reverse($bytes); }
return $conv->BytesToUInt16($bytes);
}

function ReadUInt32($endian = 0) {
$conv = new Conversions;
$bytes = $this->ReadBytes(4);
if ($endian == 1) { $bytes = array_reverse($bytes); }
return $conv->BytesToUInt32($bytes);
}

}

class Writer {
private $filepath = "";
private $openfile = "";
private $filemode = "";
private $position = 0;
private $length = 0;

public function __construct($filepath, $filemode = "w", $position = 0) {
$this->filepath = $filepath;
$this->filemode = $filemode;
$this->position = $position;
if (file_exists($this->filepath)) { $this->length = filesize($this->filepath); }
else { $this->length = 0; }
}

function FileName() {
return basename($this->filepath);
}

function FileMode($filemode) {
if ($filemode != null) { $this->filemode = $filemode; }
return $this->filemode;
}

function Length() {
clearstatcache();
if (file_exists($this->filepath)) { $this->length = filesize($this->filepath); }
else { $this->length = 0; }
return $this->length;
}

function Position($position) {
if ($position != null) { $this->position = $position; }
return $this->position;
}

function Open() {
$this->openfile = fopen($this->filepath, $this->filemode) or exit("could not open file");
return $this->openfile;
}

function Close() {
return fclose($this->openfile);
}

function WriteByte($byte) {
fseek($this->openfile, $this->position);
$data = fwrite($this->openfile, chr($byte));
$this->position = ftell($this->openfile);
return $data;
}

function WriteBytes($bytes) {
fseek($this->openfile, $this->position);
$data = 0;
for ($i = 0; $i < count($bytes); $i++) {
$data += fwrite($this->openfile, chr($bytes[$i]));
}
$this->position = ftell($this->openfile);
return $data;
}

function WriteHexString($str) {
fseek($this->openfile, $this->position);
$bytes = array(); $x = 0;
for ($i = 0; $i < strlen($str); $i += 2) {
$bytes[$x] = hexdec(substr($str, $i, 1) . substr($str, $i + 1, 1));
$x += 1;
}
$data = 0;
for ($i = 0; $i < count($bytes); $i++) {
$data += fwrite($this->openfile, chr($bytes[$i]));
}
$this->position = ftell($this->openfile);
return $data;
}

function WriteChar($char) {
fseek($this->openfile, $this->position);
$data = fwrite($this->openfile, $char);
$this->position = ftell($this->openfile);
return $data;
}

function WriteString($string) {
fseek($this->openfile, $this->position);
$data = fwrite($this->openfile, $string);
$this->position = ftell($this->openfile);
return $data;
}

function WriteUnicodeString($str, $endian = 1) {
fseek($this->openfile, $this->position);
$data = 0;
for ($i = 0; $i < strlen($str); $i++) {
if ($endian == 1) {
$data += fwrite($this->openfile, substr($str, $i, 1) . chr(0x0));
} else {
$data += fwrite($this->openfile, chr(0x0) . substr($str, $i, 1));
}
}
$this->position = ftell($this->openfile);
return $data;
}

function WriteInt8($dec) {
$conv = new Conversions;
$bytes = $conv->Int8ToByte($dec);
return $this->WriteByte($bytes);
}

function WriteInt16($dec, $endian = 0) {
$conv = new Conversions;
$bytes = $conv->Int16ToBytes($dec);
if ($endian == 1) { $bytes = array_reverse($bytes); }
return $this->WriteBytes($bytes);
}

function WriteInt32($dec, $endian = 0) {
$conv = new Conversions;
$bytes = $conv->Int32ToBytes($dec);
if ($endian == 1) { $bytes = array_reverse($bytes); }
return $this->WriteBytes($bytes);
}

function WriteUInt8($dec) {
$conv = new Conversions;
$bytes = $conv->UInt8ToByte($dec);
return $this->WriteByte($bytes);
}

function WriteUInt16($dec, $endian = 0) {
$conv = new Conversions;
$bytes = $conv->UInt16ToBytes($dec);
if ($endian == 1) { $bytes = array_reverse($bytes); }
return $this->WriteBytes($bytes);
}

function WriteUInt32($dec, $endian = 0) {
$conv = new Conversions;
$bytes = $conv->UInt32ToBytes($dec);
if ($endian == 1) { $bytes = array_reverse($bytes); }
return $this->WriteBytes($bytes);
}

}

class EndianType {
const BIG = 0;
const LITTLE = 1;
function GetValue($name) { $name = strtoupper($name); return constant("EndianType::".$name); }
function GetName($value) { switch ($value) { case 0: return "BIG"; break; case 1: return "LITTLE"; break; default: return "NOTHING"; } }
}

class Conversions {

function UInt8ToInt8($dec) { if ($dec > 127) { $dec = ($dec - 256); } return $dec; }
function UInt16ToInt16($dec) { if ($dec > 32767) { $dec = ($dec - 65536); } return $dec; }
function UInt32ToInt32($dec) { if ($dec > 2147483647) { $dec = ($dec - 4294967296); } return $dec; }
function Int8ToUInt8($dec) { if ($dec < 0) { $dec = ($dec + 256); } return $dec; }
function Int16ToUInt16($dec) { if ($dec < 0) { $dec = ($dec + 65536); } return $dec; }
function Int32ToUInt32($dec) { if ($dec < 0) { $dec = ($dec + 4294967296); } return $dec; }
function BytesToAscii ($bytes) { $str = ""; for ($i = 0; $i < count($bytes); $i ++) { $str .= chr($bytes[$i]); } return $str; }
function AsciiToBytes($str) { $bytes = array(); for ($i = 0; $i < strlen($str); $i ++) { $bytes[$i] = ord(substr($str, $i, 1)); } return $bytes; }
function AsciiToHex($str) { return bin2hex($str); }
function HexToAscii($str) { $data = ""; $byte = ""; for ($i = 0; $i < strlen($str); $i += 2) { $byte = hexdec($str[$i] . $str[$i + 1]); $data .= chr($byte); } return $data; }
function BytesToUnicode($bytes) { $str = ""; for ($i = 0; $i < count($bytes); $i ++) { $str .= chr($bytes[$i]); } return str_replace(chr(0x0), "", $str); }
function UnicodeToBytes($str, $endian = 1) { $bytes = array(); for ($i = 0; $i < strlen($str); $i ++) { if ($endian == 1) { array_push($bytes, ord(substr($str, $i, 1))); array_push($bytes, 0x0); } else { array_push($bytes, 0x0); array_push($bytes, ord(substr($str, $i, 1))); } } return $bytes; }
function UnicodeToHex($str, $endian = 1) { $data = ""; for ($i = 0; $i < strlen($str); $i++) { if ($endian == 1) { $data .= substr($str, $i, 1); $data .= chr(0x0); } else { $data .= chr(0x0); $data .= substr($str, $i, 1); } } return strtoupper(bin2hex($data)); }
function HexToUnicode($str) { $data = ""; $byte = ""; for ($i = 0; $i < strlen($str); $i += 2) { $byte = hexdec($str[$i] . $str[$i + 1]); if (chr($byte) != chr(0x0)) { $data .= chr($byte); } } return $data; }
function HexToBytes($str) { if (strlen($str) == 0) { return 0; } $bytes = array(); $x = 0; for ($i = 0; $i < strlen($str); $i += 2) { $bytes[$x] = hexdec(substr($str, $i, 1) . substr($str, $i + 1, 1)); $x += 1; } return $bytes; }
function BytesToHex($bytes) { if (!is_array($bytes)) { return strtoupper(dechex($bytes)); } $hex = ''; for ($i = 0; $i < count($bytes); $i ++) { $hex .= dechex($bytes[$i]); } return strtoupper($hex); }
function ByteToInt8($byte) { if (is_array($byte)) { throw new Exception("invalid input"); } $conv = new Conversions; return $conv->UInt8ToInt8($byte); }
function BytesToInt16($bytes) { if (count($bytes) != 2) { throw new Exception("invalid input"); } $dec = (($bytes[0] << 8) + ($bytes[1])); $conv = new Conversions; return $conv->UInt16ToInt16($dec); }
function BytesToInt32($bytes) { if (count($bytes) != 4) { throw new Exception("invalid input"); } $dec = (($bytes[0] << 24) + ($bytes[1] << 16) + ($bytes[2] << 8) + ($bytes[3])); $conv = new Conversions; return $conv->UInt32ToInt32($dec); }
function ByteToUInt8($byte) { if (is_array($byte)) { throw new Exception("invalid input"); } $conv = new Conversions; return $conv->Int8ToUInt8($byte); }
function BytesToUInt16($bytes) { if (count($bytes) != 2) { throw new Exception("invalid input"); } $dec = (($bytes[0] << 8) + ($bytes[1])); $conv = new Conversions; return $conv->Int16ToUInt16($dec); }
function BytesToUInt32($bytes) { if (count($bytes) != 4) { throw new Exception("invalid input"); } $dec = (($bytes[0] << 24) + ($bytes[1] << 16) + ($bytes[2] << 8) + ($bytes[3])); $conv = new Conversions; return $conv->Int32ToUInt32($dec); }
function Int8ToByte($dec) { if ($dec > 127 || $dec < -128) { throw new Exception("invalid input"); } $byte = ($dec & 0xFF); return $byte; }
function Int16ToBytes($dec) { if ($dec > 32767 || $dec < -32768) { throw new Exception("invalid input"); } $bytes = array(); $bytes[0] = ($dec >> 8) & 0xFF; $bytes[1] = ($dec) & 0xFF; return $bytes; }
function Int32ToBytes($dec) { if ($dec > 2147483647 || $dec < -2147483648) { throw new Exception("invalid input"); } $bytes = array(); $bytes[0] = ($dec >> 24) & 0xFF; $bytes[1] = ($dec >> 16) & 0xFF; $bytes[2] = ($dec >> 8) & 0xFF; $bytes[3] = ($dec >> 0) & 0xFF; return $bytes; }
function UInt8ToByte($dec) { if ($dec > 255 || $dec < 0) { throw new Exception("invalid input"); } $byte = ($dec & 0xFF); return $byte; }
function UInt16ToBytes($dec) { if ($dec > 65535 || $dec < 0) { throw new Exception("invalid input"); } $bytes = array(); $bytes[0] = ($dec >> 8) & 0xFF; $bytes[1] = ($dec) & 0xFF; return $bytes; }
function UInt32ToBytes($dec) { if ($dec > 4294967295 || $dec < 0) { throw new Exception("invalid input"); } $bytes = array(); $bytes[0] = ($dec >> 24) & 0xFF; $bytes[1] = ($dec >> 16) & 0xFF; $bytes[2] = ($dec >> 8) & 0xFF; $bytes[3] = ($dec) & 0xFF; return $bytes; }
function ArrayReverse($array) { return array_reverse($array); }
}

?>

JizzaBeez
07-13-2011, 06:43 AM
Update: new version = 1.0.5.0

New features:

-Read Int8/UInt8/Int16/UInt16/Int32/UInt32 in both endians!

-Write Int8/UInt8/Int16/UInt16/Int32/UInt32 in both endians!

-Conversions Class with a lot of type conversions.

Mocha
05-07-2012, 09:29 PM
Do you plan on adding support for Reading Unicode Strings?

JizzaBeez
05-10-2012, 12:57 PM
Do you plan on adding support for Reading Unicode Strings?

Done.


Update: new version = 1.0.6.0

New features:

Reader
-ReadUnicodeString

<?php
require("phpio.php");
$filepath = "C:\Untitled1.txt";
$reader = new Reader($filepath);
$reader->Open();
$reader->Position(0);
$length = 9; // length of the string excluding null bytes
$data = $reader->ReadUnicodeString($length);
$reader->Close();
echo($data);
// bytes = "4A 00 69 00 7A 00 7A 00 61 00 42 00 65 00 65 00 7A 00"
// string = "JizzaBeez"
?>

Writer
-WriteUnicodeString

<?php
require("phpio.php");
$filepath = "C:\Untitled1.txt";
$writer = new Writer($filepath);
$writer->Open();
$writer->Position(0);
$data = "JizzaBeez";
$writer->WriteUnicodeString($data, 1); // "1" = little endian, "0" = big endian
$writer->Close();
// bytes = "4A 00 69 00 7A 00 7A 00 61 00 42 00 65 00 65 00 7A 00"
// string = "JizzaBeez"
?>

Conversions
-UnicodeToBytes
-BytesToUnicode
-UnicodeToHex
-HexToUnicode