Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: charset problem with Ajax XML Ticker (txt file source)

  1. #1
    Join Date
    Feb 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default charset problem with Ajax XML Ticker (txt file source)

    1) Script Title:
    Ajax XML Ticker (txt file source)
    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...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?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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/s...ead.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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Feb 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Feb 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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,

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Feb 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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/dynamici...tmlticker.htm). Anybody helps?

    Thanks

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    If the data is coming from your server and you have something like PHP or asp, I don't see why not.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    Feb 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

  10. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The script:

    http://www.dynamicdrive.com/dynamici...htmlticker.htm

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

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •