mraiur Posted May 13, 2008 Share Posted May 13, 2008 Hi i have to make a rss veed that has to be made in two encodings everything is working but when i preview the rss -> "An invalid character was found in text content" . And when i saw the code there where "?" or "!" or "~!" something like this . And when i searched to find some answears it was a bug in PHP 4 that is fixed in PHP 5 but the problem is that the servers the feed is on my boss still refuse to upgrade to PHP 5 . So is there any way to overcome this problem? BTW: 1-encoding is UTF-8 and 2-encoding windows-1251 thx all Quote Link to comment Share on other sites More sharing options...
soycharliente Posted May 13, 2008 Share Posted May 13, 2008 Have you tried converting the characters to the HTML entities? Quote Link to comment Share on other sites More sharing options...
mraiur Posted May 13, 2008 Author Share Posted May 13, 2008 I just tried it but still it continues to "break"... Quote Link to comment Share on other sites More sharing options...
soycharliente Posted May 13, 2008 Share Posted May 13, 2008 So the formatting of the links won't work because you're using PHP4 to parse them? Do I understand correctly? Can we see some code? Quote Link to comment Share on other sites More sharing options...
mraiur Posted May 13, 2008 Author Share Posted May 13, 2008 its to much code to show i mean 1 i made was to cache all other is to read . and the main problem is that a sentence witch is for example in bulgarian in utf-8 is 8 symbols "Бългаски" but strlen shows its 16 symbols and substring for example cuts the string in the starting of the symbol ... i think Quote Link to comment Share on other sites More sharing options...
soycharliente Posted May 13, 2008 Share Posted May 13, 2008 I don't know enough about specific encodings to be much help. Quote Link to comment Share on other sites More sharing options...
mraiur Posted May 14, 2008 Author Share Posted May 14, 2008 Is there any other way to convert or something like that ... i tried converting the string to utf8 but yet again it still makes "invalid characters" ... Quote Link to comment Share on other sites More sharing options...
haku Posted May 14, 2008 Share Posted May 14, 2008 I'm fairly sure that you can only have one charset in a document, you cannot use a mixture of charsets. So if you are trying to use a mixture of charsets, your problem probably lies there. How exactly are you using this combination of charsets? Quote Link to comment Share on other sites More sharing options...
mraiur Posted May 14, 2008 Author Share Posted May 14, 2008 no i generate multiple files and the encoding witch has to be used is selected from the URL. So ?encoding=1 ( utf-8 files ) ?encoding=2 ( windows-1251 files ) Quote Link to comment Share on other sites More sharing options...
haku Posted May 14, 2008 Share Posted May 14, 2008 Its possible those characters don't exist in utf-8. Quote Link to comment Share on other sites More sharing options...
mraiur Posted May 14, 2008 Author Share Posted May 14, 2008 but the problem is that they are shown normaly but i need to cut the string for example 100 chars and when i see the cutted string "invalid character". Quote Link to comment Share on other sites More sharing options...
haku Posted May 14, 2008 Share Posted May 14, 2008 Ahh now I get it. Is this happening in both files, or only the file with windows-1251 encoding? Quote Link to comment Share on other sites More sharing options...
mraiur Posted May 14, 2008 Author Share Posted May 14, 2008 yea Quote Link to comment Share on other sites More sharing options...
effigy Posted May 14, 2008 Share Posted May 14, 2008 Have you tried iconv? What encoding is the source in? Quote Link to comment Share on other sites More sharing options...
haku Posted May 14, 2008 Share Posted May 14, 2008 yea That didn't really answer my question, but it's ok, I'm pretty sure I understand your problem. You will need to enable the mbstring (multi-byte string) library in php (it's not usually enabled by default), and then use the mbstring functions to cut the feed at 100 characters. This should solve your problem. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.