Thema: Delphi TJson.Format und Umlaute

Einzelnen Beitrag anzeigen

Schokohase
(Gast)

n/a Beiträge
 
#4

AW: TJson.Format und Umlaute

  Alt 2. Sep 2019, 09:42
Also wenn wir davon reden, was Delphi da mittels TJson veranstaltet, dann müssen wir auch über die JSON-Spezifikation sprechen, denn das war die Grundlage für die Funktionsweise von TJson .

Das Delphi einen "normalen" string als Ergebnis zurückliefert, ja das sollte klar sein. Allerdings sollten sich nach dem TJson.Format nur noch Zeichen befinden, die sich auch in der UTF8-Zeichentabelle befinden.

Und warum sollte da etwas escaped werden, wenn es nicht escaped werden muss (das Zeichen ist in der UTF8-Zeichentabelle enthalten).

Ansonsten, welche Zeichen sollen denn alle escaped werden? Alle? Einige? Nach welchen Kriterien?

Aber eventuell hilft dir auch noch die Beschreibung aus der RFC
Zitat:
Code:
2.5. Strings

   The representation of strings is similar to conventions used in the C
   family of programming languages. A string begins and ends with
   quotation marks. All Unicode characters may be placed within the
   quotation marks except for the characters that must be escaped:
   quotation mark, reverse solidus, and the control characters (U+0000
   through U+001F).

   Any character may be escaped. If the character is in the Basic
   Multilingual Plane (U+0000 through U+FFFF), then it may be
   represented as a six-character sequence: a reverse solidus, followed
   by the lowercase letter u, followed by four hexadecimal digits that
   encode the character's code point. The hexadecimal letters A though
   F can be upper or lowercase. So, for example, a string containing
   only a single reverse solidus character may be represented as
   "\u005C".

   Alternatively, there are two-character sequence escape
   representations of some popular characters. So, for example, a
   string containing only a single reverse solidus character may be
   represented more compactly as "\\".

   To escape an extended character that is not in the Basic Multilingual
   Plane, the character is represented as a twelve-character sequence,
   encoding the UTF-16 surrogate pair. So, for example, a string
   containing only the G clef character (U+1D11E) may be represented as
   "\uD834\uDD1E".
(Quelle: https://www.ietf.org/rfc/rfc4627.txt)
Daraus geht hervor, was escaped werden muss, und was escaped werden darf.

PS

Mich dünkt du hast ein anderes Problem und versuchst dieses nun dem JSON in die Schuhe zu schieben.

Geändert von Schokohase ( 2. Sep 2019 um 09:45 Uhr)
  Mit Zitat antworten Zitat