utf8.htm 933 B

1234567891011121314151617181920212223242526272829
  1. <h1>UTF-8</h1>
  2. <h2>Erlang</h2>
  3. The main thing you should know about Erlang unicode is that
  4. <code>
  5. 1> unicode:characters_to_binary("UniText") == <<"UniText"/utf8>>.
  6. </code>
  7. I.e. in N2O DSL you should use:
  8. <code>
  9. 2> io:format("~tp",[ #button{body= <<"Unicode Name"/utf8>>} ]).
  10. </code>
  11. <h2>JavaScript</h2>
  12. Whenever you want to send to server the value from DOM element you should use utf8_toByteArray.
  13. <code>
  14. > utf_toByteArray(document.getElementById('phone').value);
  15. </code>
  16. <p>However we created shortcut for that purposes which knows about radio, fieldset and other types of DOM nodes. So you should use just:</p>
  17. <code>
  18. > querySource('phone');
  19. </code>
  20. <p>querySource JavaScript function ships in nitrogen.js which is part of N2O JavaScript library.
  21. Whenever you get unicode data from server you should prepare it before place in DOM with utf8_decode:</p>
  22. <code>
  23. > console.log(utf8_decode(receivedMessage));
  24. </code>