Got it!
{ Big sigh }
Cake's Xml classes use PHPs "Xml Parser". And PHPs parser
automatically converts the contents to UTF-8.
http://www.php.net/manual/en/xml.encoding.php
So no matter what I had in the file (of the three supported charsets
at least) I will end up with utf-8 text. Good to know.
While I was in there looking at __header I came to the conclusion that
this line:
---line 866
$this->__header = trim(str_replace(a('<' . '?', '?' . '>'), a('', ''),
substr(trim($this->__rawData), 0, strpos($this->__rawData, "\n"))));
---
should look like this:
---
$this->__header = trim(str_replace(a('<' . '?', '?' . '>'), a('', ''),
substr($this->__rawData, 0, strpos($this->__rawData, '?' . '>'))));
---
or
---
$this->__header = trim(str_replace(a('<' . '?', '?' . '>'), a('', ''),
substr(trim($this->__rawData), 0, strpos(trim($this->__rawData), '?' .
'>'))));
---
Changes are:
1. Shouldn't it look for the end of the xml header and not the end of
the line?
2. And shouldn't the substr and strpos both either trim the data or
not, so strpos is correct at all times. I know the xml shouldn't
contain any whitespace up-front but the trims should match so either
two of them or none, right?
On Jan 22, 6:19 pm, Martin Westin <[email protected]> wrote:
> Hi ReVo,
>
> $__header contains a string of the first line in the xml. this will
> usually contain something like
> xml version="1.0" encoding="UTF-8"
> since the tag characters are stripped away. But it may also contain
> the whole of, or part of, the xml since xml files are valid without
> any whitespace.
>
> Alternative 2 is not an option since I want to find out what charset
> the xml is, not just set the attributes in the Xml object. I want to
> know the charset so I can properly convert all text in the xml for
> display.
>
> Using SimpleXML (or "ComplicatedXML" for php4) sort of defeats the
> purpose. I am not doing something very complicated but It would suck
> to have to toss Cake's Xml and use something else. I think I would
> rather just edit the Xml class to store these values if it is in fact
> a missing or "broken" functionality.
>
> Sorry, i am a but cranky... time for some food I guess.
> Thank you for your suggestions.
>
> /Martin
>
> On Jan 22, 4:08 pm, RoVo <[email protected]> wrote:
>
> > Hi Martin,
>
> > the header is stored in:
> > var $__header = null;
> > may be, it's only used in the header-function of xml.php?!?
>
> > but alternatively you can use the option-param e.g.:
> > $rss = new XML($url_to_an_rss_feed, array('encoding'=>'ISO-8859-1') );
>
> > If you have PHP5, as well you can use SimpleXML - like
> > Tim:http://debuggable.com/posts/parsing-xml-using-simplexml:480f4dfe-6a58...
>
> > Hope that helps
> > RoVo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---