Using the British pound sign in an XML feed to be read by an iPhone

前端 未结 4 799
梦如初夏
梦如初夏 2021-01-05 15:33

I have created a web-based UTF-8 XML feed for use in an iPhone application.

When viewing in a web browser, if the feed contains a British Pound sign, I get a nasty X

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-05 15:46

    My final solution which seems to work in all cases is to replace all special chars as they are input.

      public function xmlEntities($text)
      {
        $search = array('&','<','>','"','\'', chr(163), chr(128), chr(165));
        $replace = array('&', '<', '>', '"', ''', '£', '€', '¥');
    
        $text = str_replace($search, $replace, $text);
    
        return $text;
      }
    

提交回复
热议问题