RE: [PHP] sending a hex string as it is?
But I think he'll still have an issue when he goes to transmit it. Whatever data you have is going to be interpreted by the function doing the sending unless it's a "binary safe" function that's going to send raw binary. Thanks for the tip on "pack" though. Havn't needed it yet, but always good to know. And PHP has so many functions (I'm constantly amazed that it usually has a function for whatever I need). -TG > -Original Message- > From: DvDmanDT [mailto:[EMAIL PROTECTED] > Sent: Thursday, January 29, 2004 6:58 PM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] sending a hex string as it is? > > > No need to ge that deep (socket_create and stuff).. > To send the HEX number 20 (also a space), you can do the following: > > "\x20"; > chr(0x20); > chr(hexdec('20')); > pack('C',0x20); > > All of those _should_ create a space... > -- > // DvDmanDT > MSN: dvdmandt¤hotmail.com > Mail: dvdmandt¤telia.com > "Trevor Gryffyn" <[EMAIL PROTECTED]> skrev i meddelandet > news:[EMAIL PROTECTED] > RCARGO.COM... > Ahh.. Since you're not declaring what data type $var is, it must be > treating it as a string, even though I'd think it'd take it > as an int if > you didn't put quotes around it. That's one thing I like about PHP.. > You can be as strict or lax as you want with the types. But I can see > in this case where it'd cause an issue. > > Well, you could try: > > Intval($var) > > That should force it to be an integer. > > > You know what, I think the real question here is how are you > "sending it > over the wire". Sounds like you're sending it in some manner that > transmits it as text. In which case you WILL get "32 30" for a "20".. > And if you convert the 20 to an INT, you'll still get it > because of the > way you're transmitting. > > You're probably going to have to open a binary connection to whatever > you're doing. > > Look into "socket_create()" > > Sounds like you need something a little more low-level than > what you're > using. > > -TG > > > -Original Message- > > From: Khoa Nguyen [mailto:[EMAIL PROTECTED] > > Sent: Thursday, January 29, 2004 8:51 AM > > To: David OBrien; [EMAIL PROTECTED] > > Subject: RE: [PHP] sending a hex string as it is? > > > > > > I guess I confused the matter by mentioning hex. The problem > > is the same > > with decimal number; for example > > > $var = 20; > > echo $var; // This will send 32 30 over the wire, not 14 (hex > > value of decimal 20) > > // How do I make it send 14? > > ?> > > > > I guess "echo" function treats $var as a string. Maybe I am > > looking for > > a function that will sends a data stream as it is > > > > Thanks, > > Khoa > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sending a hex string as it is?
No need to ge that deep (socket_create and stuff).. To send the HEX number 20 (also a space), you can do the following: "\x20"; chr(0x20); chr(hexdec('20')); pack('C',0x20); All of those _should_ create a space... -- // DvDmanDT MSN: dvdmandt¤hotmail.com Mail: dvdmandt¤telia.com "Trevor Gryffyn" <[EMAIL PROTECTED]> skrev i meddelandet news:[EMAIL PROTECTED] Ahh.. Since you're not declaring what data type $var is, it must be treating it as a string, even though I'd think it'd take it as an int if you didn't put quotes around it. That's one thing I like about PHP.. You can be as strict or lax as you want with the types. But I can see in this case where it'd cause an issue. Well, you could try: Intval($var) That should force it to be an integer. You know what, I think the real question here is how are you "sending it over the wire". Sounds like you're sending it in some manner that transmits it as text. In which case you WILL get "32 30" for a "20".. And if you convert the 20 to an INT, you'll still get it because of the way you're transmitting. You're probably going to have to open a binary connection to whatever you're doing. Look into "socket_create()" Sounds like you need something a little more low-level than what you're using. -TG > -Original Message----- > From: Khoa Nguyen [mailto:[EMAIL PROTECTED] > Sent: Thursday, January 29, 2004 8:51 AM > To: David OBrien; [EMAIL PROTECTED] > Subject: RE: [PHP] sending a hex string as it is? > > > I guess I confused the matter by mentioning hex. The problem > is the same > with decimal number; for example > $var = 20; > echo $var; // This will send 32 30 over the wire, not 14 (hex > value of decimal 20) > // How do I make it send 14? > ?> > > I guess "echo" function treats $var as a string. Maybe I am > looking for > a function that will sends a data stream as it is > > Thanks, > Khoa -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] sending a hex string as it is?
Ahh.. Since you're not declaring what data type $var is, it must be treating it as a string, even though I'd think it'd take it as an int if you didn't put quotes around it. That's one thing I like about PHP.. You can be as strict or lax as you want with the types. But I can see in this case where it'd cause an issue. Well, you could try: Intval($var) That should force it to be an integer. You know what, I think the real question here is how are you "sending it over the wire". Sounds like you're sending it in some manner that transmits it as text. In which case you WILL get "32 30" for a "20".. And if you convert the 20 to an INT, you'll still get it because of the way you're transmitting. You're probably going to have to open a binary connection to whatever you're doing. Look into "socket_create()" Sounds like you need something a little more low-level than what you're using. -TG > -Original Message- > From: Khoa Nguyen [mailto:[EMAIL PROTECTED] > Sent: Thursday, January 29, 2004 8:51 AM > To: David OBrien; [EMAIL PROTECTED] > Subject: RE: [PHP] sending a hex string as it is? > > > I guess I confused the matter by mentioning hex. The problem > is the same > with decimal number; for example >$var = 20; > echo $var; // This will send 32 30 over the wire, not 14 (hex > value of decimal 20) > // How do I make it send 14? > ?> > > I guess "echo" function treats $var as a string. Maybe I am > looking for > a function that will sends a data stream as it is > > Thanks, > Khoa -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] sending a hex string as it is?
I guess I confused the matter by mentioning hex. The problem is the same with decimal number; for example I guess "echo" function treats $var as a string. Maybe I am looking for a function that will sends a data stream as it is Thanks, Khoa -Original Message- From: David OBrien [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 3:25 PM To: Khoa Nguyen Subject: RE: [PHP] sending a hex string as it is? Also http://www.php.net/manual/en/function.sprintf.php has provisions for using hex and octal numbers -dave At 02:17 PM 1/28/2004, you wrote: >Thanks for the info Dave, but I still can't make it work: > > $var = 0x10; // decimal 16 > echo $var; // case 1 > echo strval($var); // case 2 >?> > >In both cases, I see 3136 (ASCII encoded of string "16") on the wire >:-( > >Any ideas? > >Khoa > >-Original Message- >From: David OBrien [mailto:[EMAIL PROTECTED] >Sent: Wednesday, January 28, 2004 2:08 PM >To: Khoa Nguyen; [EMAIL PROTECTED] >Subject: Re: [PHP] sending a hex string as it is? > > >At 02:03 PM 1/28/2004, Khoa Nguyen wrote: > > >$var = 0x8180; > > > >How do I send $var to the browser as it is? In other words, if > >sniffing > > >on the wire, I should see 8180, not 38 31 38 30. > > >I think >http://www.php.net/manual/en/function.strval.php >would work here >-Dave > > >Thanks for your help. > >Khoa > > > >-- > >PHP General Mailing List (http://www.php.net/) > >To unsubscribe, visit: http://www.php.net/unsub.php > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] sending a hex string as it is?
At 02:17 PM 1/28/2004, Khoa Nguyen wrote: Thanks for the info Dave, but I still can't make it work: $var = "0x" . dechex(strval($var)); is about the only way I could get it to show 0x10 instead of 16 -Dave ?> In both cases, I see 3136 (ASCII encoded of string "16") on the wire :-( Any ideas? Khoa -Original Message- From: David OBrien [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 2:08 PM To: Khoa Nguyen; [EMAIL PROTECTED] Subject: Re: [PHP] sending a hex string as it is? At 02:03 PM 1/28/2004, Khoa Nguyen wrote: >$var = 0x8180; > >How do I send $var to the browser as it is? In other words, if sniffing >on the wire, I should see 8180, not 38 31 38 30. I think http://www.php.net/manual/en/function.strval.php would work here -Dave >Thanks for your help. >Khoa > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sending a hex string as it is?
Did you consider following? $var="\x10"; ? Or dechex();? -- // DvDmanDT MSN: dvdmandt¤hotmail.com Mail: dvdmandt¤telia.com "Khoa Nguyen" <[EMAIL PROTECTED]> skrev i meddelandet news:[EMAIL PROTECTED] Thanks for the info Dave, but I still can't make it work: In both cases, I see 3136 (ASCII encoded of string "16") on the wire :-( Any ideas? Khoa -Original Message- From: David OBrien [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 2:08 PM To: Khoa Nguyen; [EMAIL PROTECTED] Subject: Re: [PHP] sending a hex string as it is? At 02:03 PM 1/28/2004, Khoa Nguyen wrote: >$var = 0x8180; > >How do I send $var to the browser as it is? In other words, if sniffing >on the wire, I should see 8180, not 38 31 38 30. I think http://www.php.net/manual/en/function.strval.php would work here -Dave >Thanks for your help. >Khoa > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] sending a hex string as it is?
Thanks for the info Dave, but I still can't make it work: In both cases, I see 3136 (ASCII encoded of string "16") on the wire :-( Any ideas? Khoa -Original Message- From: David OBrien [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 2:08 PM To: Khoa Nguyen; [EMAIL PROTECTED] Subject: Re: [PHP] sending a hex string as it is? At 02:03 PM 1/28/2004, Khoa Nguyen wrote: >$var = 0x8180; > >How do I send $var to the browser as it is? In other words, if sniffing >on the wire, I should see 8180, not 38 31 38 30. I think http://www.php.net/manual/en/function.strval.php would work here -Dave >Thanks for your help. >Khoa > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sending a hex string as it is?
At 02:03 PM 1/28/2004, Khoa Nguyen wrote: $var = 0x8180; How do I send $var to the browser as it is? In other words, if sniffing on the wire, I should see 8180, not 38 31 38 30. I think http://www.php.net/manual/en/function.strval.php would work here -Dave Thanks for your help. Khoa -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] sending a hex string as it is?
$var = 0x8180; How do I send $var to the browser as it is? In other words, if sniffing on the wire, I should see 8180, not 38 31 38 30. Thanks for your help. Khoa -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php