Code looks fine in text editor; is gibberish on server

Discussion in 'Web Design and Development' started by PaperQueen, Jan 30, 2009.

  1. PaperQueen macrumors 6502

    PaperQueen

    Joined:
    Aug 16, 2007
    Location:
    Just this side of insanity (Minneapolis)
    #1
    Disclaimer: I am not a coder, so please be gentle. :eek:

    I’m tweaking a custom.css file for use my blog (Thesis, for those who care). When I view it in TextEdit, TextMate, or GoLive, it looks fine. After it’s been uploaded to the server, apostrophes in web addresses turn to gibberish or question marks.

    I’ve uploaded through both Fetch and GoLive. Fetch seems to produce question marks while GoLive substitutes “— gibberish.

    Anyone have any insight to share? Can’t be the browser, since it appears the same in both Firefox and Safari, as well as to a third party offsite.

    Help, please...?
     
  2. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #2
    Make sure you upload text files (source code/css) as ASCII and not binary. That's the very first thing you check. Also make sure you're saving the file as plane ASCII, not rich text. Questions marks mean certain characters could not be recognized within the default encoding. These are the common things to check.

    Others here might offer additional advice so stay tuned.

    -jim
     
  3. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #3
    Could potentially be a character set issue. Do you have a line in your code at the top resembling this,
    HTML:
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    The browser or the server may be misrepresenting the correct character set that was used when creating the page. This is a common issue that I see on many web sites.

    Also, were you copying and pasting text from say MS Word, into your document? This can also create issues as there are different types of apostrophes and other symbols.
     
  4. PaperQueen thread starter macrumors 6502

    PaperQueen

    Joined:
    Aug 16, 2007
    Location:
    Just this side of insanity (Minneapolis)
    #4
    Hi Jim,

    The way I’m going at this is to open the file from inside whatever editor is being used (File > Open), type in the changes, then save. Each of the three editors has retained the .css in the document name, so I know it’s not converting to rtf.

    To upload, I’m simply dragging the document into Fetch, which then overwrites the existing file on the server.

    How would I be able to tell if a file is being saved in ASCII versus binary? Wouldn’t binary show 1s and 0s when I looked at the newly saved (or downloaded from the server) file? Or am I being blind here?

    Like I said....not a coder.....
     
  5. PaperQueen thread starter macrumors 6502

    PaperQueen

    Joined:
    Aug 16, 2007
    Location:
    Just this side of insanity (Minneapolis)
    #5
    Nope. No sign of the character set line anywhere in the file.

    Again, no. Wouldn’t go near Word for anything web related. Typically, I work in GoLive, but given this coding issue, I’m also trying to correct the problem in TextEdit and TextMate.
     
  6. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #6
    There's different definitions for binary. Yes, it can mean 1s and 0s, but also it refers to complex file formats that are not human readable, in contrast to a plain text file. You gave an example of what you saw, if everything looks like that it could be a binary vs ascii issue, but if it's just for a couple characters it's more likely a character set issue as I hinted to.

    Since your page doesn't contain a tag saying what character set to use, let's give it one. First try the one I gave. If that doesn't help, try replacing ISO-8859-1 with UTF-8. Also, if you have a link it may be easier to diagnose. In your browser you can also try setting different character sets. In Firefox, if you go under the View menu you'll see a Character Encoding option. From there you can manually set different sets. Trying picking different ones to see if it clears up those odd characters. That'll tell you what your document is using.
     
  7. PaperQueen thread starter macrumors 6502

    PaperQueen

    Joined:
    Aug 16, 2007
    Location:
    Just this side of insanity (Minneapolis)
    #7
    Next chapter in this tale of pain....

    Well, now I’m editing directly on the server through my cPanel, but still no luck. For some reason, the (fill in your favorite explative) quotation marks and apostrophes are going “smart,” tilting at angles rather than remaining plain and straight.

    The host can go in and correct it on their end, but since I’m in the midst of designing a new blog on a subdomain, that could mean 25+ phone calls per day.

    Anyone have a clue what the solution is for this? Have tried both Firefox and Safari, but that latter won’t even LET me edit the code. Very, very frustrating.
     
  8. PaperQueen thread starter macrumors 6502

    PaperQueen

    Joined:
    Aug 16, 2007
    Location:
    Just this side of insanity (Minneapolis)
    #8
    I don’t know if this makes a difference or not, but the file is custom.css, not a web page. By adding a tag calling out a character set, won’t I run the risk of the css not functioning properly (this is in Thesis for Wordpress, if that helps at all)?

    I wish I did; since it’s not a page, but a css file, no clue what I could send.

    Sadly, this didn’t make a difference. I opened up the code editing screen on my cPanel, then tried all four character sets listed in the Firefox View menu, typing quotation marks in each to see if one would stay straight. No luck. They all went “smart” (a word I’ve come to hate in the past 24 hours).
     
  9. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #9
    Attach the CSS file either zipped up or renamed with .txt on the end (i.e. Custom.css.txt). Then give us the link to any web page which is linking that file on the server. Armed with that, one of us will solve this issue.

    -jim
     
  10. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #10
    I missed that is was a CSS file by itself. I thought is was the CSS inside and HTML file. Adding that tag won't make a difference of course then.

    I figured it might be a smart quote issue (though forgot their name), but it's weird how they're popping in there. If you edit the file locally and use non-smart quotes, then upload that file through FTP, do the quotes get smartied? Apparently their cPanel wasn't setup to be the most helpful.

    Edit: It's a WordPress issue. I found a plug-in that address modifying source code. This should be of help.
     
  11. eskalation.dk macrumors member

    Joined:
    Oct 4, 2006
    #11
    Hi,

    i might be of help.

    Your problem might be that your document is in encoded in ISO-8851 whereas it needs to be in UTF-8. It all depends on what the server wants and what you have set your document encoding to be.

    It sounds to me like a mismatch. If your document is a UTF-8 and your <meta> tag says that the encoding is ISO, then your browser will try to enterprit the file as a ISO file, but the app will probably say that your file is whatever your file-setting is set to be. My advice is to go se what your file setting is in your local web editor.

    What program do you use to edit your webfile?
     
  12. PaperQueen thread starter macrumors 6502

    PaperQueen

    Joined:
    Aug 16, 2007
    Location:
    Just this side of insanity (Minneapolis)
    #12
    Unfortunately, the plugin only applies to quotes and apostrophes in posts-—not those in the underlying code. To test the theory, I installed the plugin and tried it. No go.
     
  13. PaperQueen thread starter macrumors 6502

    PaperQueen

    Joined:
    Aug 16, 2007
    Location:
    Just this side of insanity (Minneapolis)
    #13
    Here goes.... I just pulled this down from the server, so no clue if you’ll see straight apostrophes and quotes or if they’ll “go smart” again.

    The page I’m working on is located on a subdomain (rather than drag my current blog viewers through the hell this has been to fix):
    test.alwaysupward.com/wordpress

    Thanks for staying with me on this one. Truth be told, if we could just find a way for me to edit the code through the browser, I’d be thrilled. Of the four named encoding options in Firefox (View > Character Encoding), none allow me to type straight apostrophes or quotes.

    As mentioned earlier, Safari won’t allow me to edit on the server at all.
     

    Attached Files:

  14. PaperQueen thread starter macrumors 6502

    PaperQueen

    Joined:
    Aug 16, 2007
    Location:
    Just this side of insanity (Minneapolis)
    #14
    TextEdit
    TextMate
    GoLive

    Also:
    cPanel > File Manager ... Code Edit
     
  15. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #15
    I looked at the file with BBEdit, and I'm not seeing the smart quotes here. The file looks to be encoded using UTF-8, which is good. I looks like cPanel is just doing the harm. Do you have to use cPanel. What if you just directly FTP the file into place? Is that an option for you?
     
  16. PaperQueen thread starter macrumors 6502

    PaperQueen

    Joined:
    Aug 16, 2007
    Location:
    Just this side of insanity (Minneapolis)
    #16
    That’s actually where the problem first cropped up. No matter how I get the file to the server, once it’s there, the server sees smart quotes. Even when I view the file through cPanel, there are smart quotes. No matter where I try to edit the file, there are problems.

    As mentioned above, the file has been edited in three programs (TextEdit, TextMate, and GoLive). It’s been uploaded via GoLive and Fetch. In all cases, the server converts the file to smart quotes.

    When editing in cPanel (> File Manager), the quotes and apostrophes I type appear as smarties.

    I’ve tried editing in cPanel using Firefox (created smart quotes) and Safari (won’t allow me to edit).
     
  17. PaperQueen thread starter macrumors 6502

    PaperQueen

    Joined:
    Aug 16, 2007
    Location:
    Just this side of insanity (Minneapolis)
    #17
    Also-—what you’re seeing is the corrected version that my webhost fixed. When they do it via Firefox (on PC) from their end, it works.

    When I do it via Firefox on my Mac, it doesn’t work.

    I haven’t touched the thing since they fixed the quotes, other than to test single quotes, then delete them when they continue to appear as smarties.
     
  18. PaperQueen thread starter macrumors 6502

    PaperQueen

    Joined:
    Aug 16, 2007
    Location:
    Just this side of insanity (Minneapolis)
    #18
    I’ve uploaded a sample of what’s happening at:

    http://alwaysupward.com/trial_run.txt

    You’ll see examples of text that was edited in TextEdit, as well as a second set of lines edited directly on the server via cPanel.
     
  19. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #19
    @OP:

    Thanks for uploading the CSS file and sending us the link. I examined and the file is fine and your web page is indeed using the UTF-8 character set. However, I noticed one irregularity in your HTML that links this specific CSS file compared to the others:

    HTML:
    <link rel="stylesheet" href="http://test.alwaysupward.com/wordpress/wp-content/themes/thesis/custom/custom.css?013009-150143" type="text/css" media="screen, projection" />
    Specifically I mean the "?013009-150143" argument appended on the end of the filename. You load other style sheets with the .php extension and various arguments which is perfectly legal (for those reading this not familiar with the concept, it's called dynamic CSS) and a few more with the .css extension without any argument since they're not dynamic, and no issues with any of those.

    Interestingly, the custom.css validates fine with that argument or not.

    So my advice is remove the "?013009-150143" on the end in the link tag calling custom.css and see if that improves the situation. It's just speculation at this point, but it appears the WordPress, encoding and editor related aideas posed by the group hasn't yet solved this issue so... WTF, why not try it? Worst thing that could happen is I'm wrong. I've been wrong before!

    -jim
     
  20. PaperQueen thread starter macrumors 6502

    PaperQueen

    Joined:
    Aug 16, 2007
    Location:
    Just this side of insanity (Minneapolis)
    #20
    @ SrWebDeveloper

    I don’t mean to be dense, but what file is that string in? I know you referred to the html file, but the only two files I’ve laid fingers on have been the custom.css and custom_functions.php. Anything else in the WP database is as originally written by the developer. The only html document I can find anywhere is the “read_me.html” which obviously wouldn’t be the ticket.

    Since this bizarre smart quotes thing occurs everywhere-—on the test document (post #18), in the cPanel, and in all three text editors-—this appears to be the result of some hidden setting somewhere on my laptop. That’s the only common link other than the server, which the host is able to edit with straight quotes from their end (using a PC, crud).

    Is that crazy? It’s definitely not driven by WP or the test document wouldn’t be doing this too, since it’s outside the WP folders.
     
  21. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #21
    What I was referring to was the link tag I found in the HTML source when I viewed source of the page you linked above: http://test.alwaysupward.com/wordpress/

    It's probably in a WordPress template, but if you're not sure which file and you have a local copy on your Mac in "sites" use spotlight to find it or any find utility (look for any reference to "custom.css"). This might not solve your trouble, it was just an observation. Edit the template or whatever file has that link tag, remove the argument on the end, that's all I'm suggesting.

    -jim
     
  22. PaperQueen thread starter macrumors 6502

    PaperQueen

    Joined:
    Aug 16, 2007
    Location:
    Just this side of insanity (Minneapolis)
    #22
    Surrender...and success

    Based on angelwatt’s preferred use of BBEdit, I broke down and tried it (the fourth text editing option tried thus far...or was it fifth?). Thankfully, BBE has a drop down file option to whip quotes into shape (Text > Straighten quotes). Without it, I’d be in a heap.

    Now...if I could only figure out why every third or fourth time I need to upload to the server BBE tells me it can’t due to a program error. Trading one frustration for another..........sigh.........

    Thanks to everyone who swung at the fence on this one. You guys rock.
     
  23. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #23
    Just saw that BBEdit released a new update (9.1.1), which reworked some issues with the S/FTP. The update may address the issue you were having. I've only rarely used that feature and didn't have problems personally, but obviously some people were since they reworked it.
     
  24. PaperQueen thread starter macrumors 6502

    PaperQueen

    Joined:
    Aug 16, 2007
    Location:
    Just this side of insanity (Minneapolis)
    #24
    Thanks for the heads up, angelwatt. I’m headed over there now.
     

Share This Page