utf8.tex 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. \section{UTF-8}
  2. \subsection{Erlang}
  3. The main thing you should know about Erlang unicode is that
  4. \vspace{1\baselineskip}
  5. \begin{lstlisting}
  6. unicode:characters_to_binary("Uni") == <<"Uni"/utf8>>.
  7. \end{lstlisting}
  8. \vspace{1\baselineskip}
  9. I.e. in N2O DSL you should use:
  10. \vspace{1\baselineskip}
  11. \begin{lstlisting}
  12. #button{body= <<"Unicode Name"/utf8>>}
  13. \end{lstlisting}
  14. \vspace{1\baselineskip}
  15. \subsection{JavaScript}
  16. Whenever you want to send to server the value from DOM element
  17. you should use utf8\_toByteArray.
  18. \vspace{1\baselineskip}
  19. \begin{lstlisting}
  20. > utf8_toByteArray(document.getElementById('phone').value);
  21. \end{lstlisting}
  22. \vspace{1\baselineskip}
  23. However we created shortcut for that purposes which knows
  24. about radio, fieldset and other types of DOM nodes. So you should use just:
  25. \vspace{1\baselineskip}
  26. \begin{lstlisting}
  27. > querySource('phone');
  28. \end{lstlisting}
  29. \vspace{1\baselineskip}
  30. querySource JavaScript function ships in nitrogen.js which is part
  31. of N2O JavaScript library.
  32. \paragraph{}
  33. Whenever you get unicode data from server you should prepare it before place
  34. in DOM with utf8\_dec:
  35. \vspace{1\baselineskip}
  36. \begin{lstlisting}
  37. > console.log(utf8_dec(receivedMessage));
  38. \end{lstlisting}
  39. \vspace{1\baselineskip}