[erlang-questions] list manipulation

Martin Dimitrov <>
Wed Sep 5 10:27:01 CEST 2012


Thanks for the clue. I see some vals > 255. That must be the problem.

Martin

On 9/5/2012 10:07 AM, Erik Søe Sørensen wrote:
> Does the list contain non-bytes - ie, values > 255 (or <0)?
> Is the list pure (ie, ends with [])?
>
> What you're probably looking for is the encoding functions in the 'unicode'
> module.
>
> /Erik
> Den 05/09/2012 08.57 skrev "Martin Dimitrov" <>:
>
>> Hello,
>>
>> I have a list, representing a UTF8 string, containing more than 225000
>> elements. I have load it in var L:
>>
>> 8> lists:flatten(L).
>> [60,63,120,109,108,32,118,101,114,115,105,111,110,61,34,49,
>>  46,48,34,32,101,110,99,111,100,105,110,103,61|...]
>> 9> list_to_binary(L).
>> ** exception error: bad argument
>>      in function  list_to_binary/1
>>         called as
>> list_to_binary([60,63,120,109,108,32,118,101,114,115,105,111,
>>
>> 110,61,34,49,46,48,34,32,101,110,99,111,100,
>>                                   105,110,103|...])
>> 10> file:write_file("data.txt", L).
>> {error,badarg}
>>
>> Why list_to_binary/1 and write_file/2 fail?
>>
>> Best regards,
>>
>> Martin
>>
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
>>





More information about the erlang-questions mailing list