Einzelnen Beitrag anzeigen

Der schöne Günther

Registriert seit: 6. Mär 2013
6.110 Beiträge
 
Delphi 10 Seattle Enterprise
 
#6

AW: Codierung/Decodierung von Umlauten

  Alt 28. Okt 2014, 09:06
Seit XE5(?) ist doch Json rundum dabei. So ware es spontan für einen String doch ok, oder?

Delphi-Quellcode:
uses
   System.SysUtils,
   System.Json; // Unter XE5 glaube ich Data.DBXJSON statt System.Json

procedure justEncodingThings();
const
   baseStrEnc: String = 'M\u00FCller';
   baseStrDec: String = 'Müller';
var
   decodedStr: String;
   jsonValue: TJSONValue;
begin
   jsonValue := TJSONObject.ParseJSONValue( baseStrEnc.QuotedString('"') );
   decodedStr := jsonValue.Value;

   Assert( decodedStr = baseStrDec );

   jsonValue.Free();
end;
  Mit Zitat antworten Zitat