From b61dcb731079b79f0fc63cd2fc5aeafa31e7d5ea Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Fri, 27 Oct 2023 11:15:26 -0700 Subject: [PATCH] initial commits --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/README.md b/README.md index c6088a3..3320a18 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,54 @@ Online documentation, which includes examples, can be found at: http://godoc.org [![GoDoc](https://godoc.org/sourcecode.social/reiver/go-hexadeca?status.svg)](https://godoc.org/sourcecode.social/reiver/go-hexadeca) +## Symbols + +Package **hexadeca** lets you pick the 16 symbols to hexadecimal encode to and hexadecimal decode from. +For example — + +Lower-Case: +`'0'`, `'1'`, `'2'`, `'3'`, `'4'`, `'5'`, `'6'`, `'7'`, `'8'`, `'9'`, `'a'`, `'b'`, `'c'`, `'d'`, `'e'`, `'f'`. + +Upper-Case: +`'0'`, `'1'`, `'2'`, `'3'`, `'4'`, `'5'`, `'6'`, `'7'`, `'8'`, `'9'`, `'A'`, `'B'`, `'C'`, `'D'`, `'E'`, `'F'`. + +Persian: +`'۰'` (zero), `'۱'` (one), `'۲'` (two), `'۳'` (three), `'۴'` (four), `'۵'` (five), `'۶'` (six), `'۷'` (seven), `'۸'` (eight) ,`'۹'` (nine), `'ا'` (alef), `'ب '` (be), `'پ '` (pe), `'ت '` (te), `'ث '` (s̱e), `'ج'` (jim). + +As well as defining you own using function: +```go +func CustomSymbol(value byte) rune { + var table [16]rune = [16]rune{ + '𝍠', // 0 + '𝍡', // 1 + '𝍢', // 2 + '𝍣', // 3 + '𝍤', // 4 + '𝍥', // 5 + '𝍦', // 6 + '𝍧', // 7 + '𝍨', // 8 + '𝍩', // 9 + '𝍪', // 10 + '𝍫', // 11 + '𝍬', // 12 + '𝍭', // 13 + '𝍮', // 14 + '𝍯', // 15 + } + + var index int = int(value) % len(table) + + var result rune = table[index] + + return result +} + +// ... + +r1, r0 := hexadeca.EncodeRune(value, CustomSymbol) +``` + ## Example A couple examples of encoding a `byte` to hexidecimal.