<?php
$all = 'RM50';
// single
$r = 'R';
$m = 'M';
$a = '5';
$b = '0';
$s=strtoHex($all);var_dump($s);
// single
$s=strtoHex($r);var_dump($s);
$s=strtoHex($m);var_dump($s);
$s=strtoHex($a);var_dump($s);
$s=strtoHex($b);var_dump($s);
exit();
exit();
function strToHex($string)
{
$hex='';
for ($i=0; $i < strlen($string); $i++)
{
$hex .= dechex(ord($string[$i]));
}
return $hex;
}
?>
Ok here you go.
PHP:<?php $all = 'RM50'; // single $r = 'R'; $m = 'M'; $a = '5'; $b = '0'; $s=strtoHex($all);var_dump($s); // single $s=strtoHex($r);var_dump($s); $s=strtoHex($m);var_dump($s); $s=strtoHex($a);var_dump($s); $s=strtoHex($b);var_dump($s); exit(); exit(); function strToHex($string) { $hex=''; for ($i=0; $i < strlen($string); $i++) { $hex .= dechex(ord($string[$i])); } return $hex; } ?>
var str = 'some string';
str = str.replace(/./g, function(c) { return '\\x' + c.charCodeAt(0).toString(16); });
// str now contains the characters using '\x' notation
str = str.replace(/./g, function(c) { eval("c = '\\x" + c.charCodeAt(0).toString(16) + "';"); return c; });