Jump to content

Reading hex


kardenal

Recommended Posts

Hi. I'm trying to get PHP to read a hex value. This value comes from an SMS message sendt by a logger. It has information of energyusage. The information is sendt in hex and is 112 char long but PHP codes (pack) this into a 12 char long ASCII string and i can't find a way decode (unpack) this to its originale form. Does anyone have any idea how i can get hold of the initial hex value?

The SMS message: format definition from linux "gsmsmsd" command.

Type of message: SMS message
Message type: SMS-DELIVER
SC address: '4792001000'
More messages to send: 1
Reply path: 0
User data header indicator: 0
Status report indication: 0
Originating address: '4793002664'
Protocol identifier: 0x0
Data coding scheme: compressed fax message waiting
SC timestamp: 05/01/2006 12:00:27 AM (+0200)
User data length: [!--coloro:#CC0000--][span style=\"color:#CC0000\"][!--/coloro--]112 [!--colorc--][/span][!--/colorc--]
User data header: 0x
User data: '[!--coloro:#CC0000--][span style=\"color:#CC0000\"][!--/coloro--]m741007ë,W[!--colorc--][/span][!--/colorc--]

The "m741007ë,W" is a representation of the 112 chr hex string.

The hex is 16 based.

Anyone???
Link to comment
https://forums.phpfreaks.com/topic/8875-reading-hex/
Share on other sites

You are probably echoing the "User data string" and since it looks like the information contains binary (i.e. non characters) it most likely has some NULL characters (all zeroes) which stops a normal character string.

Take a look at the functions [a href=\"http://www.php.net/pack\" target=\"_blank\"]pack()[/a] and [a href=\"http://www.php.net/bin2hex\" target=\"_blank\"]bin2hex()[/a]. One of them should give you what you're looking for.

Ken
Link to comment
https://forums.phpfreaks.com/topic/8875-reading-hex/#findComment-32607
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.