/tutorial/vision/basic_examples/basic_unicode.e

http://github.com/tybor/Liberty · Specman e · 62 lines · 32 code · 9 blank · 21 comment · 2 complexity · a1387e37a3e94236c741bade247e08e0 MD5 · raw file

  1. class BASIC_UNICODE
  2. -- This file is writen in utf8 format. If you read it using utf8 mode
  3. -- and good unicode font, you'll see euro symbol. If not, you may see
  4. -- three characters instead.
  5. --
  6. -- If you use linux, try "cat basic_unicode.e". If euro symbol is not
  7. -- displayed then try: LC_CTYPE=en_GB.UTF-8 xterm -fn '-Misc-Fixed-Medium-R-SemiCondensed--13-120-75-75-C-60-ISO10646-1'&
  8. -- If you didn't have this font, look for some font matching '-*-*-*-*-*-*-*-*-*-*-m-*-iso10646-1' or '-*-*-*-*-*-*-*-*-*-*-c-*-iso10646-1'. Use xfontsel
  9. -- or xlsfonts -fn '-*-*-*-*-*-*-*-*-*-*-m(or c)-*-iso10646-1'. If you find
  10. -- none then you need to install unicode fonts (iso10646).
  11. --
  12. -- If you are using windows, look for an unicode capable editor
  13. -- (Microsoft Word is known to be able to read UTF-8 encoded files)
  14. -- Many unicode editors are available on the web.
  15. --
  16. -- More information is available at:
  17. -- http://www.unicode.org/
  18. -- http://www.unicode.org/charts/
  19. -- http://www.unicode.org/onlinedat/products.html
  20. inherit GRAPHIC
  21. create
  22. make
  23. feature {}
  24. toplevel_window: TOPLEVEL_WINDOW
  25. make is
  26. local
  27. label_1, label_2, label_3, label_4: LABEL
  28. s: UNICODE_STRING
  29. do
  30. create s.make(0)
  31. -- utf8 sequence decoding (when read from file for example)
  32. if s.utf8_decode_from("Currency sign for the European monetary: â‚?") then
  33. create toplevel_window.default_create
  34. toplevel_window.set_title("Unicode demo")
  35. toplevel_window.set_background_color(white_color)
  36. toplevel_window.map
  37. create label_1.make(s)
  38. toplevel_window.child_attach(label_1)
  39. -- unicode manifest string (in utf8 format)
  40. create label_2.make(U"Latin capital letter A, combining ring above: A%/204/%/138/")
  41. toplevel_window.child_attach(label_2)
  42. create label_3.make(U"Angstrom sign: â„?")
  43. toplevel_window.child_attach(label_3)
  44. -- unicode manifest string with unicode character number (hexa)
  45. create label_4.make(U"Surface integral symbol: %/Ux222F/")
  46. toplevel_window.child_attach(label_4)
  47. toplevel_window.when_close_requested(agent vision.loop_stack.break)
  48. vision.start
  49. else
  50. io.put_string("Error%N")
  51. end
  52. end
  53. end