Unquoting a string

The following example shows two implementations of some code that unquotes a string a classical implementation and an implementation with a state pattern.

A quoted string starts and ends with a double-quote character ("). Any occurrence of a double-quote character in a string is represented by two occurrences of that character. The following table shows a few examples of strings that have been converted into a quoted form:

String Quoted string
Delphi "Delphi"
Delphi and patterns "Delphi and patterns"
Delphi "ROCKS!" "Delphi ""Rocks!"""

An unquoting algorithm takes the quoted string (for example, "quoted ""quoted""") and converts it into its original form (quoted "quoted"). Its behavior can be represented with ...

Get Hands-On Design Patterns with Delphi now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.