Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TemplatePro invalid capitalize result #809

Open
Pecaas opened this issue Feb 16, 2025 · 0 comments
Open

TemplatePro invalid capitalize result #809

Pecaas opened this issue Feb 16, 2025 · 0 comments

Comments

@Pecaas
Copy link

Pecaas commented Feb 16, 2025

There are some problems with capitalize function and national characters.

Call capitalize of "Křížek přemysl" results in "KřížEk PřEmysl"

In people_table.html in htmlx_templatepro is defined

 <td>{{:person.FirstName|capitalize}}</td>

Capitalize function is implemented in TemplatePro.pas. Instead of defining list of allowed chars it is better for me to define NOTALLOWEDCHARS. Then it works fine. But I do not know all use cases of that function, it can break something on the other place.

function CapitalizeString(const s: string; const CapitalizeFirst: Boolean): string;
const
 // ALLOWEDCHARS = ['a' .. 'z', '_'];
   NOTALLOWEDCHARS = [' '];
var
  index: Integer;
  bCapitalizeNext: Boolean;
begin
  bCapitalizeNext := CapitalizeFirst;
  Result := lowercase(s);
  if Result <> EmptyStr then
  begin
    for index := 1 to Length(Result) do
    begin
      if bCapitalizeNext then
      begin
        Result[index] := UpCase(Result[index]);
        bCapitalizeNext := False;
      end
//      else if not CharInSet(Result[index], ALLOWEDCHARS) then
      else if CharInSet(Result[index], NOTALLOWEDCHARS) then
      begin
        bCapitalizeNext := True;
      end;
    end; // for
  end; // if
end;

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant