[erlang-questions] Erlang 3000?
Wed Nov 19 11:27:53 CET 2008
On 19 Nov 2008, at 09:33AM, Johnny Billquist wrote:
> Richard O'Keefe wrote:
>> On 17 Nov 2008, at 1:44 pm, Håkan Stenholm wrote:
>>> Conditionals that have more than 2 branches where none of them
>>> branch on
>>> patterns - e.g. something like the to_upper code below:
>>> to_upper_char(C) when is_integer(C) ->
>>> $a =< C, C =< $z -> C - 32;
>>> 16#E0 =< C, C =< 16#F6 -> C - 32;
>>> 16#F8 =< C, C =< 16#FE -> C - 32;
>>> true -> C
>> If this is supposed to convert ISO Latin 1 characters
>> to upper case, it's wrong. (In at least two different
>> ways, both of which are left as an exercise for the
>> reader.) Code for such purposes simply shouldn't be
>> written by hand these days, but should be generated by
>> some sort of script from the (relevant portion of the)
>> Unicode data base. As such, whether it's written using
>> 'case', 'if', or embedded Intercal should be of no interest.
> ??? That's a perfectly correct translation from lowercase to uppercase
> for Latin-1.
> Unicode is something else.
> Or is there just some bug in the code as such that I fail to see?
"straße" - German for "street" - can be encoded in ISO Latin 1, but
both your code and the one in the standard string module will fail to
convert it to upper-case properly.
More information about the erlang-questions