initial commits

master
Charles Iliya Krempeaux 2023-10-27 13:25:50 -07:00
parent 82f3f4f9d3
commit bdf540c282
7 changed files with 73 additions and 33 deletions

View File

@ -70,17 +70,34 @@ r1, r0 := hexadeca.EncodeRune(value, CustomSymbol)
To hexadecimal encode a `byte` use any of these: To hexadecimal encode a `byte` use any of these:
```go ```go
import "sourcecode.social/reiver/go-hexadeca" import "sourcecode.social/reiver/go-hexadeca/enc/bytes"
// ... // ...
// value==254 -> mostSignificant=='f', leastSignificant=='e' // value==254 -> mostSignificant=='f', leastSignificant=='e'
mostSignificant, leastSignificant := hexadeca.EncodeByteUsingLowerCaseSymbols(value) mostSignificant, leastSignificant := hexadecabytes.EncodeByteUsingLowerCaseSymbols(value)
// ... // ...
// value==254 -> mostSignificant=='F', leastSignificant=='E' // value==254 -> mostSignificant=='F', leastSignificant=='E'
mostSignificant, leastSignificant := hexadeca.EncodeByteUsingUpperCaseSymbols(value) mostSignificant, leastSignificant := hexadecabytes.EncodeByteUsingUpperCaseSymbols(value)
```
Or:
```go
import "sourcecode.social/reiver/go-hexadeca/enc/runes"
// ...
// value==254 -> mostSignificant=='f', leastSignificant=='e'
mostSignificant, leastSignificant := hexadecarunes.EncodeByteUsingLowerCaseSymbols(value)
// ...
// value==254 -> mostSignificant=='F', leastSignificant=='E'
mostSignificant, leastSignificant := hexadecarunes.EncodeByteUsingUpperCaseSymbols(value)
``` ```
@ -88,19 +105,38 @@ Or:
```go ```go
import ( import (
"sourcecode.social/reiver/go-hexadeca" "sourcecode.social/reiver/go-hexadeca/enc/bytes"
"sourcecode.social/reiver/go-hexadeca/symbols/byte"
)
// ...
// value==254 -> mostSignificant=='f', leastSignificant=='e'
mostSignificant, leastSignificant := hexadecabytes.EncodeByte(value, bytesymbols.LowerCase)
// ...
// value==254 -> mostSignificant=='F', leastSignificant=='E'
mostSignificant, leastSignificant := hexadecabytes.EncodeByte(value, bytesymbols.UpperCase)
```
Or:
```go
import (
"sourcecode.social/reiver/go-hexadeca/enc/runes"
"sourcecode.social/reiver/go-hexadeca/symbols/rune" "sourcecode.social/reiver/go-hexadeca/symbols/rune"
) )
// ... // ...
// value==254 -> mostSignificant=='f', leastSignificant=='e' // value==254 -> mostSignificant=='f', leastSignificant=='e'
mostSignificant, leastSignificant := hexadeca.EncodeByte(value, runesymbols.LowerCase) mostSignificant, leastSignificant := hexadecarunes.EncodeByte(value, runesymbols.LowerCase)
// ... // ...
// value==254 -> mostSignificant=='F', leastSignificant=='E' // value==254 -> mostSignificant=='F', leastSignificant=='E'
mostSignificant, leastSignificant := hexadeca.EncodeByte(value, runesymbols.UpperCase) mostSignificant, leastSignificant := hexadecarunes.EncodeByte(value, runesymbols.UpperCase)
``` ```
## hexadecimal encode `uint16` ## hexadecimal encode `uint16`

View File

@ -1,4 +1,4 @@
package hexadeca package hexadecarunes
import ( import (
"sourcecode.social/reiver/go-hexadeca/symbols/rune" "sourcecode.social/reiver/go-hexadeca/symbols/rune"

View File

@ -1,9 +1,9 @@
package hexadeca_test package hexadecarunes_test
import ( import (
"testing" "testing"
"sourcecode.social/reiver/go-hexadeca" "sourcecode.social/reiver/go-hexadeca/enc/runes"
) )
func TestEncodeByteUsingLowerCaseSymbols(t *testing.T) { func TestEncodeByteUsingLowerCaseSymbols(t *testing.T) {
@ -314,7 +314,7 @@ func TestEncodeByteUsingLowerCaseSymbols(t *testing.T) {
for testNumber, test := range tests { for testNumber, test := range tests {
actualMostSignificant, actualLeastSignificant := hexadeca.EncodeByteUsingLowerCaseSymbols(test.Value) actualMostSignificant, actualLeastSignificant := hexadecarunes.EncodeByteUsingLowerCaseSymbols(test.Value)
{ {
actual := actualMostSignificant actual := actualMostSignificant
@ -652,7 +652,7 @@ func TestEncodeByteUsingUpperCaseSymbols(t *testing.T) {
for testNumber, test := range tests { for testNumber, test := range tests {
actualMostSignificant, actualLeastSignificant := hexadeca.EncodeByteUsingUpperCaseSymbols(test.Value) actualMostSignificant, actualLeastSignificant := hexadecarunes.EncodeByteUsingUpperCaseSymbols(test.Value)
{ {
actual := actualMostSignificant actual := actualMostSignificant

View File

@ -1,18 +1,19 @@
package hexadeca package hexadeca
import ( import (
"sourcecode.social/reiver/go-hexadeca/enc/runes"
"sourcecode.social/reiver/go-hexadeca/symbols/rune" "sourcecode.social/reiver/go-hexadeca/symbols/rune"
) )
func EncodeInt64(value int64, symbolFunc func(byte)rune) (r15 rune, r14 rune, r13 rune, r12 rune, r11 rune, r10 rune, r9 rune, r8 rune, r7 rune, r6 rune, r5 rune, r4 rune, r3 rune, r2 rune, r1 rune, r0 rune) { func EncodeInt64(value int64, symbolFunc func(byte)rune) (r15 rune, r14 rune, r13 rune, r12 rune, r11 rune, r10 rune, r9 rune, r8 rune, r7 rune, r6 rune, r5 rune, r4 rune, r3 rune, r2 rune, r1 rune, r0 rune) {
r15, r14 = EncodeByte(byte(0x00000000000000ff & (value >> (8 * 7))), symbolFunc) r15, r14 = hexadecarunes.EncodeByte(byte(0x00000000000000ff & (value >> (8 * 7))), symbolFunc)
r13, r12 = EncodeByte(byte(0x00000000000000ff & (value >> (8 * 6))), symbolFunc) r13, r12 = hexadecarunes.EncodeByte(byte(0x00000000000000ff & (value >> (8 * 6))), symbolFunc)
r11, r10 = EncodeByte(byte(0x00000000000000ff & (value >> (8 * 5))), symbolFunc) r11, r10 = hexadecarunes.EncodeByte(byte(0x00000000000000ff & (value >> (8 * 5))), symbolFunc)
r9, r8 = EncodeByte(byte(0x00000000000000ff & (value >> (8 * 4))), symbolFunc) r9, r8 = hexadecarunes.EncodeByte(byte(0x00000000000000ff & (value >> (8 * 4))), symbolFunc)
r7, r6 = EncodeByte(byte(0x00000000000000ff & (value >> (8 * 3))), symbolFunc) r7, r6 = hexadecarunes.EncodeByte(byte(0x00000000000000ff & (value >> (8 * 3))), symbolFunc)
r5, r4 = EncodeByte(byte(0x00000000000000ff & (value >> (8 * 2))), symbolFunc) r5, r4 = hexadecarunes.EncodeByte(byte(0x00000000000000ff & (value >> (8 * 2))), symbolFunc)
r3, r2 = EncodeByte(byte(0x00000000000000ff & (value >> (8 ))), symbolFunc) r3, r2 = hexadecarunes.EncodeByte(byte(0x00000000000000ff & (value >> (8 ))), symbolFunc)
r1, r0 = EncodeByte(byte(0x00000000000000ff & value ), symbolFunc) r1, r0 = hexadecarunes.EncodeByte(byte(0x00000000000000ff & value ), symbolFunc)
return return
} }

View File

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

View File

@ -1,14 +1,15 @@
package hexadeca package hexadeca
import ( import (
"sourcecode.social/reiver/go-hexadeca/enc/runes"
"sourcecode.social/reiver/go-hexadeca/symbols/rune" "sourcecode.social/reiver/go-hexadeca/symbols/rune"
) )
func EncodeUint32(value uint32, symbolFunc func(byte)rune) (r7 rune, r6 rune, r5 rune, r4 rune, r3 rune, r2 rune, r1 rune, r0 rune) { func EncodeUint32(value uint32, symbolFunc func(byte)rune) (r7 rune, r6 rune, r5 rune, r4 rune, r3 rune, r2 rune, r1 rune, r0 rune) {
r7, r6 = EncodeByte(byte(0x000000ff & (value >> (8 * 3))), symbolFunc) r7, r6 = hexadecarunes.EncodeByte(byte(0x000000ff & (value >> (8 * 3))), symbolFunc)
r5, r4 = EncodeByte(byte(0x000000ff & (value >> (8 * 2))), symbolFunc) r5, r4 = hexadecarunes.EncodeByte(byte(0x000000ff & (value >> (8 * 2))), symbolFunc)
r3, r2 = EncodeByte(byte(0x000000ff & (value >> (8 ))), symbolFunc) r3, r2 = hexadecarunes.EncodeByte(byte(0x000000ff & (value >> (8 ))), symbolFunc)
r1, r0 = EncodeByte(byte(0x000000ff & value ), symbolFunc) r1, r0 = hexadecarunes.EncodeByte(byte(0x000000ff & value ), symbolFunc)
return return
} }

View File

@ -1,18 +1,19 @@
package hexadeca package hexadeca
import ( import (
"sourcecode.social/reiver/go-hexadeca/enc/runes"
"sourcecode.social/reiver/go-hexadeca/symbols/rune" "sourcecode.social/reiver/go-hexadeca/symbols/rune"
) )
func EncodeUint64(value uint64, symbolFunc func(byte)rune) (r15 rune, r14 rune, r13 rune, r12 rune, r11 rune, r10 rune, r9 rune, r8 rune, r7 rune, r6 rune, r5 rune, r4 rune, r3 rune, r2 rune, r1 rune, r0 rune) { func EncodeUint64(value uint64, symbolFunc func(byte)rune) (r15 rune, r14 rune, r13 rune, r12 rune, r11 rune, r10 rune, r9 rune, r8 rune, r7 rune, r6 rune, r5 rune, r4 rune, r3 rune, r2 rune, r1 rune, r0 rune) {
r15, r14 = EncodeByte(byte(0x00000000000000ff & (value >> (8 * 7))), symbolFunc) r15, r14 = hexadecarunes.EncodeByte(byte(0x00000000000000ff & (value >> (8 * 7))), symbolFunc)
r13, r12 = EncodeByte(byte(0x00000000000000ff & (value >> (8 * 6))), symbolFunc) r13, r12 = hexadecarunes.EncodeByte(byte(0x00000000000000ff & (value >> (8 * 6))), symbolFunc)
r11, r10 = EncodeByte(byte(0x00000000000000ff & (value >> (8 * 5))), symbolFunc) r11, r10 = hexadecarunes.EncodeByte(byte(0x00000000000000ff & (value >> (8 * 5))), symbolFunc)
r9, r8 = EncodeByte(byte(0x00000000000000ff & (value >> (8 * 4))), symbolFunc) r9, r8 = hexadecarunes.EncodeByte(byte(0x00000000000000ff & (value >> (8 * 4))), symbolFunc)
r7, r6 = EncodeByte(byte(0x00000000000000ff & (value >> (8 * 3))), symbolFunc) r7, r6 = hexadecarunes.EncodeByte(byte(0x00000000000000ff & (value >> (8 * 3))), symbolFunc)
r5, r4 = EncodeByte(byte(0x00000000000000ff & (value >> (8 * 2))), symbolFunc) r5, r4 = hexadecarunes.EncodeByte(byte(0x00000000000000ff & (value >> (8 * 2))), symbolFunc)
r3, r2 = EncodeByte(byte(0x00000000000000ff & (value >> (8 ))), symbolFunc) r3, r2 = hexadecarunes.EncodeByte(byte(0x00000000000000ff & (value >> (8 ))), symbolFunc)
r1, r0 = EncodeByte(byte(0x00000000000000ff & value ), symbolFunc) r1, r0 = hexadecarunes.EncodeByte(byte(0x00000000000000ff & value ), symbolFunc)
return return
} }