@@ -38,12 +38,20 @@ internal extension String {
3838
3939 case . escapeScalars( _, let octothorpLevel? , _, true ) :
4040 let octothorps = String ( repeating: " # " , count: Int ( octothorpLevel) )
41- return ( octothorpLevel, octothorps + #"""# , #"""# + octothorps)
41+ //#if swift(>=5.4)
42+ // return (octothorpLevel, octothorps + #"""#, #"""# + octothorps)
43+ //#else
44+ return ( octothorpLevel, octothorps + " \" " , " \" " + octothorps)
45+ //#endif
4246
4347 case . escapeScalars( _, nil , _, let showQuotes) :
4448 /* We must determine the octothorp level. */
4549 var level = UInt ( 0 )
46- var ( sepOpen, sepClose) = ( #"""# , #"""# )
50+ //#if swift(>=5.4)
51+ // var (sepOpen, sepClose) = (#"""#, #"""#)
52+ //#else
53+ var ( sepOpen, sepClose) = ( " \" " , " \" " )
54+ //#endif
4755 while str. contains ( sepClose) {
4856 level += 1
4957 sepOpen = " # " + sepOpen
@@ -75,7 +83,11 @@ internal extension String {
7583 if curSpecial. 1 == octothorpLevel - 1 {
7684 /* We have now reached the number of octothorp needed to build an actual “special char” (closing quote, backslash, etc.); we must escape it. */
7785 specialCharState = nil
78- return #"\"# + octothorps + String( curSpecial. 0 ) + octothorps
86+ //#if swift(>=5.4)
87+ // return #"\"# + octothorps + String(curSpecial.0) + octothorps
88+ //#else
89+ return " \\ " + octothorps + String( curSpecial. 0 ) + octothorps
90+ //#endif
7991 }
8092 specialCharState = ( curSpecial. 0 , curSpecial. 1 + 1 )
8193 return " "
@@ -112,7 +124,11 @@ internal extension String {
112124 return prefix + " "
113125 }
114126 let escaped = scalar. escaped ( asASCII: asASCII)
115- return prefix + ( octothorpLevel == 0 ? escaped : escaped. replacingOccurrences ( of: #"\"# , with: #"\"# + octothorps, options: . literal) )
127+ //#if swift(>=5.4)
128+ // return prefix + (octothorpLevel == 0 ? escaped : escaped.replacingOccurrences(of: #"\"#, with: #"\"# + octothorps, options: .literal))
129+ //#else
130+ return prefix + ( octothorpLevel == 0 ? escaped : escaped. replacingOccurrences ( of: " \\ " , with: " \\ " + octothorps, options: . literal) )
131+ //#endif
116132 }
117133 }
118134 let asciiJoined = ascii. joined ( separator: " " )
@@ -121,6 +137,10 @@ internal extension String {
121137 }
122138
123139 private static let newLines = CharacterSet . newlines
124- private static let specialChars = CharacterSet ( charactersIn: #""\"# )
125-
140+ //#if swift(>=5.4)
141+ // private static let specialChars = CharacterSet(charactersIn: #""\"#)
142+ //#else
143+ private static let specialChars = CharacterSet ( charactersIn: " \" \\ " )
144+ //#endif
145+
126146}
0 commit comments