[erlang-questions] Charset conversion / stylistic question.

Bengt Kleberg <>
Thu Apr 19 08:59:45 CEST 2007


On 2007-04-18 23:19, Tim Becker wrote:
...deleted
>   cp037_to_iso_8859_1 (129) -> 97; % a
>   cp037_to_iso_8859_1 (130) -> 98; % b
>   cp037_to_iso_8859_1 (131) -> 99; % c
>   ...
> 
> seems sort of inefficient, especially considering the size of the
> source to convert UCS :)

in the case of a simple mapping like the one above (cp037 - 32 = 
iso_8859_1) you can write:

cp037_to_iso_8859_1( Cp037 ) -> Cp037 - 32.

if the mapping only holds for the range specified in the example you can 
use:

cp037_to_iso_8859_1( Cp037 ) when
		(Cp037 >= 129) andalso (Cp037 =< 131) ->
	Cp037 - 32.


bengt
-- 
Those were the days...
    EPO guidelines 1978: "If the contribution to the known art resides
    solely in a computer program then the subject matter is not
    patentable in whatever manner it may be presented in the claims."



More information about the erlang-questions mailing list