%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% 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)-> lists:flatten[io_lib:format("\\u~4.16.0B",[X]) || X <- Str]. %% first converting to list,then to uXXXX form binary_to_uXXXX(Bin)-> list_to_uXXXX(decode(Bin)).