initial commits

master
Charles Iliya Krempeaux 2023-10-27 13:31:50 -07:00
parent bdf540c282
commit e18ab2b384
3 changed files with 61 additions and 10 deletions

View File

@ -144,15 +144,30 @@ mostSignificant, leastSignificant := hexadecarunes.EncodeByte(value, runesymbols
To hexadecimal encode a `uint16` use any of these:
```go
import "sourcecode.social/reiver/go-hexadeca"
import "sourcecode.social/reiver/go-hexadeca/enc/bytes"
// ...
r3, r2, r1, r0 := hexadeca.EncodeUint16UsingLowerCaseSymbols(value)
r3, r2, r1, r0 := hexadecabytes.EncodeUint16UsingLowerCaseSymbols(value)
// ...
r3, r2, r1, r0 := hexadeca.EncodeUint16UsingUpperCaseSymbols(value)
r3, r2, r1, r0 := hexadecabytes.EncodeUint16UsingUpperCaseSymbols(value)
```
Or:
```go
import "sourcecode.social/reiver/go-hexadeca/enc/runes"
// ...
r3, r2, r1, r0 := hexadecarunes.EncodeUint16UsingLowerCaseSymbols(value)
// ...
r3, r2, r1, r0 := hexadecarunes.EncodeUint16UsingUpperCaseSymbols(value)
```
@ -160,17 +175,34 @@ Or:
```go
import (
"sourcecode.social/reiver/go-hexadeca"
"sourcecode.social/reiver/go-hexadeca/enc/bytes"
"sourcecode.social/reiver/go-hexadeca/symbols/byte"
)
// ...
r3, r2, r1, r0 := hexadecabytes.EncodeUint16(value, bytesymbols.LowerCase)
// ...
r3, r2, r1, r0 := hexadecabytes.EncodeUint16(value, bytesymbols.UpperCase)
```
Or:
```go
import (
"sourcecode.social/reiver/go-hexadeca/enc/bytes"
"sourcecode.social/reiver/go-hexadeca/symbols/rune"
)
// ...
r3, r2, r1, r0 := hexadeca.EncodeUint16(value, runesymbols.LowerCase)
r3, r2, r1, r0 := hexadecabytes.EncodeUint16(value, runesymbols.LowerCase)
// ...
r3, r2, r1, r0 := hexadeca.EncodeUint16(value, runesymbols.UpperCase)
r3, r2, r1, r0 := hexadecabytes.EncodeUint16(value, runesymbols.UpperCase)
```
## hexadecimal encode `uint32`

View File

@ -0,0 +1,20 @@
package hexadecabytes
import (
"sourcecode.social/reiver/go-hexadeca/symbols/byte"
)
func EncodeUint16(value uint16, symbolFunc func(byte)byte) (r3 byte, r2 byte, r1 byte, r0 byte) {
r3, r2 = EncodeByte(byte(0x00ff & (value >> (8 ))), symbolFunc)
r1, r0 = EncodeByte(byte(0x00ff & value ), symbolFunc)
return
}
func EncodeUint16UsingLowerCaseSymbols(value uint16) (r3 byte, r2 byte, r1 byte, r0 byte) {
return EncodeUint16(value, bytesymbols.LowerCase)
}
func EncodeUint16UsingUpperCaseSymbols(value uint16) (r3 byte, r2 byte, r1 byte, r0 byte) {
return EncodeUint16(value, bytesymbols.UpperCase)
}

View File

@ -1,13 +1,12 @@
package hexadeca
package hexadecarunes
import (
"sourcecode.social/reiver/go-hexadeca/enc/runes"
"sourcecode.social/reiver/go-hexadeca/symbols/rune"
)
func EncodeUint16(value uint16, symbolFunc func(byte)rune) (r3 rune, r2 rune, r1 rune, r0 rune) {
r3, r2 = hexadecarunes.EncodeByte(byte(0x00ff & (value >> (8 ))), symbolFunc)
r1, r0 = hexadecarunes.EncodeByte(byte(0x00ff & value ), symbolFunc)
r3, r2 = EncodeByte(byte(0x00ff & (value >> (8 ))), symbolFunc)
r1, r0 = EncodeByte(byte(0x00ff & value ), symbolFunc)
return
}