anchor.diff:  valid_utf8_bytes(B) when is_binary(B) ->
       binary_skip_bytes(B, invalid_utf8_indexes(B)).
   
  -%% Interal API
  -
  -%% @spec binary_skip_bytes(B::binary(), L::[integer()]) -> binary()
  +%% Internal API
  +
  +-spec binary_skip_bytes(binary(), [non_neg_integer()]) -> binary().
   %% @doc Return B, but skipping the 0-based indexes in L.
   binary_skip_bytes(B, []) ->
       B;
  
positive.code: %%      invalid bytes.
  
  -module(mochiutf8).
  -export([valid_utf8_bytes/1, codepoint_to_bytes/1]).
  
  %% External API
  
  %% @spec codepoint_to_binary(integer()) -> binary()
  %% @doc Convert a unicode codepoint to UTF-8 bytes.
  codepoint_to_bytes(C) when (C >= 16#00 andalso C =< 16#7f) ->
      %% U+0000 - U+007F - 7 bits
  
negative.code:        codepoint_to_bytes(16#10ffff)),
      ok.
  
  bytes_foldl_test() ->
      ?assertEqual(
         <<"abc">>,
         bytes_foldl(fun (B, Acc) -> <<Acc/binary, B/binary>> end, <<>>, <<"abc">>)),
      ?assertEqual(
         <<"abc", 226, 152, 131, 228, 184, 173, 194, 133, 244,143,191,191>>,
         bytes_foldl(fun (B, Acc) -> <<Acc/binary, B/binary>> end, <<>>,
                     <<"abc", 226, 152, 131, 228, 184, 173, 194, 133, 244,143,191,191>>)),
      ok.
  
  bytes_to_codepoints_test() ->
      ?assertEqual(
         "abc" ++ [16#2603, 16#4e2d, 16#85, 16#10ffff],
         bytes_to_codepoints(<<"abc", 226, 152, 131, 228, 184, 173, 194, 133, 244,143,191,191>>)),
      ok.
  
  codepoint_foldl_test() ->
      ?assertEqual(
         "cba",
         codepoint_foldl(fun (C, Acc) -> [C | Acc] end, [], <<"abc">>)),
      ?assertEqual(
         [16#10ffff, 16#85, 16#4e2d, 16#2603 | "cba"],
         codepoint_foldl(fun (C, Acc) -> [C | Acc] end, [],
                         <<"abc", 226, 152, 131, 228, 184, 173, 194, 133, 244,143,191,191>>)),
      ok.
  
  len_test() ->
      ?assertEqual(
         29,
         len(<<"unicode snowman for you: ", 226, 152, 131, 228, 184, 173, 194, 133, 244, 143, 191, 191>>)),
      ok.
  
  codepoints_to_bytes_test() ->
      ?assertEqual(
         iolist_to_binary(lists:map(fun codepoint_to_bytes/1, lists:seq(1, 1000))),
         codepoints_to_bytes(lists:seq(1, 1000))),
      ok.
  
  valid_utf8_bytes_test() ->
      ?assertEqual(
         <<"invalid U+11ffff: ">>,
  