quote:
Originally posted by Mattike
So, if I understand, you have a string like
code:
var thing = "FF00FC";
and you need a function which makes it like this:
code:
var new_thing = "\xFF\x00\xFC";
If so, this should do:
code:
function SetDataPatch(string) {
var newstring = "";
for(var i=0; i<string.length; i+=2) {
var hex = string.substr(i, 2); //The hexadecimal character code
var dec = parseInt(hex, 16); //The decimal character code
newstring += String.fromCharCode(dec); //Adds the character to the string
}
return newstring;
}
I thank you but this code for me don't work
function SetDataPatch(string) {
var newstring = "";
for(var i=0; i<string.length; i+=2) {
var hex = string.substr(i, 2); //The hexadecimal character code
var dec = parseInt(hex, 16); //The decimal character code
newstring += String.fromCharCode(dec); //Adds the character to the string
}
Debug.Trace(newstring)
return newstring;
}