LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-09-2007, 08:15 AM   #1
radiodee1
Member
 
Registered: Oct 2006
Location: New York
Distribution: Debian
Posts: 675
Blog Entries: 11

Rep: Reputation: 36
html doc transformed to binary


I'm running Debian Etch. I've installed apache2 and have setup a website on the localhost ip address. I'll never really go online. I had apache setup the same way on my windows partition before I had linux, and since then I have been moving files from the old site to the new site.

There is one page that displays wrong. Apache2 shows it as normal letters with lots of spaces in between them, though you cannot read them. When firefox is told to show the page wihtout the server ("open file...") the page comes up fine. When I look at the page with vim the contents are correct, but gedit and kate cannot display the page right. Gedit complains the page is in the wrong character encoding (not UTF-8?), and kate says the page is a binary. Kate ultimately shows the file with a space after every letter. If I "cat" the file I can see it, but "less" says the file may be binary and shows junk on the screen. How do I get my document back?
 
Old 01-09-2007, 08:48 AM   #2
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
If cat is displaying it correctly, try
Code:
cat yourfilename > yournewfilename
 
Old 01-09-2007, 10:41 AM   #3
radiodee1
Member
 
Registered: Oct 2006
Location: New York
Distribution: Debian
Posts: 675

Original Poster
Blog Entries: 11

Rep: Reputation: 36
I try

Code:
cat general.html > general.html2
rm general.html
cp general.html2 general.html
but the browser, when going through apache2, can't display it. Gedit won't display it either. I can still look at it with vim. Any ideas?
 
Old 01-09-2007, 10:46 AM   #4
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Try
Code:
file general.html
to see what kind of file it is... it may shed some light on this problem. Otherwise, can't you just open it in vim, copy all the contents and then paste them into a new file?
 
Old 01-09-2007, 10:51 AM   #5
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
iconv -f ISO-8859-1 -t UTF8 general.html > general_utf8.html

You may have to download iconv and also modify the -f ISO-8859-1 which is the current encoding of the file (eventhough it works as is in lots of case)
 
Old 01-09-2007, 11:56 AM   #6
radiodee1
Member
 
Registered: Oct 2006
Location: New York
Distribution: Debian
Posts: 675

Original Poster
Blog Entries: 11

Rep: Reputation: 36
I type

Code:
iconv -f ISO8859-1 -t UTF-8 general.html > general_utf8.html
cp general_utf8.html general.html
I can still look at general_utf8.html, but apache2 still won't show it. The "file" command has improved. Before it said nothing after the word "general.html".

Quote:
file general_utf8.html
general_utf8.html: data
Do I have the right encodings? Where do I see what they are? "iconv -l" just gives a list.

EDIT: after the "iconv" command, I can still see the file with "cat" but no longer with "vim". The file opens up, but every other character is unreadable... mostly blue carrot (^) and blue ampersand (@)...

Last edited by radiodee1; 01-09-2007 at 12:03 PM.
 
Old 01-09-2007, 12:29 PM   #7
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
First, what says:
locale

Blue ampersand? humm then the conversion failed or your machine is not in utf8 (result of locale is the minimum)

You have to know which encoding is for this original file (I have no clue how to know this, the only way I do it is with od -x filename )
If you are in a hurry, use the mouse as someone said
 
Old 01-10-2007, 06:36 AM   #8
radiodee1
Member
 
Registered: Oct 2006
Location: New York
Distribution: Debian
Posts: 675

Original Poster
Blog Entries: 11

Rep: Reputation: 36
In the end I used "cat" to display the file (a version of the file I had saved from before I used "iconv") and I copied and pasted the contents into another text editor. The file was too long for the xterm memory, (even when I had scrolled all the way to the top there was still stuff missing from the beginning of the file) so I had to do part of it in pieces from "vim". Thanks pwc101. Thanks everyone for the advice.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
converting DOC to HTML using PHP Xing Programming 3 02-17-2009 06:32 AM
convert odt or .doc into html linuxmandrake Linux - Software 6 02-23-2008 03:48 AM
Php to return a binary not html logicdisaster Programming 3 10-07-2004 01:25 PM
.html to MS Word doc h/w Linux - Software 5 12-06-2003 03:28 PM
Konqueror + file:/usr/share/doc/HTML/index.html jon_k Linux - Software 2 11-25-2003 05:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration