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 Link to comment https://forums.phpfreaks.com/topic/105423-encoded-string-problem/ 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? Link to comment https://forums.phpfreaks.com/topic/105423-encoded-string-problem/#findComment-539877 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"... Link to comment https://forums.phpfreaks.com/topic/105423-encoded-string-problem/#findComment-539895 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? Link to comment https://forums.phpfreaks.com/topic/105423-encoded-string-problem/#findComment-539900 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 Link to comment https://forums.phpfreaks.com/topic/105423-encoded-string-problem/#findComment-539922 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. Link to comment https://forums.phpfreaks.com/topic/105423-encoded-string-problem/#findComment-539924 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" ... Link to comment https://forums.phpfreaks.com/topic/105423-encoded-string-problem/#findComment-540684 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? Link to comment https://forums.phpfreaks.com/topic/105423-encoded-string-problem/#findComment-540689 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 ) Link to comment https://forums.phpfreaks.com/topic/105423-encoded-string-problem/#findComment-540692 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. Link to comment https://forums.phpfreaks.com/topic/105423-encoded-string-problem/#findComment-540694 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". Link to comment https://forums.phpfreaks.com/topic/105423-encoded-string-problem/#findComment-540696 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? Link to comment https://forums.phpfreaks.com/topic/105423-encoded-string-problem/#findComment-540722 Share on other sites More sharing options...
mraiur Posted May 14, 2008 Author Share Posted May 14, 2008 yea Link to comment https://forums.phpfreaks.com/topic/105423-encoded-string-problem/#findComment-540766 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? Link to comment https://forums.phpfreaks.com/topic/105423-encoded-string-problem/#findComment-540954 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. Link to comment https://forums.phpfreaks.com/topic/105423-encoded-string-problem/#findComment-541061 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.