go-hexadeca/runes/encodebyte.go

27 lines
814 B
Go
Raw Normal View History

2023-10-27 20:25:50 +00:00
package hexadecarunes
2023-10-27 00:21:23 +00:00
2023-10-27 18:58:14 +00:00
import (
"sourcecode.social/reiver/go-hexadeca/symbols/rune"
)
2023-10-27 00:21:23 +00:00
// EncodeByte encodes the value of a byte into hexadecimal.
func EncodeByte(value byte, symbolFunc func(byte)rune) (mostSignificant rune, leastSignificant rune) {
mostSignificant = symbolFunc( (0xf0 & value) >> 4 )
leastSignificant = symbolFunc( (0x0f & value) )
return
}
func EncodeByteUsingLowerCaseSymbols(value byte) (mostSignificant rune, leastSignificant rune) {
2023-10-27 18:58:14 +00:00
return EncodeByte(value, runesymbols.LowerCase)
2023-10-27 00:21:23 +00:00
}
func EncodeByteUsingPersianSymbols(value byte) (mostSignificant rune, leastSignificant rune) {
2023-10-27 18:58:14 +00:00
return EncodeByte(value, runesymbols.Persian)
2023-10-27 00:21:23 +00:00
}
func EncodeByteUsingUpperCaseSymbols(value byte) (mostSignificant rune, leastSignificant rune) {
2023-10-27 18:58:14 +00:00
return EncodeByte(value, runesymbols.UpperCase)
2023-10-27 00:21:23 +00:00
}