[erlang-questions] Why are the two strings outputed in diffrent format?

devdoer bird devdoer2@REDACTED
Tue Sep 30 07:53:46 CEST 2008


Got it!

2008/9/30 Edwin Fine <erlang-questions_efine@REDACTED>

> I would guess probably because Erlang uses ISO/IEC 8859-1, in which 155 is
> not defined while the others all are (
> http://en.wikipedia.org/wiki/ISO_8859-1#Codepage_layout). Characters
> between 137 and 159 are excluded, while all the rest are printable included.
>
> 2008/9/30 devdoer bird <devdoer2@REDACTED>
>
>  OK.  Then I 'll take a look at it io_lib.erl. But one more question: why
>> the value 155 is unprintable while 228 is , considering they are both
>> greater than 128.
>>
>> Thanks.
>>
>> 2008/9/30 Edwin Fine <erlang-questions_efine@REDACTED>
>>
>>  It is because one of the integers in y (155) is not considered printable
>>> by Erlang.
>>>
>>> 17> X = "\326\320\271\372".
>>> "\326\320\271\372"
>>> 18> Y = [228,184,173,229,155,189].
>>> [228,184,173,229,155,189]
>>> 19> [{I, io_lib:printable_list([I])} || I <- X].
>>> [{214,true},{208,true},{185,true},{250,true}]
>>> 20> [{I, io_lib:printable_list([I])} || I <- Y].
>>> [{228,true},
>>>  {184,true},
>>>  {173,true},
>>>  {229,true},
>>>  {155,false},
>>>  {189,true}]
>>> 21>
>>>
>>> 2008/9/29 devdoer bird <devdoer2@REDACTED>
>>>
>>>>   HI:
>>>>
>>>> I have a utf8  encoded file y.erl:  the source is :
>>>> -module(y).
>>>> -compile(export_all).
>>>> output2()->
>>>>     "中文".
>>>>
>>>>
>>>> And a latin encoded file x.erl, the source is:
>>>>  -module(x).
>>>> -compile(export_all).
>>>> output2()->
>>>>     "中文".
>>>>
>>>> When execute them in erlang shell,
>>>> 1> x:output2().
>>>> "\326\320\271\372"
>>>> 2>y:output2().
>>>> [228,184,173,229,155,189]
>>>>
>>>> I don't know why they  are outupted in diffrent format, one is
>>>> string-format, the other is list-format. Why aren't they birth outputed in
>>>> string-format or both in list-format?
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> erlang-questions mailing list
>>>> erlang-questions@REDACTED
>>>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080930/f0a53c6a/attachment.htm>


More information about the erlang-questions mailing list