Convert JSON WideString to TJSONStringType lazarus / 21-General ---------------------------------------------------------------------- PizzaProgram · 2022-05-12 19:39 I need to sign a JSON string with JOSE JWS (RSA) algorithm. This will be a DLL, so to interchange data (with Delphi7) the only safe way is to call the functions with WideString variables. This way: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i const  c_json : WideString =  '{'#13#10+    '"someData": {'#13#10+ ...'"name": "Tétel 1",'#13#10+'}'; ... function TMyClaims.GetAsString: TJSONStringType;var w : WideString;begin    w := c_json ; // normally it's WideString variable, this is only for testing    Result := UTF8Encode(w);    //ShowMessage( Result ); end; Result gives back strange chars: "Tétel.." becomes "Tétel.." I need this, because GetAsString is called by : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TJWTSigner.GetSignInputString(aJWT: TJWT): UTF8String;begin  Result:=aJWT.JOSE.AsEncodedString+'.'+aJWT.Claims.AsEncodedStringend;  in the fpjwt.pp unit Line: 379. Here is a full example I've changed to fit for "pure JSON", not as TClaim payload:  https://gitlab.com/freepascal.org/fpc/source/- /blob/main/packages/fcl-web/examples/jwt/signrs256.lpr ---------------------------------------------------------------------- balazsszekely · 2022-05-13 04:50 Hungarian is ISO_8859_1, please try this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses LazUTF8, LConvEncoding;   function GetAsString: TJSONStringType;var  w : WideString;  UTF8: UTF8String;begin    w := c_json ; // normally it's WideString variable, this is only for testing    UTF8 := UTF16ToUTF8(w);    Result := UTF8ToISO_8859_1(UTF8);end; ---------------------------------------------------------------------- PascalDragon · 2022-05-13 08:25 Quote from: PizzaProgram on May 12, 2022, 09:39:55 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i const  c_json : WideString =  '{'#13#10+    '"someData": {'#13#10+ ...'"name": "Tétel 1",'#13#10+'}'; ... function TMyClaims.GetAsString: TJSONStringType;var w : WideString;begin    w := c_json ; // normally it's WideString variable, this is only for testing    Result := UTF8Encode(w);    //ShowMessage( Result ); end; Result gives back strange chars: "Tétel.." becomes "Tétel.." Would you please try Result := TJSONStringType(w) instead of using UTF8Encode? (The compiler will do the conversion automatically) How do you check the value of the result? Using the commented ShowMessage?