编辑代码

-module(ip_mgr).
-export([main/1, is_unicode_cn/1]).

% 辅助函数,用于检查字符是否可能是中文
is_unicode_cn(C) ->
    case C of
        C when C >= 16#4e00 andalso C =< 16#9fa5 ->
            true;
        _ ->
            false
    end.

main(_) ->
    AsciiList = [50,52,52,36,36,97,108,105,121,117,110,36,36,48,36,36,113,117,105,99,107,103,97,109,101,36,36,51,48,49,36,36,49,20803,31036,21253,36,36,36],
    % 将ASCII码列表转换为二进制数据
    Binary = iolist_to_binary(AsciiList),

    % 尝试将二进制数据转换为字符串
    try
        % 将二进制数据转换为Unicode字符列表
        Chars = unicode:characters_to_list(Binary),
        % 打印所有字符
        io:format("All characters: ~ts~n", [Chars]),
        
        % 过滤出可能的中文字符
        Chinese = [C || C <- Chars, is_unicode_cn(C)],
        % 打印中文字符
        io:format("Chinese characters: ~ts~n", [Chinese])
    catch
        error:_ ->
            io:format("Error converting binary to unicode list.")
    end.