PDA

View Full Version : charset problem with Ajax XML Ticker (txt file source)



diamondnular
02-28-2007, 05:50 AM
1) Script Title:
Ajax XML Ticker (txt file source)
2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex2/ajaxticker.htm
3) Describe problem: The ticker displays everything fine if txt file is coded in utf-8. But when I tried with different charset (with some special characters of course, for example ISO-8859-2, then some characters disappear. Maybe it is a font problem? Any body help?

jscheuer1
02-28-2007, 06:54 AM
First off, this is likely to be a problem that can only really be addressed on the server. In any case, a local solution would be just that, local. So, I would suggest going live with a test page to make sure it even is a problem on the server. If it is, you can try modifying the server configuration or the .htaccess file or other things as mentioned in this thread:

http://www.dynamicdrive.com/forums/showthread.php?t=3644

particularly post#2 in that thread but, using the encoding required by your pages.

Another option you can try is to make sure that you use the HTML named or numbered entities rather than the characters themselves in your external file.

diamondnular
03-01-2007, 02:00 AM
Hi John,

yes, I did think of the server, and also the meta tag is configured correctly (ISO-8859-2). Notice that everything else displays fine, just the ticker does not. But changing server seems odd, because I think the code should work with any charset.

Can you explain more about the second option? How I can code external file with HTML named or numbered entities?

Thanks.

jscheuer1
03-01-2007, 05:43 AM
The server could perhaps be configured to serve your file as text/html with the proper encoding. What happens in scripts like these is that the server serves one file to another before serving the whole thing to the user. What probably is currently happening is that the server is serving the .txt page to the HTML page as text/plain.

On the other front, as I don't know which exact characters you are talking about, I'll use the British pound symbol as an example. In your external file it could be entered as:

- (that's the symbol itself, in case your browser isn't rendering it as I entered it)

or as the HTML named entity:

£

or as the HTML numbered entity:

£

or possibly even as the javascript hex code:

\xa3

Using any of these strategies may get you what you are after.

diamondnular
03-01-2007, 06:19 AM
Hi John,

Oh now I understand that. So if I create txt file by the server as well (for example, read news or css from other UTF-8 sites), then the process will be: UTF-8 (external server) -> txt file (with HTML numbered entities) -> ticker (my own server, ISO-8859-2). People when accessing my pages (meta tag ISO-8859-2 already) will read without any problem. Isn't that correct?

If the process above is correct, then I need a code to change from any charset to HTML numbered entities. This seems to be difficult. Do you have any idea about that? Is there such a code?

Thanks,

jscheuer1
03-01-2007, 06:28 AM
Well, that was meant as two separate avenues you might want to pursue. Obviously, if the content in your external file is generated server side and you have no way to have it use entities, the easiest thing would be to have it get served with the proper encoding, thus eliminating the need for entities.

If that can't be made to happen, there may be a utility around to convert to entities. This should probably be done as the external file is written, before it is served the first time. Such a utility should be written for the environment in which the external file is being generated.

diamondnular
03-01-2007, 06:00 PM
Hi there,

I hava another idea. This Ajax XML Ticker looks messages in text file and displays that. Can I change something so that I can include the txt file in the same page - ie Ticket does not need to look for a file, just read the page content and display that (like the one in http://www.dynamicdrive.com/dynamicindex2/prohtmlticker.htm). Anybody helps?

Thanks

jscheuer1
03-01-2007, 06:18 PM
If the data is coming from your server and you have something like PHP or asp, I don't see why not.

diamondnular
03-01-2007, 07:15 PM
Hi John,

Now I need to change something in ajaxticker.js so that it will look for <div class="message"> inside the page (not in the external file). How can I do that? I am totally newbie for javascript and do not know how to do. If anyone can help, I appreciate that.

Thanks.

jscheuer1
03-02-2007, 03:14 AM
The script:

http://www.dynamicdrive.com/dynamicindex2/prohtmlticker.htm

that you pointed out already has that feature. Why not use it?

diamondnular
03-02-2007, 03:44 AM
Hi John,

I prefer Ajax XML Ticker because it has a fading effect that ProhtmlTicker does not. I have two options:

1. Change the code Ajax Ticker so that it works the same way as Prohtml (reads messages in the same page, not external page)

2. Change the code ProHTML so that it has more options like fading.

I am playing around with these two scripts but still no luck. Javascript seems beyond me (I have never leanred programming before :)). Anybody can help, or can point out to me the way to understand the scripts?

Thanks.

jscheuer1
03-02-2007, 06:16 AM
You also may want to consider:

http://www.dynamicdrive.com/dynamicindex2/fadescroll.htm

or any of the other pure DHTML scrollers. You shouldn't feel limited to scrollers with their content in a division. If you are using a server side language to resolve data into the page as it loads, that data may be as easily resolved into the appropriate spots in a javascript array as into HTML code in a division.

In any event, it would probably be easier to modify a script that already has content on the page somewhere, than one that was designed to pull from another file via Ajax or xml.

diamondnular
03-04-2007, 04:20 AM
Hi John,

Yes, I found DHTML Ticker Script (http://dynamicdrive.com/dynamicindex2/generaltick.htm) which is very similar to the one you suggested. But the one I found to be most powerful is ProHTML and I am trying to add some more options to that.

Best,

diamondnular