u2x11 911 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env bash
  2. #
  3. # Convert "U+..." commented entries in /usr/include/X11/keysymdef.h
  4. # into JavaScript for use by noVNC. Note this is likely to produce
  5. # a few duplicate properties with clashing values, that will need
  6. # resolving manually.
  7. #
  8. # Colin Dean <colin@xvpsource.org>
  9. #
  10. regex="^#define[ \t]+XK_[A-Za-z0-9_]+[ \t]+0x([0-9a-fA-F]+)[ \t]+\/\*[ \t]+U\+([0-9a-fA-F]+)[ \t]+[^*]+.[ \t]+\*\/[ \t]*$"
  11. echo "unicodeTable = {"
  12. while read line; do
  13. if echo "${line}" | egrep -qs "${regex}"; then
  14. x11=$(echo "${line}" | sed -r "s/${regex}/\1/")
  15. vnc=$(echo "${line}" | sed -r "s/${regex}/\2/")
  16. if echo "${vnc}" | egrep -qs "^00[2-9A-F][0-9A-F]$"; then
  17. : # skip ISO Latin-1 (U+0020 to U+00FF) as 1-to-1 mapping
  18. else
  19. # note 1-to-1 is possible (e.g. for Euro symbol, U+20AC)
  20. echo " 0x${vnc} : 0x${x11},"
  21. fi
  22. fi
  23. done < /usr/include/X11/keysymdef.h | uniq
  24. echo "};"