PageRenderTime 23ms CodeModel.GetById 15ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/mod_base/filters/filter_capfirst.erl

https://code.google.com/p/zotonic/
Erlang | 30 lines | 8 code | 6 blank | 16 comment | 0 complexity | 36c002eadf5245b8c980eccf0685ebce MD5 | raw file
 1%% @author Marc Worrell <marc@worrell.nl>
 2%% @copyright 2010 Marc Worrell
 3%% @doc 'capfirst' filter, capitalize the first character
 4
 5%% Copyright 2010 Marc Worrell
 6%%
 7%% Licensed under the Apache License, Version 2.0 (the "License");
 8%% you may not use this file except in compliance with the License.
 9%% You may obtain a copy of the License at
10%% 
11%%     http://www.apache.org/licenses/LICENSE-2.0
12%% 
13%% Unless required by applicable law or agreed to in writing, software
14%% distributed under the License is distributed on an "AS IS" BASIS,
15%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16%% See the License for the specific language governing permissions and
17%% limitations under the License.
18
19-module(filter_capfirst).
20-export([capfirst/2]).
21
22
23capfirst(undefined, _Context) ->
24    undefined;
25capfirst([H|T], _Context) when H >= $a andalso H =< $z ->
26    [H + $A - $a | T];
27capfirst(<<Byte:8/integer, Binary/binary>>, _Context) when Byte >= $a andalso Byte =< $z ->
28    [<<(Byte + $A - $a)>>, Binary].
29
30