function y = eml_string_transform(x,xform)
%MATLAB Code Generation Private Function

%   Applies function xform to each element of x.

%   Copyright 2011-2014 The MathWorks, Inc.
%#codegen

coder.internal.prefer_const(x,xform);
coder.internal.assertSupportedString(x);
y = coder.nullcopy(x);
hichar = coder.internal.charmax;
hcmask = coder.internal.indexInt(hichar);
table = coder.const(feval(xform,char(0:hichar)));
% We mask the elements of s(k) with hcmask so that the index will
% always be in range, even if the input is unsupported.
for k = 1:numel(x)
    y(k) = table(1 + eml_bitand( ...
        coder.internal.indexInt(x(k)), ...
        hcmask));
end
