From e6846604bb85b98fe6b84562c877346e1c9788b2 Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Sat, 28 Oct 2023 11:57:50 -0700 Subject: [PATCH] initial commits --- bytes/encodeint32.go | 22 ++++++++++++++++++++++ encodeint32.go | 18 ++++++++++++++++++ runes/encodeint32.go | 26 ++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 bytes/encodeint32.go create mode 100644 encodeint32.go create mode 100644 runes/encodeint32.go diff --git a/bytes/encodeint32.go b/bytes/encodeint32.go new file mode 100644 index 0000000..44e62b5 --- /dev/null +++ b/bytes/encodeint32.go @@ -0,0 +1,22 @@ +package hexadecabytes + +import ( + "sourcecode.social/reiver/go-hexadeca/symbols/byte" +) + +func EncodeInt32(value int32, symbolFunc func(byte)byte) (r7 byte, r6 byte, r5 byte, r4 byte, r3 byte, r2 byte, r1 byte, r0 byte) { + r7, r6 = EncodeByte(byte(0x000000ff & (value >> (8 * 3))), symbolFunc) + r5, r4 = EncodeByte(byte(0x000000ff & (value >> (8 * 2))), symbolFunc) + r3, r2 = EncodeByte(byte(0x000000ff & (value >> (8 ))), symbolFunc) + r1, r0 = EncodeByte(byte(0x000000ff & value ), symbolFunc) + + return +} + +func EncodeInt32UsingLowerCaseSymbols(value int32) (r7 byte, r6 byte, r5 byte, r4 byte, r3 byte, r2 byte, r1 byte, r0 byte) { + return EncodeInt32(value, bytesymbols.LowerCase) +} + +func EncodeInt32UsingUpperCaseSymbols(value int32) (r7 byte, r6 byte, r5 byte, r4 byte, r3 byte, r2 byte, r1 byte, r0 byte) { + return EncodeInt32(value, bytesymbols.UpperCase) +} diff --git a/encodeint32.go b/encodeint32.go new file mode 100644 index 0000000..de1bc30 --- /dev/null +++ b/encodeint32.go @@ -0,0 +1,18 @@ +package hexadeca + +import ( + "sourcecode.social/reiver/go-hexadeca/bytes" + "sourcecode.social/reiver/go-hexadeca/runes" +) + +func EncodeInt32UsingLowerCaseSymbols(value int32) (r7 byte, r6 byte, r5 byte, r4 byte, r3 byte, r2 byte, r1 byte, r0 byte) { + return hexadecabytes.EncodeInt32UsingLowerCaseSymbols(value) +} + +func EncodeInt32UsingPersianSymbols(value int32) (r7 rune, r6 rune, r5 rune, r4 rune, r3 rune, r2 rune, r1 rune, r0 rune) { + return hexadecarunes.EncodeInt32UsingPersianSymbols(value) +} + +func EncodeInt32UsingUpperCaseSymbols(value int32) (r7 byte, r6 byte, r5 byte, r4 byte, r3 byte, r2 byte, r1 byte, r0 byte) { + return hexadecabytes.EncodeInt32UsingUpperCaseSymbols(value) +} diff --git a/runes/encodeint32.go b/runes/encodeint32.go new file mode 100644 index 0000000..4c633bd --- /dev/null +++ b/runes/encodeint32.go @@ -0,0 +1,26 @@ +package hexadecarunes + +import ( + "sourcecode.social/reiver/go-hexadeca/symbols/rune" +) + +func EncodeInt32(value int32, 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) + r5, r4 = EncodeByte(byte(0x000000ff & (value >> (8 * 2))), symbolFunc) + r3, r2 = EncodeByte(byte(0x000000ff & (value >> (8 ))), symbolFunc) + r1, r0 = EncodeByte(byte(0x000000ff & value ), symbolFunc) + + return +} + +func EncodeInt32UsingLowerCaseSymbols(value int32) (r7 rune, r6 rune, r5 rune, r4 rune, r3 rune, r2 rune, r1 rune, r0 rune) { + return EncodeInt32(value, runesymbols.LowerCase) +} + +func EncodeInt32UsingPersianSymbols(value int32) (r7 rune, r6 rune, r5 rune, r4 rune, r3 rune, r2 rune, r1 rune, r0 rune) { + return EncodeInt32(value, runesymbols.Persian) +} + +func EncodeInt32UsingUpperCaseSymbols(value int32) (r7 rune, r6 rune, r5 rune, r4 rune, r3 rune, r2 rune, r1 rune, r0 rune) { + return EncodeInt32(value, runesymbols.UpperCase) +}