Skip to content

Non encoding above 127 ASCII if is UTF-8 #20

@Dzyszla

Description

@Dzyszla

Proposal for modify middleware to no encoding above 127 ASCII char code:

var
procedure Middleware(Req: THorseRequest; Res: THorseResponse; Next: {$IF DEFINED(FPC)}TNextProc{$ELSE}TProc{$ENDIF});
  ...
  ops: TJSONValue.TJsonOutputOptions;
begin
 ...
	  if SameText(Charset, 'utf-8') then
		ops := [TJSONValue.TJSONOutputOption.EncodeBelow32]
	  else
		ops := [TJSONValue.TJSONOutputOption.EncodeBelow32, TJSONValue.TJSONOutputOption.EncodeAbove127];

	  Res.RawWebResponse.Content := TJSONValue(Res.Content).ToJSON(ops);
...
end;

Or maybe some other configuration for this? If I want to response with utf-8 charset, why can't use utf-8 charset as is in json?

(this feature can support only by D12 (or some lower, but above D10).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions