424,066 Members | 2,120 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,066 IT Pros & Developers. It's quick & easy.

Encoding IPv4 Address to HexBinary

P: n/a
Please help me out
1. What is meant by HexBinary Encoding,how is this done?
2. How must i convert a IPv4 Address to HexBinary Format ???

Thnx
Fernando

Jun 20 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 20 Jun, 15:32, xxyyzz <xxyyzzy...@gmail.comwrote:
Please help me out

1. What is meant by HexBinary Encoding,how is this done?
2. How must i convert a IPv4 Address to HexBinary Format ???

Thnx
Fernando
The schema datatypes spec defines a hexBinary format. You can see it
at:

http://www.w3.org/TR/xmlschema-2/#hexBinary

Basically each byte is represented by two ASCII hexadecimal
characters.

It's also common in schemas to represent IP addresses using xs:string
and then restrict that with a pattern along the lines of:

<xs:pattern value="[1-9][0-9]{0,2}(\.[1-9][0-9]{0,2}){3}"/>

You can refine the pattern if you like to take into account that you
don't get IP addresses like 876.432.354.974, but that's too much like
hard work for me!

HTH,

Pete.
--
=============================================
Pete Cordell
Codalogic Ltd
for XML Schema to C++ data binding visit
http://www.codalogic.com/lmx/
=============================================

Jun 21 '07 #2

P: n/a
On Jun 21, 2:22 pm, use...@tech-know-ware.com wrote:
On 20 Jun, 15:32, xxyyzz <xxyyzzy...@gmail.comwrote:
Please help me out
1. What is meant by HexBinary Encoding,how is this done?
2. How must i convert a IPv4 Address to HexBinary Format ???
Thnx
Fernando

The schema datatypes spec defines a hexBinary format. You can see it
at:

http://www.w3.org/TR/xmlschema-2/#hexBinary

Basically each byte is represented by two ASCII hexadecimal
characters.

It's also common in schemas to represent IP addresses using xs:string
and then restrict that with a pattern along the lines of:

<xs:pattern value="[1-9][0-9]{0,2}(\.[1-9][0-9]{0,2}){3}"/>

You can refine the pattern if you like to take into account that you
don't get IP addresses like 876.432.354.974, but that's too much like
hard work for me!

HTH,

Pete.
--
=============================================
Pete Cordell
Codalogic Ltd
for XML Schema to C++ data binding visit
http://www.codalogic.com/lmx/
=============================================
Pete,
do mean dat we convert the IP to hex and then dat hex to ASCII

ex: (90.21.2.101)

IP 90. 21. 2. 101
HEX 5a 15 02 65

HEX to ASCII

HEX 5 a 1 5 0 2 6 5
ASCII 35 61 31 35 30 32 36 35

Waiting for your response,
Thanx,
Fernando

Jun 21 '07 #3

P: n/a
On 21 Jun, 11:05, xxyyzz <xxyyzzy...@gmail.comwrote:
>
Pete,
do mean dat we convert the IP to hex and then dat hex to ASCII

ex: (90.21.2.101)

IP 90. 21. 2. 101
HEX 5a 15 02 65

HEX to ASCII

HEX 5 a 1 5 0 2 6 5
ASCII 35 61 31 35 30 32 36 35

Waiting for your response,
Thanx,
Fernando
Looking at it, the reference to ASCII didn't really help much!

You stop at the hex stage, then join them all up. An example in an
XML instance would be something like:

<ipv4>5a150265</ipv4>

HTH,

Pete.
--
=============================================
Pete Cordell
Codalogic Ltd
for XML Schema to C++ data binding visit
http://www.codalogic.com/lmx/
=============================================

Jun 21 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.