本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
458B

  1. package utils
  2. // RuneToInt converts a rune between '0' and '9' to an integer between 0 and 9
  3. // If the rune is outside of this range -1 is returned.
  4. func RuneToInt(r rune) int {
  5. if r >= '0' && r <= '9' {
  6. return int(r - '0')
  7. }
  8. return -1
  9. }
  10. // IntToRune converts a digit 0 - 9 to the rune '0' - '9'. If the given int is outside
  11. // of this range 'F' is returned!
  12. func IntToRune(i int) rune {
  13. if i >= 0 && i <= 9 {
  14. return rune(i + '0')
  15. }
  16. return 'F'
  17. }
上海开阖软件有限公司 沪ICP备12045867号-1