471,050 Members | 1,193 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,050 software developers and data experts.

Encoding IPv4 Address to HexBinary

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
3 2748
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
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
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.

Similar topics

reply views Thread by David Bear | last post: by
1 post views Thread by Don Adams | last post: by
15 posts views Thread by qazmlp | last post: by
8 posts views Thread by Erwin Moller | last post: by
2 posts views Thread by Valerie Hough | last post: by
1 post views Thread by =?Utf-8?B?V2lsbGlhbSBSYW5kbGV0dA==?= | last post: by
14 posts views Thread by Simon | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.