anchor.diff: +%% -*- coding: utf-8 -*-
   -module(eaws_util).
   -export([   calc_sign/2,
               formatted_params/1,
  
positive.code:   SmtpH = smtp_headers(From, To, Subj, Date, Bndry),
    SubtTxt = subtype_txt(Txt, Bndry),
    F = fun({FileName, Content}, Acc) ->
              <<Acc/binary, (subtype_attach(to_binary(filename:basename(to_list(FileName))), Content, Bndry))/binary>>;
            (FileName, Acc) ->
              case file:read_file(to_list(FileName)) of
                {ok, Content} ->
                  <<Acc/binary, (subtype_attach(to_binary(filename:basename(to_list(FileName))), Content, Bndry))/binary>>;
                _Error -> Acc
              end
    end,
  
negative.code: 
  to_list(X) when is_list(X) -> X;
  to_list(X) when is_binary(X) -> binary_to_list(X).
  
  %% Unicode lib
  %% author detect unicode S.Kostyshkin
  is_unicode_string(BinaryString) when is_binary(BinaryString) ->
    Latin1List = binary_to_list(BinaryString),
    UTF8List = unicode:characters_to_list(BinaryString),
    Latin1List =/= UTF8List;
  is_unicode_string(String) when is_list(String) ->
    is_unicode_string(list_to_binary(String)).
  
  to_utf8(Txt) ->
    case is_unicode_string(Txt) of
      true ->
        unicode:characters_to_binary(unicode:characters_to_list(Txt));
      false -> Txt
    end.
  
  