LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Gedit wierd charaters (https://www.linuxquestions.org/questions/linux-general-1/gedit-wierd-charaters-909154/)

Dr_Lion 10-20-2011 08:07 AM

Gedit wierd charaters
 
I'm not sure if this is the right place to post, if not be free to change and let me know.

I'm trying to open a .csv file in gedit (ubuntu lucid) and i get weird charaters as the title says, in open office it opens how it should, and if a try the cat in console i get the right output too.

i've searched a bit and i red something with fonts, in openofice it says Arial, i installed de package msttfonts but the problem didn't disapear.

Anyone knows how to fix this?

Thanks in advance.

corp769 10-20-2011 08:53 AM

Hello,

Could you post part of the file you are trying to open to better assist us? And also if you can, a screenshot if the characters don't appear within the post, thanks!

Cheers,

Josh

SecretCode 10-20-2011 09:17 AM

Gedit doesn't care about fonts, being a text editor. But it does care about character encoding, and that may be the problem. Is it perhaps a file from a windows system?

David the H. 10-20-2011 01:40 PM

Well, fonts can be a problem if the one you're using doesn't have a needed character in it, but that's rather rare unless the text is in some uncommon language. An encoding problem is certainly more likely, particularly if there are just a few bad oddball characters scattered around the text.

gedit seems to offer no way to change the text encoding after a file is loaded, but the open dialog has a field at the bottom for selecting the encoding as you load it. You can also use the --encoding option on the command line.

Most editors try to autodetect encodings when loading the file, but they aren't perfect at it. Windows has traditionally used cp-1252, a Microsoft "variant" of ISO-8859, for English text. Other variants are available for various European languages. Keep trying them until you find one that works. Linux uses UTF-8, by the way.

You can use iconv to batch-convert files from one encoding to another, once you know what they are. You can try running the chardet command on it to see what comes up, but it's not always that accurate either (it likely uses the same library calls as the editors). If the output is less than 100% certain, don't trust it.

Finally, on a related note, don't forget that there's a difference between dos and unix style line-endings. Some programs auto-convert these as well, but not all. There are many options for manually converting line-endings in files, so I'll leave that as a research exercise for the OP. :study:

DavidMcCann 10-21-2011 12:00 PM

If you don't know the encoding, can you tell us a character you're getting and what you think it should be? For example, I had a .txt file once that caused trouble. Once I saw Õ where there should be an apostrophe, I could look it up and see it Apple's 'Standard Roman'.

Dr_Lion 10-27-2011 05:30 AM

Well, i didn't solve my problem, but anyway with the cat command line it works, show it right, and for what i need i don't really need the gedit.

Now it's even better i would post it here but the gedit can't open it now, it says to choose the charset encoding, and ask for retry.

Thanks for the advices anyway.


All times are GMT -5. The time now is 03:01 PM.