From f1c7f7809a1291b601ea87608f7bbfb44c88e49a Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Sat, 28 Oct 2023 12:02:30 -0700 Subject: [PATCH] initial commits --- README.md | 1 + bytes/encodeint16.go | 20 ++++++++++++++++++++ encodeint16.go | 18 ++++++++++++++++++ runes/encodeint16.go | 24 ++++++++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 bytes/encodeint16.go create mode 100644 encodeint16.go create mode 100644 runes/encodeint16.go diff --git a/README.md b/README.md index 8cb36a2..22fc251 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ Package **hexadeca** has functions for hexadecimal encoding and decoding for the * `uint16`, * `uint32` * `uint64` +* `int16` * `int32` * `int64` diff --git a/bytes/encodeint16.go b/bytes/encodeint16.go new file mode 100644 index 0000000..6249a92 --- /dev/null +++ b/bytes/encodeint16.go @@ -0,0 +1,20 @@ +package hexadecabytes + +import ( + "sourcecode.social/reiver/go-hexadeca/symbols/byte" +) + +func EncodeInt16(value int16, 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 EncodeInt16UsingLowerCaseSymbols(value int16) (r3 byte, r2 byte, r1 byte, r0 byte) { + return EncodeInt16(value, bytesymbols.LowerCase) +} + +func EncodeInt16UsingUpperCaseSymbols(value int16) (r3 byte, r2 byte, r1 byte, r0 byte) { + return EncodeInt16(value, bytesymbols.UpperCase) +} diff --git a/encodeint16.go b/encodeint16.go new file mode 100644 index 0000000..dacc28c --- /dev/null +++ b/encodeint16.go @@ -0,0 +1,18 @@ +package hexadeca + +import ( + "sourcecode.social/reiver/go-hexadeca/bytes" + "sourcecode.social/reiver/go-hexadeca/runes" +) + +func EncodeInt16UsingLowerCaseSymbols(value int16) (r3 byte, r2 byte, r1 byte, r0 byte) { + return hexadecabytes.EncodeInt16UsingLowerCaseSymbols(value) +} + +func EncodeInt16UsingPersianSymbols(value int16) (r3 rune, r2 rune, r1 rune, r0 rune) { + return hexadecarunes.EncodeInt16UsingPersianSymbols(value) +} + +func EncodeInt16UsingUpperCaseSymbols(value int16) (r3 byte, r2 byte, r1 byte, r0 byte) { + return hexadecabytes.EncodeInt16UsingUpperCaseSymbols(value) +} diff --git a/runes/encodeint16.go b/runes/encodeint16.go new file mode 100644 index 0000000..e716f4c --- /dev/null +++ b/runes/encodeint16.go @@ -0,0 +1,24 @@ +package hexadecarunes + +import ( + "sourcecode.social/reiver/go-hexadeca/symbols/rune" +) + +func EncodeInt16(value int16, symbolFunc func(byte)rune) (r3 rune, r2 rune, r1 rune, r0 rune) { + r3, r2 = EncodeByte(byte(0x00ff & (value >> (8 ))), symbolFunc) + r1, r0 = EncodeByte(byte(0x00ff & value ), symbolFunc) + + return +} + +func EncodeInt16UsingLowerCaseSymbols(value int16) (r3 rune, r2 rune, r1 rune, r0 rune) { + return EncodeInt16(value, runesymbols.LowerCase) +} + +func EncodeInt16UsingPersianSymbols(value int16) (r3 rune, r2 rune, r1 rune, r0 rune) { + return EncodeInt16(value, runesymbols.Persian) +} + +func EncodeInt16UsingUpperCaseSymbols(value int16) (r3 rune, r2 rune, r1 rune, r0 rune) { + return EncodeInt16(value, runesymbols.UpperCase) +}