-1

Hey all I have the following 32 hexadecimal digit string:

0x80000000000000003F64000000000000

And when I need to take that number above and look up something with it I need it to be searchable in this type of format:

0000-0000-3F64-0000-S-0000-0000-R

The official format it needs to be in order to search is explained like this:

Format:

NNNN-NNNN-NNNN-NNNN-X
   or
NNNN-NNNN-NNNN-NNNN-X-NNNN-NNNN-Y
   or
NNNN-NNNN-NNNN-NNNN

where N are hexadecimal digits, X and Y are check digits.

16 hexadecimal digit followed with a check character (using Arabic numerals 0 to 9 and letters A to Z), followed by an 8 hexadecimal digit version segment, followed with a check character (using Arabic numerals 0 to 9 and letters A to Z).

Defined in ISO 15706-2 Annex D. The ISAN.

ROOT: 0000-0000-3F64

Tree segment of 4 digit hexadecimal values separated with a hyphen "-"

EpisodeOrPart: 0000

One segment of 4 digit hexadecimal values.

Check1: S

One digit made of a decimal value from 0 to 9 or an upper case charater from A to Z.

Version: 0000-0000

Two segments of 4 digits hexadecimal values separated with an hyphen "-".

Check2: R

One digit made of a decimal value from 0 to 9 or an upper case character from A to Z.

And I am not really sure how to go about converting what I have to the needed format so any help would be great!

Note: The "-S" and the "-R" can be removed. Those are random computer generated algorithms that add those which, as you see in the example above, are not needed in the search if you do not have them available. So really I would only be interested in getting the format to be "0000-0000-3F64-0000-0000-0000".

4

2 回答 2

0

不是 100% 确定你想要什么,但是......

此函数0x从头开始删除:

Private Function format(ByVal str As String) As String
    str = str.Substring(10)
    For i As Integer = 20 To 4 Step -4
        str = str.Insert(i, "-")
    Next
    Return str
End Function

0000-0000-3F64-0000-0000-0000从返回0x80000000000000003F64000000000000

对于仅 32 个不带0x前缀的十六进制字符,此函数:

Private Function format(ByVal str As String) As String
    str = str.Substring(8)
    For i As Integer = 20 To 4 Step -4
        str = str.Insert(i, "-")
    Next
    Return str
End Function

0000-0000-3F64-0000-0000-0000从返回80000000000000003F64000000000000

于 2015-05-18T07:02:01.873 回答
0

根本不清楚你想要什么...... 8 去哪里了?

这是一些可能有帮助的代码...

'32 hex digits = 16 bytes (128 bits)'
Dim s As String = "0x80000000000000003F64000000000000" 
'simple reformat'
Dim s_sf As String = s.Substring(10, 4) & "-" & s.Substring(14, 4) & "-" & s.Substring(18, 4) & "-" & s.Substring(22, 4) & "-S-" & s.Substring(26, 4) & "-" & s.Substring(30, 4) & "-R"
MsgBox(s_sf)
'Convert hex string to byte 0x3F = 63 decimal
Dim b As Byte = Convert.ToByte("3F", 16)
MsgBox(b.ToString)
'Convert byte to Hex string 63 decimal = 0x3F
Dim s_hex As String = Hex(63)
MsgBox(s_hex)
于 2015-05-18T07:48:23.820 回答