title: Invalid UTF-8 Error when saving Leaflet Widget in R
body: <p>I'm creating a Leaflet widget in R using the following code</p>
  
  <pre><code>m &lt;- leaflet(map_data_wgs84) %&gt;% addTiles() %&gt;% addCircles(popup = (paste(sep="&lt;br/&gt;", as.character(map_data_wgs84$MEMBER_REF), map_data_wgs84$Name)))
  
  saveWidget(m, file="c://software//members.html")
  </code></pre>
  
  <p>I want a popup that palaces an ID number and name separated by a line break. However when I run the saveWidget command I get the following error</p>
  
  <pre><code>Error in gsub("&lt;/", "\\u003c/", payload, fixed = TRUE) : 
    input string 1 is invalid UTF-8
  </code></pre>
  
  <p>which is because of the <code>&lt;br/&gt;</code> separator.</p>
  
  <p>What am I doing wrong here?</p>
  
  <p>thanks</p>
  
  <p><strong>UPDATE:</strong>
  it would appear it is <strong>not</strong> the <code>&lt;br/&gt;</code> separator but rather character(s) in the map_data_wgs84$Name column. These 12000 records are pulled from a contact database before mapping.</p>
  
  <p>I suspect I need some way to make the characters clean for use in Leaflet with something like htmlEscaoe however I cant figure out how to use this within paste. This doesnt work because htmlEscape is parsed as a string:</p>
  
  <pre><code>addCircles(popup = paste(as.character(map_data_wgs84$MEMBER_REF), ~htmlEscape(map_data_wgs84$Name), sep=","))
  </code></pre>
  
  <p>For for a MEMBER_REF of 56202 the popup becomes:</p>
  
  <p>56202,htmlEscape(map_data_wgs84$Name)</p>