> Erlang中文手册 > encoding_to_bom/1 从编码里生成一个二进制的 UTF 字节顺序标记

unicode:encoding_to_bom/1

从编码里生成一个二进制的 UTF 字节顺序标记

用法:

encoding_to_bom(InEncoding) -> Bin

内部实现:

-spec encoding_to_bom(InEncoding) -> Bin when
      Bin :: binary(),
      InEncoding :: encoding().

encoding_to_bom(unicode) ->
    >;
encoding_to_bom(utf8) ->
    >;
encoding_to_bom(utf16) ->
    >;
encoding_to_bom({utf16,big}) ->
    >;
encoding_to_bom({utf16,little}) ->
    >;
encoding_to_bom(utf32) ->
    >;
encoding_to_bom({utf32,big}) ->
    >;
encoding_to_bom({utf32,little}) ->
    >;
encoding_to_bom(latin1) ->
    >.

从输入编码 InEncoding 里生成一个二进制的 UTF 字节顺序标记

unicode:encoding_to_bom(unicode).
unicode:encoding_to_bom(utf8).
unicode:encoding_to_bom(utf16).
unicode:encoding_to_bom({utf16,big}).
unicode:encoding_to_bom({utf16,little}).
unicode:encoding_to_bom(utf32).
unicode:encoding_to_bom({utf32,big}).
unicode:encoding_to_bom({utf32,little}).
unicode:encoding_to_bom(latin1).