[ad_1]
I’ve a Swift app that takes in a base64 HTML doc and converts it to a string.
Right here is a part of the beginning string for demonstration of each examples.
"<html><head><meta http-equiv="Content material-Kind" content material="textual content/html; charset=utf-8" /><meta http-equiv="Content material-Fashion-Kind" content material="textual content/css" /><meta title="generator" content material="Aspose.Phrases for .NET 20.5" /><title></title><model kind="textual content/css">physique { widows:0; orphans:0; font-family:Arial; font-size:12pt }p { margin:0pt }.Footer { margin:0pt; text-indent:0pt; text-align:left; line-height:regular; widows:2; orphans:2; font-family:'Occasions New Roman'; font-size:12pt; font-weight:regular; font-style:regular; text-decoration:none; vertical-align:0pt; coloration:#000000 }.Header { margin:0pt; text-indent:0pt; text-align:left; line-height:regular; widows:2; orphans:2; font-family:'Occasions New Roman'; font-size:12pt; font-weight:regular; font-style:regular; text-decoration:none; vertical-align:0pt; coloration:#000000 }.Normal0 { margin:0pt; text-indent:0pt; text-align:left; line-height:regular; widows:2; orphans:2; font-family:'Occasions New Roman'; font-size:12pt; font-weight:regular; font-style:regular; text-decoration:none; vertical-align:0pt; coloration:#000000 }span.CharChar { font-size:12pt }</model></head><physique><div><div model="clear:each"><p class="Normal0" model="text-align:heart"><span model="font-weight:daring">DEMO SURGERY CENTER</span></p><p class="Normal0" model="text-align:heart"><span>21600 Made Up Road</span></p><p class="Normal0" model="text-align:heart"><span>Enjoyable Metropolis, CA 92222</span></p><p class="Normal0" model="text-align:heart"><span>Tel:</span><span>  </span><span>(818) 673-2900</span><span>    </span><span>Fax:</span><span>  </span><span>(818) 673-2950</span></p><p class="Header" model="font-size:11pt"><span> </span></p><p class="Header" model="text-align:heart; font-size:11pt"><span model="font-weight:daring">HISTORY AND PHYSICAL REPORT</span></p><p class="Header" model="font-size:11pt"><span> </span></p><p class="Header" model="font-size:11pt"><span model="font-weight:daring">PATIENT NAME</span><span>:</span><span>  </span><span>{%Patient_Name%}</span><span model="width:115.95pt; show:inline-block"> </span><span model="font-weight:daring">MEDICAL RECORD #</span><span>:</span><span>  </span><span>"
When I attempt to use the replacingOccurances operate, I get solely a part of the unique string returned, like it’s being escaped one way or the other
let resultData = Knowledge(base64Encoded: thisTemplate.base64FileInfo)!
let htmlString = String(information: resultData, encoding: String.Encoding.utf8)!
var outputString = htmlString.replacingOccurrences(of: "{%Patient_Name%}", with: "Take a look at, Affected person")
The returned String is minimize off, and no replacements had been made, that is the string I get in return
"<html><head><meta http-equiv="Content material-Kind" content material="textual content/html; charset=utf-8" /><meta http-equiv="Content material-Fashion-Kind" content material="textual content/css" /><meta title="generator" content material="Aspose.Phrases for .NET 20.5" /><title></title><model kind="textual content/css">physique { widows:0; orphans:0; font-family:Arial; font-size:12pt }p { margin:0pt }.Footer { margin:0pt; text-indent:0pt; text-align:left; line-height:regular; widows:2; orphans:2; font-family:'Occasions New Roman'; font-size:12pt; font-weight:regular; font-style:regular; text-decoration:none; vertical-align:0pt; coloration:#000000 }.Header { margin:0pt; text-indent:0pt; text-align:left; line-height:regular; widows:2; orphans:2; font-family:'Occasions New Roman'; font-size:12pt; font-weight:regular; font-style:regular; text-decoration:none; vertical-align:0pt; coloration:#000000 }.Normal0 { margin:0pt; text-indent:0pt; text-align:left; line-height:regular; widows:2; orphans:2; font-family:'Occasions New Roman'; font-size:12pt; font-weight:regular; font-style:regular; text-decoration:none; vertical-align:0pt"
It’s lacking the whole lot after “vertical-align:0pt” for some motive. This occurs on all HTML paperwork I try to change utilizing the String strategies in Swift 4. It additionally occurs when attempting to Cut up the String. (See Under). I have never discovered any particular characters, Why Would this be taking place???
If I cut up the string utilizing
let resultData = Knowledge(base64Encoded: thisTemplate.base64FileInfo)!
let htmlString = String(information: resultData, encoding: String.Encoding.utf8)!
var thisSplit = htmlString.elements(separatedBy: "{%")
I get two gadgets within the output.
[“<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ /><meta http-equiv=”Content-Style-Type” content=”text/css” /><meta name=”generator” content=”Aspose.Words for .NET 20.5″ /><style type=”text/css”>body { widows:0; orphans:0; font-family:Arial; font-size:12pt }p { margin:0pt }.Footer { margin:0pt; text-indent:0pt; text-align:left; line-height:normal; widows:2; orphans:2; font-family:’Times New Roman’; font-size:12pt; font-weight:normal; font-style:normal; text-decoration:none; vertical-align:0pt; color:#000000 }.Header { margin:0pt; text-indent:0pt; text-align:left; line-height:normal; widows:2; orphans:2; font-family:’Times New Roman’; font-size:12pt; font-weight:normal; font-style:normal; text-decoration:none; vertical-align:0pt; color:#000000 }.Normal0 { margin:0pt; text-indent:0pt; text-align:left; line-height:normal; widows:2; orphans:2; font-family:’Times New Roman’; font-size:12pt; font-weight:normal; font-style:normal; text-decoration:none; vertical-align:0pt”, ” Patient_Name%}<span style=”width:115.95pt; display:inline-block”>Â <span style=”font-weight:bold”>MEDICAL RECORD #:Â “]
This is a matter as a result of the primary result’s lacking a big portion of the string after vertical-align:0pt. Right here is the lacking portion of the String
“; coloration:#000000 }.Header { margin:0pt; text-indent:0pt; text-align:left; line-height:regular; widows:2; orphans:2; font-family:’Occasions New Roman’; font-size:12pt; font-weight:regular; font-style:regular; text-decoration:none; vertical-align:0pt; coloration:#000000 }.Normal0 { margin:0pt; text-indent:0pt; text-align:left; line-height:regular; widows:2; orphans:2; font-family:’Occasions New Roman’; font-size:12pt; font-weight:regular; font-style:regular; text-decoration:none; vertical-align:0pt; coloration:#000000 }span.CharChar { font-size:12pt }DEMO SURGERY CENTER
21600 Made Up Road
Enjoyable Metropolis, CA 92222
Tel: (818) 673-2900 Fax: (818) 673-2950
HISTORY AND PHYSICAL REPORT
PATIENT NAME:”
Why is that this string being escaped/cut up/minimize when the part is not a match???
[ad_2]
