Strange windows -> samba -> linux file types/encoding

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
nogero

Strange windows -> samba -> linux file types/encoding

Post by nogero »

I could swear I have done similar things many times before without this issue. I have as mint 8 box with samba. I get on a windows PC and "copy myfile.txt \\mint-server\mydir\myfile.txt (copy it to my home folder on the linux box).

Then I login on the linux machine as a normal user and try to mail this file with:
mail -s "here is my file" user@domain.com < myfile.txt
This results in an email message with a few junk characters displaying, no text.
If I 'vi myfile.txt' it shows text just fine.
If I 'more myfile.txt' it shows garbage just like the emailed message.
If I 'cat myfile.txt' it displays text of file correctly.

So there is something about this windows text file that fools "more" and "mail" into thinking it is something other than plain text. If I do command "file myfile.txt" it shows:
"Little-endian UTF-16 Unicode text, with CRLF, CR line terminators"
I expected to see "ASCII text".

if I do a "hd myfile.txt" it shows nulls between each letter of text, here are first two lines of output that begins with "Backup Status"
00000000 ff fe 42 00 61 00 63 00 6b 00 75 00 70 00 20 00 |..B.a.c.k.u.p. .|
00000010 53 00 74 00 61 00 74 00 75 00 73 00 0d 00 0a 00 |S.t.a.t.u.s.....|
So it has a character at the beginning I did not expect, and a null between each character. I expected to see:
00000000 42 61 63 6b 75 70 20 53 74 61 74 75 73 0a 4f 70 |Backup Status.Op|
00000010 65 72 61 74 69 6f 6e 3a 20 42 61 63 6b 75 70 0a |eration: Backup.|


Does anyone know why this is happening?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
lbearl

Re: Strange windows -> samba -> linux file types/encoding

Post by lbearl »

That is a very interesting issue. My first hunch would be that you are saving the file in the text editor using an UTF encoding which some core GNU utilities might not handle properly (such as more). The first question I would wonder is if you are using notepad.exe or something else in windows to create the file, as a lot of other text editors will default to a UTF encoding. If you can change the encoding of the text, that might fix the issue.

Good luck with the issue.
Locked

Return to “Beginner Questions”