• skip to sidebar
  • skip to search box

trainedmonkey

by Jim Winstead Jr.

xml handling in php4

given xml input as a string with a xml declaration that specifies the encoding, what can i do to always get back utf-8 data in my character data handler?

that is, how do i get "i ♥ são paulo" as utf-8 given either of these two inputs:

<?xml version="1.0" encoding="iso-8859-1"?>
<foo>i &#9829; são paulo</foo>
<?xml version="1.0"?>
<foo>i &#9829; s&#227;o paulo</foo>

handling the second case is easy, it is the first case that i can't figure out.

and someone deserves a kick in the teeth for making php4's xml parser default to iso-8859-1.

» Friday, July 25, 2003 @ 6:17pm » 3 comments, add yours
« spy kids 3d • xml handling in php4: solved »

Comments

Have you tried:

xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8')

-adam

» Adam Trachtenberg (link) » Friday, July 25, 2003 @ 11:30pm

you may also specify an encoding to xml_parser_create() which should work.

» Sterling Hughes (link) » Saturday, July 26, 2003 @ 5:00am

S

» Joao Prado Maia (link) » Monday, July 28, 2003 @ 10:25am

Add a comment

Sorry, comments on this post are closed.

  • Home
  • About
  • Archive
  • Bookmarks
  • Photos
  • Projects
  • GitHub
  • @jimw@mefi.social

Dedicated to the public domain by Jim Winstead Jr.