initial commits

master
Charles Iliya Krempeaux 2023-10-27 11:15:26 -07:00
parent 1881ff4c1f
commit b61dcb7310
1 changed files with 48 additions and 0 deletions

View File

@ -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.