Welcome!

Join our community of MMORPG enthusiasts and private server developers! By registering, you'll gain access to in-depth discussions on source codes, binaries, and the latest developments in MMORPG server files. Collaborate with like-minded individuals, explore tutorials, and share insights on building and optimizing private servers. Join us today and unlock the full potential of MMORPG server development!

Join Today!

[PHP]add bytes to string

Joined
Sep 30, 2003
Messages
1,270
Reaction score
10
Location
With u :)
Hey coders, i need some help, i'm doing some EPP standard stuff

and i have this xml and EPP standard says you need to add 4 bytes to the top of the xml with the total xml size (xml + 4 bytes),

anyways i was doing that like this, since UTF-8 characters are 1byte long
PHP:
$output;
$output = dechex(strlen($output)+4) . $output;

anyways that would prepend the hex value of the total $output size but less then 4 bytes so i did this:

PHP:
$size = dechex(strlen($output)+4);
while(strlen($size) <= 5){
	$size = '0' . $size;
}
$output = $size . $output;

this way i would allways get 4bytes at the top of the message, but atm those 4 bytes are just numbers and not bytes so how do i "encode" them? i've tried utf8_encode with no sucess.

heres the document that guides de EPP standard i'm trying to follow (in case i didn't made my point :P)

GriffinHeart - [PHP]add bytes to string - RaGEZONE Forums



any help apreciated.
 
Back