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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.