<?xml version="1.0"?>
<paste-with-annotations>
  <paste>
    <number>
      <integer>60982</integer>
    </number>
    <user>
      <string>b101</string>
    </user>
    <title>
      <string>[erlang] unicode string to javascript \uXXXX</string>
    </title>
    <contents>
      <string>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Based on query discussed on #erlang,inputs from smoove,stonecypher.
%% 
%% To be able to convert unicode to a form that can be evaluated 
%% in javascript since it of unicode escape format
%% eg: the copyright symbol will be escaped into \u00a9
%%
%%
%%%%
%% Resources for unicode / binary/ string conversion in erlang
%%%%
%% http://pianosa.googlecode.com/svn/trunk/erlang/utf8.erl
%% http://12monkeys.co.uk/starling/
%% http://www.lshift.net/~tonyg/erlang-rfc4627/
%% http://www.erlang.org/doc/man/io.html
%% http://developer.mozilla.org/en/docs/International_characters_in_XUL_JavaScript
%%%%
%% -b101
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%functions added to utf8.erl  which already exports [encode/1, decode/1]
-export([list_to_uXXXX/1,binary_to_uXXXX/1]

%list into unicode escaped javascript form 
list_to_uXXXX(Str)-&gt;
 lists:flatten[io_lib:format(&quot;\\u~4.16.0B&quot;,[X]) || X &lt;- Str].

%% first converting to list,then to uXXXX form
binary_to_uXXXX(Bin)-&gt;
 list_to_uXXXX(decode(Bin)).

</string>
    </contents>
    <universal-time>
      <integer>3420198755</integer>
    </universal-time>
    <channel>
      <string>None</string>
    </channel>
    <colorization-mode>
      <string>Erlang</string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <keyword>TRUE</keyword>
    </is-unicode>
  </paste>
  <annotation>
    <number>
      <integer>1</integer>
    </number>
    <user>
      <string>b101</string>
    </user>
    <title>
      <string>update</string>
    </title>
    <contents>
      <string>UPDATES
%%%%%%%%

found that suppose you have unicode rendered within javascript, it can very much be used as a literal, and will infact match identically to the same unicode word found elsewhere within the HTML DOM.

also, even though the to_XXXX did no throw any errors, it wasnt showing the correct possible because N number of binaries/list does not necessarily mean N symbols (a symbol can be formed by more than a series of binary elements)

an excellent utility that helped me easily evalute the decimal/binary/hexa values of unicode symbols (just paste them into a text area to see results) was located at http://software.ellerton.net/txt2bin/

~b101
</string>
    </contents>
    <universal-time>
      <integer>3420205887</integer>
    </universal-time>
    <channel>
      <string>None</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <keyword>TRUE</keyword>
    </is-unicode>
  </annotation>
</paste-with-annotations>